diff --git a/src/containers/Flow/FlowList/FlowList.test.tsx b/src/containers/Flow/FlowList/FlowList.test.tsx index 18376583e..686ed895e 100644 --- a/src/containers/Flow/FlowList/FlowList.test.tsx +++ b/src/containers/Flow/FlowList/FlowList.test.tsx @@ -16,7 +16,7 @@ import { } from 'mocks/Flow'; import { getOrganizationQuery } from 'mocks/Organization'; import testJSON from 'mocks/ImportFlow.json'; -import { setUserSession } from 'services/AuthService'; +import { setOrganizationServices, setUserSession } from 'services/AuthService'; import { FlowList } from './FlowList'; import { Flow } from '../Flow'; import { getFilterTagQuery } from 'mocks/Tag'; @@ -67,7 +67,8 @@ vi.mock('react-router-dom', async () => { }; }); -setUserSession(JSON.stringify({ roles: ['Admin'] })); +setUserSession(JSON.stringify({ roles: [{ id: '1', label: 'Admin' }] })); +setOrganizationServices('{"__typename":"OrganizationServicesResult","rolesAndPermission":true}'); describe('', () => { test('should render Flow', async () => { @@ -172,6 +173,26 @@ describe('', () => { fireEvent.click(exportButton[0]); }); }); + + test('should create from scratch ', async () => { + render(flowList); + + await waitFor(() => { + expect(screen.getByText('Flows')).toBeInTheDocument(); + }); + + fireEvent.click(screen.getByTestId('newItemButton')); + + await waitFor(() => { + expect(screen.getByText('Create flow')).toBeInTheDocument(); + }); + + fireEvent.click(screen.getByTestId('middle-button')); + + await waitFor(() => { + expect(mockedUsedNavigate).toHaveBeenCalled(); + }); + }); }); describe('Template flows', () => { @@ -225,4 +246,30 @@ describe('Template flows', () => { expect(mockedUsedNavigate).toHaveBeenCalled(); }); }); + + test('click on Use it for templates', async () => { + render(flowList); + + await waitFor(() => { + expect(screen.getByText('Flows')).toBeInTheDocument(); + }); + + fireEvent.click(screen.getByTestId('newItemButton')); + + await waitFor(() => { + expect(screen.getByText('Create flow')).toBeInTheDocument(); + }); + + fireEvent.click(screen.getByTestId('ok-button')); + + await waitFor(() => { + expect(screen.getByText('Template Flows')).toBeInTheDocument(); + }); + + fireEvent.click(screen.getAllByTestId('copyTemplate')[0]); + + await waitFor(() => { + expect(mockedUsedNavigate).toHaveBeenCalled(); + }); + }); }); diff --git a/src/containers/Flow/FlowList/FlowList.tsx b/src/containers/Flow/FlowList/FlowList.tsx index ada308699..e1aa59562 100644 --- a/src/containers/Flow/FlowList/FlowList.tsx +++ b/src/containers/Flow/FlowList/FlowList.tsx @@ -172,7 +172,7 @@ export const FlowList = () => { }, { label: 'Use it', - icon: , + icon: , parameter: 'id', insideMore: false, dialog: (id: any) => { diff --git a/src/containers/StaffManagement/StaffManagement.test.helper.tsx b/src/containers/StaffManagement/StaffManagement.test.helper.tsx index 6b17463b2..a6693a16c 100644 --- a/src/containers/StaffManagement/StaffManagement.test.helper.tsx +++ b/src/containers/StaffManagement/StaffManagement.test.helper.tsx @@ -382,7 +382,7 @@ const createUserMockData = new Array(5).fill(null).map((val, idx) => { return { id: `${index}`, name: `NGO Main Account${index}`, - phone: `91987654321${index}`, + phone: `9198765432${index}`, accessRoles: [{ label: roles[idx] }], groups: [], contact: { diff --git a/src/containers/StaffManagement/StaffManagementList/StaffManagementList.test.tsx b/src/containers/StaffManagement/StaffManagementList/StaffManagementList.test.tsx index 0d2ead301..1fa0be9f2 100644 --- a/src/containers/StaffManagement/StaffManagementList/StaffManagementList.test.tsx +++ b/src/containers/StaffManagement/StaffManagementList/StaffManagementList.test.tsx @@ -24,7 +24,9 @@ const staffManagement = ( ); test('StaffManagementList is rendered correctly', async () => { - setUserSession(JSON.stringify({ organization: { id: '1' }, roles: ['Manager'] })); + setUserSession( + JSON.stringify({ organization: { id: '1' }, roles: [{ id: '1', label: 'Manager' }] }) + ); render(staffManagement); await waitFor(() => { diff --git a/src/containers/Ticket/TicketList/TicketList.test.tsx b/src/containers/Ticket/TicketList/TicketList.test.tsx index 045da7c84..8097f8b5a 100644 --- a/src/containers/Ticket/TicketList/TicketList.test.tsx +++ b/src/containers/Ticket/TicketList/TicketList.test.tsx @@ -34,6 +34,7 @@ test('should load the ticket list', async () => { expect(getByTestId('loading')).toBeInTheDocument(); await waitFor(() => { expect(getByText('Tickets')).toBeInTheDocument(); + expect(getByText('field name')).toBeInTheDocument(); }); }); diff --git a/src/mocks/Ticket.tsx b/src/mocks/Ticket.tsx index 7ace3f559..0bd697f3f 100644 --- a/src/mocks/Ticket.tsx +++ b/src/mocks/Ticket.tsx @@ -53,7 +53,7 @@ export const ticketListQuery = { contact: { id: '1', name: 'NGO support', - fields: null, + fields: '{}', maskedPhone: '9194*****449', }, id: '1', @@ -73,11 +73,11 @@ export const ticketListQuery = { contact: { id: '2', name: null, - fields: null, + fields: '{"name":{"value":"field name"}}', maskedPhone: '9194*****449', }, id: '2', - messageNumber: 23, + messageNumber: null, insertedAt: '2021-06-16T09:00:00.000Z', remarks: 'This issue is resolved', status: 'open', @@ -88,6 +88,46 @@ export const ticketListQuery = { name: 'Glific user', }, }, + { + body: '', + contact: { + id: '3', + name: null, + fields: '{}', + maskedPhone: '9194*****449', + }, + id: '3', + messageNumber: 23, + insertedAt: '2021-06-16T09:00:00.000Z', + remarks: 'This issue is resolved', + status: 'open', + topic: 'General', + updatedAt: '2021-06-16T09:00:00.000Z', + user: { + id: '1', + name: null, + }, + }, + { + body: '', + contact: { + id: '3', + name: null, + fields: '{}', + maskedPhone: null, + }, + id: '4', + messageNumber: 23, + insertedAt: '2021-06-16T09:00:00.000Z', + remarks: 'This issue is resolved', + status: 'open', + topic: 'General', + updatedAt: '2021-06-16T09:00:00.000Z', + user: { + id: '1', + name: null, + }, + }, ], }, },