diff --git a/package-lock.json b/package-lock.json index 5ba3800d20..572ad17190 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,7 +81,7 @@ "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", - "@testing-library/user-event": "^12.1.10", + "@testing-library/user-event": "^14.5.2", "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", @@ -6046,15 +6046,13 @@ } }, "node_modules/@testing-library/user-event": { - "version": "12.8.3", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.8.3.tgz", - "integrity": "sha512-IR0iWbFkgd56Bu5ZI/ej8yQwrkCv8Qydx6RzwbKz9faXazR/+5tvYKsZQgyXJiwgpcva127YO6JcWy7YlCfofQ==", + "version": "14.5.2", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.5.2.tgz", + "integrity": "sha512-YAh82Wh4TIrxYLmfGcixwD18oIjyC1pFQC2Y01F2lzV2HTMiYrI0nze0FD0ocB//CKS/7jIUgae+adPqxK5yCQ==", "dev": true, - "dependencies": { - "@babel/runtime": "^7.12.5" - }, + "license": "MIT", "engines": { - "node": ">=10", + "node": ">=12", "npm": ">=6" }, "peerDependencies": { diff --git a/package.json b/package.json index b8d97c8d67..86e7159952 100644 --- a/package.json +++ b/package.json @@ -117,10 +117,10 @@ "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.25.7", "@babel/preset-typescript": "^7.26.0", + "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", - "@testing-library/user-event": "^12.1.10", - "@testing-library/dom": "^10.4.0", + "@testing-library/user-event": "^14.5.2", "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", diff --git a/src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx b/src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx index bbddef4fc7..5851739474 100644 --- a/src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx +++ b/src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx @@ -120,13 +120,16 @@ describe('Testing AddOnRegister', () => { ); // Simulate user interactions - userEvent.click(screen.getByRole('button', { name: /Add New/i })); - userEvent.type(screen.getByPlaceholderText(/Ex: Donations/i), 'myplugin'); - userEvent.type( + await userEvent.click(screen.getByRole('button', { name: /Add New/i })); + await userEvent.type( + screen.getByPlaceholderText(/Ex: Donations/i), + 'myplugin', + ); + await userEvent.type( screen.getByPlaceholderText(/This Plugin enables UI for/i), 'test description', ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Ex: john Doe/i), 'test creator', ); @@ -148,16 +151,22 @@ describe('Testing AddOnRegister', () => { }); await waitFor(() => new Promise((resolve) => setTimeout(resolve, 0))); - userEvent.click(screen.getByRole('button', { name: /Add New/i })); + await userEvent.click(screen.getByRole('button', { name: /Add New/i })); await wait(100); expect(screen.getByTestId('addonregisterBtn')).toBeInTheDocument(); - userEvent.type(screen.getByTestId('pluginName'), pluginData.pluginName); - userEvent.type( + await userEvent.type( + screen.getByTestId('pluginName'), + pluginData.pluginName, + ); + await userEvent.type( screen.getByTestId('pluginCreatedBy'), pluginData.pluginCreatedBy, ); - userEvent.type(screen.getByTestId('pluginDesc'), pluginData.pluginDesc); - userEvent.click(screen.getByTestId('addonregisterBtn')); + await userEvent.type( + screen.getByTestId('pluginDesc'), + pluginData.pluginDesc, + ); + await userEvent.click(screen.getByTestId('addonregisterBtn')); await wait(100); expect(toast.success).toHaveBeenCalledWith('Plugin added Successfully'); @@ -179,16 +188,22 @@ describe('Testing AddOnRegister', () => { }); await waitFor(() => new Promise((resolve) => setTimeout(resolve, 0))); - userEvent.click(screen.getByRole('button', { name: /Add New/i })); + await userEvent.click(screen.getByRole('button', { name: /Add New/i })); await wait(100); expect(screen.getByTestId('addonregisterBtn')).toBeInTheDocument(); - userEvent.type(screen.getByTestId('pluginName'), pluginData.pluginName); - userEvent.type( + await userEvent.type( + screen.getByTestId('pluginName'), + pluginData.pluginName, + ); + await userEvent.type( screen.getByTestId('pluginCreatedBy'), pluginData.pluginCreatedBy, ); - userEvent.type(screen.getByTestId('pluginDesc'), pluginData.pluginDesc); - userEvent.click(screen.getByTestId('addonregisterBtn')); + await userEvent.type( + screen.getByTestId('pluginDesc'), + pluginData.pluginDesc, + ); + await userEvent.click(screen.getByTestId('addonregisterBtn')); await wait(3000); // Waiting for 3 seconds to reload the page as timeout is set to 2 seconds in the component expect(mockNavigate).toHaveBeenCalledWith(0); diff --git a/src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx b/src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx index b357309893..2815deca17 100644 --- a/src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx +++ b/src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx @@ -247,10 +247,10 @@ describe('Testing AddOnStore Component', () => { ); await wait(); - userEvent.click(screen.getByText('Installed')); + await userEvent.click(screen.getByText('Installed')); await wait(); - userEvent.click(screen.getByText('Available')); + await userEvent.click(screen.getByText('Available')); }); test('check the working search bar when on Available tab', async () => { @@ -271,7 +271,7 @@ describe('Testing AddOnStore Component', () => { ); await wait(); - userEvent.click(screen.getByText('Available')); + await userEvent.click(screen.getByText('Available')); await wait(); let searchText = ''; diff --git a/src/components/AddPeopleToTag/AddPeopleToTag.spec.tsx b/src/components/AddPeopleToTag/AddPeopleToTag.spec.tsx index 8867335017..8e2a263de7 100644 --- a/src/components/AddPeopleToTag/AddPeopleToTag.spec.tsx +++ b/src/components/AddPeopleToTag/AddPeopleToTag.spec.tsx @@ -161,24 +161,24 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('selectMemberBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('selectMemberBtn')[0]); + await userEvent.click(screen.getAllByTestId('selectMemberBtn')[0]); await waitFor(() => { expect(screen.getAllByTestId('selectMemberBtn')[1]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('selectMemberBtn')[1]); + await userEvent.click(screen.getAllByTestId('selectMemberBtn')[1]); await waitFor(() => { expect( screen.getAllByTestId('clearSelectedMember')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('clearSelectedMember')[0]); + await userEvent.click(screen.getAllByTestId('clearSelectedMember')[0]); await waitFor(() => { expect(screen.getAllByTestId('deselectMemberBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('deselectMemberBtn')[0]); + await userEvent.click(screen.getAllByTestId('deselectMemberBtn')[0]); }); it('searchs for tags where the firstName matches the provided firstName search input', async () => { @@ -284,7 +284,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('assignPeopleBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('assignPeopleBtn')); + await userEvent.click(screen.getByTestId('assignPeopleBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith(translations.noOneSelected); @@ -300,19 +300,19 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('selectMemberBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('selectMemberBtn')[0]); + await userEvent.click(screen.getAllByTestId('selectMemberBtn')[0]); await waitFor(() => { expect(screen.getAllByTestId('selectMemberBtn')[1]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('selectMemberBtn')[1]); + await userEvent.click(screen.getAllByTestId('selectMemberBtn')[1]); await waitFor(() => { expect(screen.getAllByTestId('selectMemberBtn')[2]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('selectMemberBtn')[2]); + await userEvent.click(screen.getAllByTestId('selectMemberBtn')[2]); - userEvent.click(screen.getByTestId('assignPeopleBtn')); + await userEvent.click(screen.getByTestId('assignPeopleBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( diff --git a/src/components/Advertisements/Advertisements.spec.tsx b/src/components/Advertisements/Advertisements.spec.tsx index 1e2d92b392..fcd649a92f 100644 --- a/src/components/Advertisements/Advertisements.spec.tsx +++ b/src/components/Advertisements/Advertisements.spec.tsx @@ -390,8 +390,8 @@ describe('Testing Advertisement Component', () => { await wait(); - userEvent.click(screen.getByText('Create Advertisement')); - userEvent.type( + await userEvent.click(screen.getByText('Create Advertisement')); + await userEvent.type( screen.getByLabelText('Enter name of Advertisement'), 'Cookie Shop', ); @@ -407,14 +407,20 @@ describe('Testing Advertisement Component', () => { }); const mediaPreview = await screen.findByTestId('mediaPreview'); expect(mediaPreview).toBeInTheDocument(); - userEvent.selectOptions( + await userEvent.selectOptions( screen.getByLabelText('Select type of Advertisement'), 'POPUP', ); - userEvent.type(screen.getByLabelText('Select Start Date'), '2023-01-01'); - userEvent.type(screen.getByLabelText('Select End Date'), '2023-02-02'); + await userEvent.type( + screen.getByLabelText('Select Start Date'), + '2023-01-01', + ); + await userEvent.type( + screen.getByLabelText('Select End Date'), + '2023-02-02', + ); - userEvent.click(screen.getByTestId('addonregister')); + await userEvent.click(screen.getByTestId('addonregister')); expect( await screen.findByText('Advertisement created successfully.'), ).toBeInTheDocument(); @@ -443,10 +449,10 @@ describe('Testing Advertisement Component', () => { ); await wait(); - userEvent.click(screen.getByText('Active Campaigns')); + await userEvent.click(screen.getByText('Active Campaigns')); await wait(); - userEvent.click(screen.getByText('Completed Campaigns')); + await userEvent.click(screen.getByText('Completed Campaigns')); }); test('if the component renders correctly and ads are correctly categorized date wise', async () => { diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx index 80ef45226f..350015c449 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx @@ -580,7 +580,7 @@ describe('Testing Advertisement Register Component', () => { type: 'video/mp4', }); const mediaInput = screen.getByTestId('advertisementMedia'); - userEvent.upload(mediaInput, mediaFile); + await userEvent.upload(mediaInput, mediaFile); const mediaPreview = await screen.findByTestId('mediaPreview'); expect(mediaPreview).toBeInTheDocument(); @@ -637,7 +637,7 @@ describe('Testing Advertisement Register Component', () => { type: 'video/mp4', }); const mediaInput = screen.getByTestId('advertisementMedia'); - userEvent.upload(mediaInput, mediaFile); + await userEvent.upload(mediaInput, mediaFile); const mediaPreview = await screen.findByTestId('mediaPreview'); expect(mediaPreview).toBeInTheDocument(); diff --git a/src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx b/src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx index 74880558b4..e1577d6d69 100644 --- a/src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx +++ b/src/components/AgendaCategory/AgendaCategoryContainer.spec.tsx @@ -116,14 +116,18 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('editAgendCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('editAgendCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('editAgendCategoryModalBtn')[0], + ); await waitFor(() => { return expect( screen.findByTestId('updateAgendaCategoryModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateAgendaCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('updateAgendaCategoryModalCloseBtn'), + ); await waitForElementToBeRemoved(() => screen.queryByTestId('updateAgendaCategoryModalCloseBtn'), @@ -150,14 +154,18 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], + ); await waitFor(() => { return expect( screen.findByTestId('previewAgendaCategoryModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('previewAgendaCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('previewAgendaCategoryModalCloseBtn'), + ); await waitForElementToBeRemoved(() => screen.queryByTestId('previewAgendaCategoryModalCloseBtn'), @@ -184,7 +192,9 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], + ); await waitFor(() => { return expect( @@ -197,14 +207,14 @@ describe('Testing Agenda Category Component', () => { screen.getByTestId('deleteAgendaCategoryModalBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaCategoryModalBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaCategoryModalBtn')); await waitFor(() => { return expect( screen.findByTestId('deleteAgendaCategoryCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaCategoryCloseBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaCategoryCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('deleteAgendaCategoryCloseBtn'), @@ -215,14 +225,18 @@ describe('Testing Agenda Category Component', () => { screen.getByTestId('editAgendaCategoryPreviewModalBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('editAgendaCategoryPreviewModalBtn')); + await userEvent.click( + screen.getByTestId('editAgendaCategoryPreviewModalBtn'), + ); await waitFor(() => { return expect( screen.findByTestId('updateAgendaCategoryModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateAgendaCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('updateAgendaCategoryModalCloseBtn'), + ); await waitForElementToBeRemoved(() => screen.queryByTestId('updateAgendaCategoryModalCloseBtn'), @@ -251,21 +265,23 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('editAgendCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('editAgendCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('editAgendCategoryModalBtn')[0], + ); const name = screen.getByPlaceholderText(translations.name); const description = screen.getByPlaceholderText(translations.description); fireEvent.change(name, { target: { value: '' } }); - userEvent.type(name, formData.name); + await userEvent.type(name, formData.name); fireEvent.change(description, { target: { value: '' } }); - userEvent.type(description, formData.description); + await userEvent.type(description, formData.description); await waitFor(() => { expect(screen.getByTestId('editAgendaCategoryBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('editAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('editAgendaCategoryBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -296,7 +312,9 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('editAgendCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('editAgendCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('editAgendCategoryModalBtn')[0], + ); const nameInput = screen.getByLabelText(translations.name); const descriptionInput = screen.getByLabelText(translations.description); @@ -304,13 +322,13 @@ describe('Testing Agenda Category Component', () => { fireEvent.change(descriptionInput, { target: { value: '' }, }); - userEvent.type(nameInput, formData.name); - userEvent.type(descriptionInput, formData.description); + await userEvent.type(nameInput, formData.name); + await userEvent.type(descriptionInput, formData.description); await waitFor(() => { expect(screen.getByTestId('editAgendaCategoryBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('editAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('editAgendaCategoryBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -339,7 +357,9 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], + ); await waitFor(() => { return expect( @@ -352,7 +372,7 @@ describe('Testing Agenda Category Component', () => { screen.getByTestId('deleteAgendaCategoryModalBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaCategoryModalBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaCategoryModalBtn')); await waitFor(() => { return expect( @@ -360,7 +380,7 @@ describe('Testing Agenda Category Component', () => { ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaCategoryBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -389,7 +409,9 @@ describe('Testing Agenda Category Component', () => { screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaCategoryModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaCategoryModalBtn')[0], + ); await waitFor(() => { return expect( @@ -402,14 +424,14 @@ describe('Testing Agenda Category Component', () => { screen.getByTestId('deleteAgendaCategoryModalBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaCategoryModalBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaCategoryModalBtn')); await waitFor(() => { return expect( screen.findByTestId('deleteAgendaCategoryCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaCategoryBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/components/AgendaItems/AgendaItemsContainer.spec.tsx b/src/components/AgendaItems/AgendaItemsContainer.spec.tsx index f8f6ab948d..994355a3c8 100644 --- a/src/components/AgendaItems/AgendaItemsContainer.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsContainer.spec.tsx @@ -122,14 +122,14 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('editAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('editAgendaItemModalBtn')[0]); + await userEvent.click(screen.getAllByTestId('editAgendaItemModalBtn')[0]); await waitFor(() => { return expect( screen.findByTestId('updateAgendaItemModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateAgendaItemModalCloseBtn')); + await userEvent.click(screen.getByTestId('updateAgendaItemModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('updateAgendaItemModalCloseBtn'), @@ -156,14 +156,16 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('previewAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaItemModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaItemModalBtn')[0], + ); await waitFor(() => { return expect( screen.findByTestId('previewAgendaItemModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('previewAgendaItemModalCloseBtn')); + await userEvent.click(screen.getByTestId('previewAgendaItemModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('previewAgendaItemModalCloseBtn'), @@ -190,7 +192,9 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('previewAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaItemModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaItemModalBtn')[0], + ); await waitFor(() => { return expect( @@ -203,14 +207,16 @@ describe('Testing Agenda Items components', () => { screen.getByTestId('previewAgendaItemModalDeleteBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('previewAgendaItemModalDeleteBtn')); + await userEvent.click( + screen.getByTestId('previewAgendaItemModalDeleteBtn'), + ); await waitFor(() => { return expect( screen.findByTestId('deleteAgendaItemCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaItemCloseBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaItemCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('deleteAgendaItemCloseBtn'), @@ -221,14 +227,16 @@ describe('Testing Agenda Items components', () => { screen.getByTestId('previewAgendaItemModalUpdateBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('previewAgendaItemModalUpdateBtn')); + await userEvent.click( + screen.getByTestId('previewAgendaItemModalUpdateBtn'), + ); await waitFor(() => { return expect( screen.findByTestId('updateAgendaItemModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateAgendaItemModalCloseBtn')); + await userEvent.click(screen.getByTestId('updateAgendaItemModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('updateAgendaItemModalCloseBtn'), @@ -257,7 +265,7 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('editAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('editAgendaItemModalBtn')[0]); + await userEvent.click(screen.getAllByTestId('editAgendaItemModalBtn')[0]); const title = screen.getByPlaceholderText(translations.enterTitle); const description = screen.getByPlaceholderText( @@ -265,15 +273,15 @@ describe('Testing Agenda Items components', () => { ); fireEvent.change(title, { target: { value: '' } }); - userEvent.type(title, formData.title); + await userEvent.type(title, formData.title); fireEvent.change(description, { target: { value: '' } }); - userEvent.type(description, formData.description); + await userEvent.type(description, formData.description); await waitFor(() => { expect(screen.getByTestId('updateAgendaItemBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateAgendaItemBtn')); + await userEvent.click(screen.getByTestId('updateAgendaItemBtn')); await waitFor(() => { // expect(toast.success).toBeCalledWith(translations.agendaItemUpdated); @@ -302,7 +310,7 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('editAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('editAgendaItemModalBtn')[0]); + await userEvent.click(screen.getAllByTestId('editAgendaItemModalBtn')[0]); const titleInput = screen.getByLabelText(translations.title); const descriptionInput = screen.getByLabelText(translations.description); @@ -310,13 +318,13 @@ describe('Testing Agenda Items components', () => { fireEvent.change(descriptionInput, { target: { value: '' }, }); - userEvent.type(titleInput, formData.title); - userEvent.type(descriptionInput, formData.description); + await userEvent.type(titleInput, formData.title); + await userEvent.type(descriptionInput, formData.description); await waitFor(() => { expect(screen.getByTestId('updateAgendaItemBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateAgendaItemBtn')); + await userEvent.click(screen.getByTestId('updateAgendaItemBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -345,7 +353,9 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('previewAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaItemModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaItemModalBtn')[0], + ); await waitFor(() => { return expect( @@ -358,7 +368,9 @@ describe('Testing Agenda Items components', () => { screen.getByTestId('previewAgendaItemModalDeleteBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('previewAgendaItemModalDeleteBtn')); + await userEvent.click( + screen.getByTestId('previewAgendaItemModalDeleteBtn'), + ); await waitFor(() => { return expect( @@ -366,7 +378,7 @@ describe('Testing Agenda Items components', () => { ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaItemBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaItemBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -395,7 +407,9 @@ describe('Testing Agenda Items components', () => { screen.getAllByTestId('previewAgendaItemModalBtn')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('previewAgendaItemModalBtn')[0]); + await userEvent.click( + screen.getAllByTestId('previewAgendaItemModalBtn')[0], + ); await waitFor(() => { return expect( @@ -408,14 +422,16 @@ describe('Testing Agenda Items components', () => { screen.getByTestId('previewAgendaItemModalDeleteBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('previewAgendaItemModalDeleteBtn')); + await userEvent.click( + screen.getByTestId('previewAgendaItemModalDeleteBtn'), + ); await waitFor(() => { return expect( screen.findByTestId('deleteAgendaItemCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteAgendaItemBtn')); + await userEvent.click(screen.getByTestId('deleteAgendaItemBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx b/src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx index cbaa628339..071921889e 100644 --- a/src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx +++ b/src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx @@ -72,7 +72,7 @@ describe('Testing Change Language Dropdown', () => { getByTestId('language-dropdown-btn').className.includes(''); getByTestId('dropdown-btn-0').className.includes(''); - userEvent.click(getByTestId('dropdown-btn-0')); + await userEvent.click(getByTestId('dropdown-btn-0')); await wait(); languages.map((language) => { @@ -137,23 +137,23 @@ describe('Testing Change Language Dropdown', () => { , ); - userEvent.click(getByTestId('language-dropdown-btn')); + await userEvent.click(getByTestId('language-dropdown-btn')); await wait(); const changeLanguageBtn = getByTestId(`change-language-btn-fr`); await wait(); expect(changeLanguageBtn).toBeInTheDocument(); await wait(); - userEvent.click(changeLanguageBtn); + await userEvent.click(changeLanguageBtn); await wait(); expect(cookies.get('i18next')).toBe('fr'); await wait(); - userEvent.click(getByTestId('language-dropdown-btn')); + await userEvent.click(getByTestId('language-dropdown-btn')); await wait(); const changeLanguageBtnHi = getByTestId(`change-language-btn-hi`); await wait(); expect(changeLanguageBtnHi).toBeInTheDocument(); await wait(); - userEvent.click(changeLanguageBtnHi); + await userEvent.click(changeLanguageBtnHi); await wait(); }); }); diff --git a/src/components/DynamicDropDown/DynamicDropDown.spec.tsx b/src/components/DynamicDropDown/DynamicDropDown.spec.tsx index 85c3208a20..5e5ae0da4d 100644 --- a/src/components/DynamicDropDown/DynamicDropDown.spec.tsx +++ b/src/components/DynamicDropDown/DynamicDropDown.spec.tsx @@ -43,14 +43,12 @@ describe('DynamicDropDown component', () => { expect(dropdownButton).toHaveTextContent('Label 2'); // Open the dropdown menu - await act(async () => { - userEvent.click(dropdownButton); - }); + await userEvent.click(dropdownButton); // Select the first option in the dropdown const optionElement = screen.getByTestId('change-fieldname-btn-TEST'); await act(async () => { - userEvent.click(optionElement); + await userEvent.click(optionElement); }); // Verify that the setFormData function was called with the correct arguments @@ -85,12 +83,12 @@ describe('DynamicDropDown component', () => { const dropdownButton = screen.getByTestId('fieldname-dropdown-btn'); await act(async () => { - userEvent.click(dropdownButton); + await userEvent.click(dropdownButton); }); const optionElement = screen.getByTestId('change-fieldname-btn-value2'); await act(async () => { - userEvent.click(optionElement); + await userEvent.click(optionElement); }); expect(customHandleChange).toHaveBeenCalledTimes(1); @@ -127,7 +125,7 @@ describe('DynamicDropDown component', () => { // Open dropdown const dropdownButton = screen.getByTestId('fieldname-dropdown-btn'); await act(async () => { - userEvent.click(dropdownButton); + await userEvent.click(dropdownButton); }); // Get dropdown menu diff --git a/src/components/EditCustomFieldDropDown/EditCustomFieldDropDown.spec.tsx b/src/components/EditCustomFieldDropDown/EditCustomFieldDropDown.spec.tsx index 4119800dd1..39e6c1c9f5 100644 --- a/src/components/EditCustomFieldDropDown/EditCustomFieldDropDown.spec.tsx +++ b/src/components/EditCustomFieldDropDown/EditCustomFieldDropDown.spec.tsx @@ -49,16 +49,13 @@ describe('Testing Custom Field Dropdown', () => { expect(getByText('Number')).toBeInTheDocument(); - act(() => { - userEvent.click(getByTestId('toggleBtn')); + act(async () => { + await userEvent.click(getByTestId('toggleBtn')); }); await wait(); - - availableFieldTypes.forEach(async (_, index) => { - act(() => { - userEvent.click(getByTestId(`dropdown-btn-${index}`)); - }); - }); + for (const [index] of availableFieldTypes.entries()) { + await userEvent.click(getByTestId(`dropdown-btn-${index}`)); + } }); }); diff --git a/src/components/EventListCard/EventListCard.spec.tsx b/src/components/EventListCard/EventListCard.spec.tsx index e0c6cc825f..bef21956f1 100644 --- a/src/components/EventListCard/EventListCard.spec.tsx +++ b/src/components/EventListCard/EventListCard.spec.tsx @@ -115,12 +115,12 @@ describe('Testing Event List Card', () => { it('Testing for event modal', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('eventModalCloseBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -176,7 +176,7 @@ describe('Testing Event List Card', () => { expect(screen.getByText(props[1].eventName)).toBeInTheDocument(); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('updateDescription')).toBeInTheDocument(); @@ -189,7 +189,7 @@ describe('Testing Event List Card', () => { props[1].eventLocation, ); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -202,7 +202,7 @@ describe('Testing Event List Card', () => { const longEventName = 'a'.repeat(101); renderEventListCard({ ...props[1], eventName: longEventName }); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('updateTitle')).toBeInTheDocument(); @@ -212,7 +212,7 @@ describe('Testing Event List Card', () => { `${longEventName.substring(0, 100)}...`, ); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -225,7 +225,7 @@ describe('Testing Event List Card', () => { const shortEventName = 'a'.repeat(100); renderEventListCard({ ...props[1], eventName: shortEventName }); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('updateTitle')).toBeInTheDocument(); @@ -233,7 +233,7 @@ describe('Testing Event List Card', () => { expect(screen.getByTestId('updateTitle')).toHaveValue(shortEventName); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -250,7 +250,7 @@ describe('Testing Event List Card', () => { eventDescription: longEventDescription, }); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('updateDescription')).toBeInTheDocument(); @@ -259,7 +259,7 @@ describe('Testing Event List Card', () => { `${longEventDescription.substring(0, 256)}...`, ); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -276,7 +276,7 @@ describe('Testing Event List Card', () => { eventDescription: shortEventDescription, }); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('updateDescription')).toBeInTheDocument(); @@ -285,7 +285,7 @@ describe('Testing Event List Card', () => { shortEventDescription, ); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -297,13 +297,13 @@ describe('Testing Event List Card', () => { it('Should navigate to event dashboard when clicked (For Admin)', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('showEventDashboardBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('showEventDashboardBtn')); + await userEvent.click(screen.getByTestId('showEventDashboardBtn')); await waitFor(() => { expect(screen.queryByTestId('card')).not.toBeInTheDocument(); @@ -315,13 +315,13 @@ describe('Testing Event List Card', () => { setItem('userId', '123'); renderEventListCard(props[2]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('showEventDashboardBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('showEventDashboardBtn')); + await userEvent.click(screen.getByTestId('showEventDashboardBtn')); await waitFor(() => { expect(screen.queryByTestId('card')).not.toBeInTheDocument(); @@ -332,19 +332,19 @@ describe('Testing Event List Card', () => { it('Should update a non-recurring event', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); const eventTitle = screen.getByTestId('updateTitle'); fireEvent.change(eventTitle, { target: { value: '' } }); - userEvent.type(eventTitle, updateData.title); + await userEvent.type(eventTitle, updateData.title); const eventDescription = screen.getByTestId('updateDescription'); fireEvent.change(eventDescription, { target: { value: '' } }); - userEvent.type(eventDescription, updateData.description); + await userEvent.type(eventDescription, updateData.description); const eventLocation = screen.getByTestId('updateLocation'); fireEvent.change(eventLocation, { target: { value: '' } }); - userEvent.type(eventLocation, updateData.location); + await userEvent.type(eventLocation, updateData.location); const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { @@ -356,10 +356,10 @@ describe('Testing Event List Card', () => { target: { value: updateData.endDate }, }); - userEvent.click(screen.getByTestId('updateAllDay')); - userEvent.click(screen.getByTestId('updateIsPublic')); - userEvent.click(screen.getByTestId('updateRegistrable')); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateAllDay')); + await userEvent.click(screen.getByTestId('updateIsPublic')); + await userEvent.click(screen.getByTestId('updateRegistrable')); + await userEvent.click(screen.getByTestId('updateEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventUpdated); @@ -375,19 +375,19 @@ describe('Testing Event List Card', () => { it('Should update a non all day non-recurring event', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); const eventTitle = screen.getByTestId('updateTitle'); fireEvent.change(eventTitle, { target: { value: '' } }); - userEvent.type(eventTitle, updateData.title); + await userEvent.type(eventTitle, updateData.title); const eventDescription = screen.getByTestId('updateDescription'); fireEvent.change(eventDescription, { target: { value: '' } }); - userEvent.type(eventDescription, updateData.description); + await userEvent.type(eventDescription, updateData.description); const eventLocation = screen.getByTestId('updateLocation'); fireEvent.change(eventLocation, { target: { value: '' } }); - userEvent.type(eventLocation, updateData.location); + await userEvent.type(eventLocation, updateData.location); const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { @@ -409,10 +409,10 @@ describe('Testing Event List Card', () => { target: { value: updateData.endTime }, }); - userEvent.click(screen.getByTestId('updateIsPublic')); - userEvent.click(screen.getByTestId('updateRegistrable')); + await userEvent.click(screen.getByTestId('updateIsPublic')); + await userEvent.click(screen.getByTestId('updateRegistrable')); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventUpdated); @@ -428,19 +428,19 @@ describe('Testing Event List Card', () => { it('should update a single event to be recurring', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); const eventTitle = screen.getByTestId('updateTitle'); fireEvent.change(eventTitle, { target: { value: '' } }); - userEvent.type(eventTitle, updateData.title); + await userEvent.type(eventTitle, updateData.title); const eventDescription = screen.getByTestId('updateDescription'); fireEvent.change(eventDescription, { target: { value: '' } }); - userEvent.type(eventDescription, updateData.description); + await userEvent.type(eventDescription, updateData.description); const eventLocation = screen.getByTestId('updateLocation'); fireEvent.change(eventLocation, { target: { value: '' } }); - userEvent.type(eventLocation, updateData.location); + await userEvent.type(eventLocation, updateData.location); const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { @@ -452,11 +452,11 @@ describe('Testing Event List Card', () => { target: { value: updateData.endDate }, }); - userEvent.click(screen.getByTestId('updateAllDay')); - userEvent.click(screen.getByTestId('updateRecurring')); - userEvent.click(screen.getByTestId('updateIsPublic')); - userEvent.click(screen.getByTestId('updateRegistrable')); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateAllDay')); + await userEvent.click(screen.getByTestId('updateRecurring')); + await userEvent.click(screen.getByTestId('updateIsPublic')); + await userEvent.click(screen.getByTestId('updateRegistrable')); + await userEvent.click(screen.getByTestId('updateEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventUpdated); @@ -472,12 +472,12 @@ describe('Testing Event List Card', () => { it('should show different update options for a recurring event based on different conditions', async () => { renderEventListCard(props[5]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.queryByTestId('updateEventBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); // shows options to update thisInstance and thisAndFollowingInstances, and allInstances await waitFor(() => { @@ -488,7 +488,9 @@ describe('Testing Event List Card', () => { expect(screen.getByTestId('update-allInstances')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventUpdateOptionsModalCloseBtn')); + await userEvent.click( + screen.getByTestId('eventUpdateOptionsModalCloseBtn'), + ); await waitFor(() => { expect(screen.getByLabelText(translations.startDate)).toBeInTheDocument(); @@ -505,7 +507,7 @@ describe('Testing Event List Card', () => { target: { value: updateData.endDate }, }); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); // shows options to update thisInstance and thisAndFollowingInstances only await waitFor(() => { @@ -518,7 +520,9 @@ describe('Testing Event List Card', () => { ).not.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventUpdateOptionsModalCloseBtn')); + await userEvent.click( + screen.getByTestId('eventUpdateOptionsModalCloseBtn'), + ); await waitFor(() => { expect(screen.getByLabelText(translations.startDate)).toBeInTheDocument(); @@ -539,36 +543,38 @@ describe('Testing Event List Card', () => { await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); await waitFor(() => { expect( screen.getByTestId('customRecurrenceFrequencyDropdown'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customDailyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customDailyRecurrence')); + await userEvent.click(screen.getByTestId('customDailyRecurrence')); await waitFor(() => { expect( screen.getByTestId('customRecurrenceSubmitBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect(screen.getByTestId('updateEventBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); // shows options to update thisAndFollowingInstances and allInstances only await waitFor(() => { @@ -581,12 +587,14 @@ describe('Testing Event List Card', () => { expect(screen.queryByTestId('update-allInstances')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventUpdateOptionsModalCloseBtn')); + await userEvent.click( + screen.getByTestId('eventUpdateOptionsModalCloseBtn'), + ); await waitFor(() => { expect(screen.getByTestId('eventModalCloseBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -598,17 +606,17 @@ describe('Testing Event List Card', () => { it('should show recurrenceRule as changed if the recurrence weekdays have changed', async () => { renderEventListCard(props[4]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); // since the current recurrence weekDay for the current recurring event is "SATURDAY", // let's first deselect it, and then we'll select a different day @@ -619,17 +627,17 @@ describe('Testing Event List Card', () => { }); // deselect saturday, which is the 7th day in recurrenceWeekDay options - userEvent.click(screen.getAllByTestId('recurrenceWeekDay')[6]); + await userEvent.click(screen.getAllByTestId('recurrenceWeekDay')[6]); // select a different day, say wednesday, the 4th day in recurrenceWeekDay options - userEvent.click(screen.getAllByTestId('recurrenceWeekDay')[3]); + await userEvent.click(screen.getAllByTestId('recurrenceWeekDay')[3]); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect(screen.getByTestId('updateEventBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); // shows options to update thisInstance and thisAndFollowingInstances, and allInstances await waitFor(() => { @@ -642,12 +650,14 @@ describe('Testing Event List Card', () => { expect(screen.getByTestId('update-allInstances')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventUpdateOptionsModalCloseBtn')); + await userEvent.click( + screen.getByTestId('eventUpdateOptionsModalCloseBtn'), + ); await waitFor(() => { expect(screen.getByTestId('eventModalCloseBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -659,7 +669,7 @@ describe('Testing Event List Card', () => { it('should update all instances of a recurring event', async () => { renderEventListCard(props[6]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('updateTitle')).toBeInTheDocument(); @@ -667,17 +677,17 @@ describe('Testing Event List Card', () => { const eventTitle = screen.getByTestId('updateTitle'); fireEvent.change(eventTitle, { target: { value: '' } }); - userEvent.type(eventTitle, updateData.title); + await userEvent.type(eventTitle, updateData.title); const eventDescription = screen.getByTestId('updateDescription'); fireEvent.change(eventDescription, { target: { value: '' } }); - userEvent.type(eventDescription, updateData.description); + await userEvent.type(eventDescription, updateData.description); const eventLocation = screen.getByTestId('updateLocation'); fireEvent.change(eventLocation, { target: { value: '' } }); - userEvent.type(eventLocation, updateData.location); + await userEvent.type(eventLocation, updateData.location); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); // shows options to update thisInstance and thisAndFollowingInstances, and allInstances await waitFor(() => { @@ -688,8 +698,10 @@ describe('Testing Event List Card', () => { expect(screen.getByTestId('update-allInstances')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('update-allInstances')); - userEvent.click(screen.getByTestId('recurringEventUpdateOptionSubmitBtn')); + await userEvent.click(screen.getByTestId('update-allInstances')); + await userEvent.click( + screen.getByTestId('recurringEventUpdateOptionSubmitBtn'), + ); await waitFor(() => { expect(screen.getByTestId('updateEventBtn')).toBeInTheDocument(); @@ -709,7 +721,7 @@ describe('Testing Event List Card', () => { it('should update thisAndFollowingInstances of a recurring event', async () => { renderEventListCard(props[5]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByLabelText(translations.startDate)).toBeInTheDocument(); @@ -730,36 +742,38 @@ describe('Testing Event List Card', () => { await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); await waitFor(() => { expect( screen.getByTestId('customRecurrenceFrequencyDropdown'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customDailyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customDailyRecurrence')); + await userEvent.click(screen.getByTestId('customDailyRecurrence')); await waitFor(() => { expect( screen.getByTestId('customRecurrenceSubmitBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect(screen.getByTestId('updateEventBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('updateEventBtn')); + await userEvent.click(screen.getByTestId('updateEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventUpdated); @@ -775,19 +789,19 @@ describe('Testing Event List Card', () => { it('should render the delete modal', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('deleteEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteEventModalBtn')); + await userEvent.click(screen.getByTestId('deleteEventModalBtn')); await waitFor(() => { expect( screen.getByTestId('eventDeleteModalCloseBtn'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventDeleteModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventDeleteModalCloseBtn')); await waitFor(() => { expect( @@ -798,7 +812,7 @@ describe('Testing Event List Card', () => { await waitFor(() => { expect(screen.getByTestId('eventModalCloseBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('eventModalCloseBtn')); + await userEvent.click(screen.getByTestId('eventModalCloseBtn')); await waitFor(() => { expect( @@ -810,17 +824,17 @@ describe('Testing Event List Card', () => { it('should call the delete event mutation when the "Yes" button is clicked', async () => { renderEventListCard(props[1]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('deleteEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteEventModalBtn')); + await userEvent.click(screen.getByTestId('deleteEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('deleteEventBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteEventBtn')); + await userEvent.click(screen.getByTestId('deleteEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventDeleted); @@ -842,12 +856,12 @@ describe('Testing Event List Card', () => { expect(screen.getByTestId('card')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('deleteEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('deleteEventModalBtn')); + await userEvent.click(screen.getByTestId('deleteEventModalBtn')); await waitFor(() => { expect( @@ -855,12 +869,14 @@ describe('Testing Event List Card', () => { ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('delete-thisAndFollowingInstances')); + await userEvent.click( + screen.getByTestId('delete-thisAndFollowingInstances'), + ); - userEvent.click(screen.getByTestId('delete-allInstances')); - userEvent.click(screen.getByTestId('delete-thisInstance')); + await userEvent.click(screen.getByTestId('delete-allInstances')); + await userEvent.click(screen.getByTestId('delete-thisInstance')); - userEvent.click(screen.getByTestId('deleteEventBtn')); + await userEvent.click(screen.getByTestId('deleteEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventDeleted); @@ -899,9 +915,9 @@ describe('Testing Event List Card', () => { , ); - userEvent.click(screen.getByTestId('card')); - userEvent.click(screen.getByTestId('deleteEventModalBtn')); - userEvent.click(screen.getByTestId('deleteEventBtn')); + await userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('deleteEventModalBtn')); + await userEvent.click(screen.getByTestId('deleteEventBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -913,12 +929,12 @@ describe('Testing Event List Card', () => { renderEventListCard(props[2]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); await waitFor(() => { expect(screen.getByTestId('registerEventBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('registerEventBtn')); + await userEvent.click(screen.getByTestId('registerEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -936,7 +952,7 @@ describe('Testing Event List Card', () => { it('should show already registered text when the user is registered for an event', async () => { renderEventListCard(props[3]); - userEvent.click(screen.getByTestId('card')); + await userEvent.click(screen.getByTestId('card')); expect( screen.getByText(translations.alreadyRegistered), diff --git a/src/components/EventManagement/EventAgendaItems/EventAgendaItems.spec.tsx b/src/components/EventManagement/EventAgendaItems/EventAgendaItems.spec.tsx index c41ec4ae2e..855898941d 100644 --- a/src/components/EventManagement/EventAgendaItems/EventAgendaItems.spec.tsx +++ b/src/components/EventManagement/EventAgendaItems/EventAgendaItems.spec.tsx @@ -138,14 +138,14 @@ describe('Testing Agenda Items Components', () => { await waitFor(() => { expect(screen.getByTestId('createAgendaItemBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaItemBtn')); + await userEvent.click(screen.getByTestId('createAgendaItemBtn')); await waitFor(() => { return expect( screen.findByTestId('createAgendaItemModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaItemModalCloseBtn')); + await userEvent.click(screen.getByTestId('createAgendaItemModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('createAgendaItemModalCloseBtn'), @@ -172,7 +172,7 @@ describe('Testing Agenda Items Components', () => { await waitFor(() => { expect(screen.getByTestId('createAgendaItemBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaItemBtn')); + await userEvent.click(screen.getByTestId('createAgendaItemBtn')); await waitFor(() => { expect( @@ -180,27 +180,27 @@ describe('Testing Agenda Items Components', () => { ).toBeInTheDocument(); }); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.enterTitle), formData.title, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.enterDescription), formData.description, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.enterDuration), formData.duration, ); const categorySelect = screen.getByTestId('categorySelect'); - userEvent.click(categorySelect); - await waitFor(() => { + await userEvent.click(categorySelect); + await waitFor(async () => { const categoryOption = screen.getByText('Category 1'); - userEvent.click(categoryOption); + await userEvent.click(categoryOption); }); - userEvent.click(screen.getByTestId('createAgendaItemFormBtn')); + await userEvent.click(screen.getByTestId('createAgendaItemFormBtn')); await waitFor(() => { // expect(toast.success).toBeCalledWith(translations.agendaItemCreated); diff --git a/src/components/EventManagement/EventAttendance/EventAttendance.spec.tsx b/src/components/EventManagement/EventAttendance/EventAttendance.spec.tsx index 7dc767e232..ad79932bcb 100644 --- a/src/components/EventManagement/EventAttendance/EventAttendance.spec.tsx +++ b/src/components/EventManagement/EventAttendance/EventAttendance.spec.tsx @@ -103,10 +103,10 @@ describe('Event Attendance Component', () => { await wait(); const sortDropdown = screen.getByTestId('sort-dropdown'); - userEvent.click(sortDropdown); // Open the sort dropdown + await userEvent.click(sortDropdown); // Open the sort dropdown const sortOption = screen.getByText('Ascending'); // Assuming 'Ascending' is the option you choose for sorting - userEvent.click(sortOption); + await userEvent.click(sortOption); await waitFor(() => { const attendees = screen.getAllByTestId('attendee-name-0'); @@ -121,10 +121,10 @@ describe('Event Attendance Component', () => { await wait(); const filterDropdown = screen.getByTestId('filter-dropdown'); - userEvent.click(filterDropdown); // Open the filter dropdown + await userEvent.click(filterDropdown); // Open the filter dropdown const filterOption = screen.getByText('This Month'); // Assuming 'This Month' is the option you choose for filtering - userEvent.click(filterOption); + await userEvent.click(filterOption); await waitFor(() => { // Check if the message 'Attendees not Found' is displayed @@ -138,14 +138,14 @@ describe('Event Attendance Component', () => { expect(screen.queryByTestId('attendance-modal')).not.toBeInTheDocument(); const statsButton = screen.getByTestId('stats-modal'); - userEvent.click(statsButton); + await userEvent.click(statsButton); await waitFor(() => { expect(screen.getByTestId('attendance-modal')).toBeInTheDocument(); }); const closeButton = screen.getByTestId('close-button'); - userEvent.click(closeButton); + await userEvent.click(closeButton); await waitFor(() => { expect(screen.queryByTestId('attendance-modal')).not.toBeInTheDocument(); diff --git a/src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx b/src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx index 38379b54fb..e7c54b95d6 100644 --- a/src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx +++ b/src/components/EventManagement/EventAttendance/EventStatistics.spec.tsx @@ -177,15 +177,15 @@ describe('AttendanceStatisticsModal', () => { , ); - await waitFor(() => { + await waitFor(async () => { const genderButton = screen.getByTestId('gender-button'); const ageButton = screen.getByTestId('age-button'); - userEvent.click(ageButton); + await userEvent.click(ageButton); expect(ageButton).toHaveClass('btn-success'); expect(genderButton).toHaveClass('btn-light'); - userEvent.click(genderButton); + await userEvent.click(genderButton); expect(genderButton).toHaveClass('btn-success'); expect(ageButton).toHaveClass('btn-light'); }); @@ -331,12 +331,12 @@ describe('AttendanceStatisticsModal', () => { , ); - await waitFor(() => { + await waitFor(async () => { const nextButton = screen.getByAltText('right-arrow'); const prevButton = screen.getByAltText('left-arrow'); - userEvent.click(nextButton); - userEvent.click(prevButton); + await userEvent.click(nextButton); + await userEvent.click(prevButton); }); }); @@ -354,9 +354,9 @@ describe('AttendanceStatisticsModal', () => { , ); - await waitFor(() => { + await waitFor(async () => { const closeButton = screen.getByTestId('close-button'); - userEvent.click(closeButton); + await userEvent.click(closeButton); expect(handleClose).toHaveBeenCalled(); }); }); diff --git a/src/components/EventRegistrantsModal/AddOnSpotAttendee.spec.tsx b/src/components/EventRegistrantsModal/AddOnSpotAttendee.spec.tsx index a3c207a2e1..1d6e9cebd6 100644 --- a/src/components/EventRegistrantsModal/AddOnSpotAttendee.spec.tsx +++ b/src/components/EventRegistrantsModal/AddOnSpotAttendee.spec.tsx @@ -131,10 +131,10 @@ describe('AddOnSpotAttendee Component', () => { , ); - userEvent.type(screen.getByLabelText('First Name'), 'John'); - userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); - userEvent.type(screen.getByLabelText('Email'), 'john@example.com'); - userEvent.type(screen.getByLabelText('Phone No.'), '1234567890'); + await userEvent.type(screen.getByLabelText('First Name'), 'John'); + await userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); + await userEvent.type(screen.getByLabelText('Email'), 'john@example.com'); + await userEvent.type(screen.getByLabelText('Phone No.'), '1234567890'); const genderSelect = screen.getByLabelText('Gender'); fireEvent.change(genderSelect, { target: { value: 'Male' } }); @@ -162,10 +162,10 @@ describe('AddOnSpotAttendee Component', () => { ); // Fill the form - userEvent.type(screen.getByLabelText('First Name'), 'John'); - userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); - userEvent.type(screen.getByLabelText('Email'), 'john@example.com'); - userEvent.type(screen.getByLabelText('Phone No.'), '1234567890'); + await userEvent.type(screen.getByLabelText('First Name'), 'John'); + await userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); + await userEvent.type(screen.getByLabelText('Email'), 'john@example.com'); + await userEvent.type(screen.getByLabelText('Phone No.'), '1234567890'); const genderSelect = screen.getByLabelText('Gender'); fireEvent.change(genderSelect, { target: { value: 'Male' } }); @@ -183,10 +183,10 @@ describe('AddOnSpotAttendee Component', () => { it('submits form successfully and calls necessary callbacks', async () => { renderAddOnSpotAttendee(); - userEvent.type(screen.getByLabelText('First Name'), 'John'); - userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); - userEvent.type(screen.getByLabelText('Email'), 'john@example.com'); - userEvent.type(screen.getByLabelText('Phone No.'), '1234567890'); + await userEvent.type(screen.getByLabelText('First Name'), 'John'); + await userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); + await userEvent.type(screen.getByLabelText('Email'), 'john@example.com'); + await userEvent.type(screen.getByLabelText('Phone No.'), '1234567890'); const genderSelect = screen.getByLabelText('Gender'); fireEvent.change(genderSelect, { target: { value: 'Male' } }); @@ -236,8 +236,8 @@ describe('AddOnSpotAttendee Component', () => { , ); - userEvent.type(screen.getByLabelText('First Name'), 'John'); - userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); + await userEvent.type(screen.getByLabelText('First Name'), 'John'); + await userEvent.type(screen.getByLabelText('Last Name'), 'Doe'); fireEvent.submit(screen.getByTestId('onspot-attendee-form')); await waitFor(() => { diff --git a/src/components/LeftDrawer/LeftDrawer.spec.tsx b/src/components/LeftDrawer/LeftDrawer.spec.tsx index b73cab654b..3733076510 100644 --- a/src/components/LeftDrawer/LeftDrawer.spec.tsx +++ b/src/components/LeftDrawer/LeftDrawer.spec.tsx @@ -98,13 +98,13 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { expect(communityProfileBtn.className.includes('btn')).toBeTruthy(); await act(async () => { - userEvent.click(rolesBtn); + await userEvent.click(rolesBtn); }); expect(global.window.location.pathname).toContain('/users'); await act(async () => { - userEvent.click(communityProfileBtn); + await userEvent.click(communityProfileBtn); }); }); @@ -201,7 +201,7 @@ describe('Testing Left Drawer component for ADMIN', () => { expect(screen.queryByTestId(/rolesBtn/i)).toBeNull(); await act(async () => { - userEvent.click(orgsBtn); + await userEvent.click(orgsBtn); }); expect(global.window.location.pathname).toContain('/orglist'); diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx index f0e5d446d1..d631e1e376 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx @@ -368,7 +368,7 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => { , ); await wait(); - userEvent.click(screen.getByText('Dashboard')); + await userEvent.click(screen.getByText('Dashboard')); expect(global.window.location.pathname).toContain('/orgdash/123'); }); @@ -391,7 +391,7 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => { expect(screen.getAllByText(/People/i)[0]).toBeInTheDocument(); const peopelBtn = screen.getByTestId(/People/i); - userEvent.click(peopelBtn); + await userEvent.click(peopelBtn); await wait(); expect(window.location.pathname).toContain('/orgpeople/123'); }); diff --git a/src/components/MemberRequestCard/MemberRequestCard.spec.tsx b/src/components/MemberRequestCard/MemberRequestCard.spec.tsx index c4365ec80a..9342ee8cef 100644 --- a/src/components/MemberRequestCard/MemberRequestCard.spec.tsx +++ b/src/components/MemberRequestCard/MemberRequestCard.spec.tsx @@ -164,8 +164,8 @@ describe('Testing Member Request Card', () => { ); await wait(); - userEvent.click(screen.getByText(/Accept/i)); - userEvent.click(screen.getByText(/Reject/i)); + await userEvent.click(screen.getByText(/Accept/i)); + await userEvent.click(screen.getByText(/Reject/i)); expect(screen.getByAltText(/userImage/i)).toBeInTheDocument(); expect(screen.getByText(/Joined:/i)).toBeInTheDocument(); @@ -194,8 +194,8 @@ describe('Testing Member Request Card', () => { ); await wait(); - userEvent.click(screen.getByText(/Accept/i)); - userEvent.click(screen.getByText(/Reject/i)); + await userEvent.click(screen.getByText(/Accept/i)); + await userEvent.click(screen.getByText(/Reject/i)); expect(screen.getByAltText(/userImage/i)).toBeInTheDocument(); expect(screen.getByText(/Joined:/i)).toBeInTheDocument(); diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.spec.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.spec.tsx index 5bea7110aa..dd14f4e813 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.spec.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.spec.tsx @@ -98,7 +98,7 @@ describe('Testing Organization Admin List Card', () => { await wait(); - userEvent.click(screen.getByTestId(/removeAdminBtn/i)); + await userEvent.click(screen.getByTestId(/removeAdminBtn/i)); await wait(2000); }); diff --git a/src/components/OrgPostCard/OrgPostCard.spec.tsx b/src/components/OrgPostCard/OrgPostCard.spec.tsx index 5364766aee..251113f254 100644 --- a/src/components/OrgPostCard/OrgPostCard.spec.tsx +++ b/src/components/OrgPostCard/OrgPostCard.spec.tsx @@ -164,7 +164,7 @@ describe('Testing Organization Post Card', () => { })); global.alert = vi.fn(); - it('Opens post on image click', () => { + it('Opens post on image click', async () => { const { getByTestId, getByAltText } = render( @@ -172,7 +172,7 @@ describe('Testing Organization Post Card', () => { , ); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); expect(getByTestId('card-text')).toBeInTheDocument(); expect(getByTestId('card-title')).toBeInTheDocument(); @@ -190,7 +190,7 @@ describe('Testing Organization Post Card', () => { expect(getByTestId('card-title')).toBeInTheDocument(); expect(getByAltText('image')).toBeInTheDocument(); }); - it('toggles "Read more" button', () => { + it('toggles "Read more" button', async () => { const { getByTestId } = render( @@ -198,7 +198,7 @@ describe('Testing Organization Post Card', () => { , ); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); const toggleButton = getByTestId('toggleBtn'); fireEvent.click(toggleButton); expect(toggleButton).toHaveTextContent('hide'); @@ -216,14 +216,14 @@ describe('Testing Organization Post Card', () => { , ); await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); const createOrgBtn = screen.getByTestId('modalOrganizationHeader'); expect(createOrgBtn).toBeInTheDocument(); - userEvent.click(createOrgBtn); - userEvent.click(screen.getByTestId('closeOrganizationModal')); + await userEvent.click(createOrgBtn); + await userEvent.click(screen.getByTestId('closeOrganizationModal')); }); it('Should render text elements when props value is not passed', async () => { global.confirm = (): boolean => false; @@ -235,7 +235,7 @@ describe('Testing Organization Post Card', () => { , ); await wait(); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); expect(screen.getByAltText('Post Image')).toBeInTheDocument(); }); it('Testing post updating after post is updated', async () => { @@ -249,10 +249,10 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); fireEvent.change(getByTestId('updateTitle'), { target: { value: 'updated title' }, }); @@ -264,7 +264,7 @@ describe('Testing Organization Post Card', () => { fireEvent.change(getByTestId('postVideoUrl'), { target: { value: 'This is a updated video' }, }); - userEvent.click(screen.getByPlaceholderText(/video/i)); + await userEvent.click(screen.getByPlaceholderText(/video/i)); const input = getByTestId('postVideoUrl'); const file = new File(['test-video'], 'test.mp4', { type: 'video/mp4' }); Object.defineProperty(input, 'files', { @@ -275,14 +275,14 @@ describe('Testing Organization Post Card', () => { convertToBase64(file); }); - userEvent.click(screen.getByTestId('closePreview')); + await userEvent.click(screen.getByTestId('closePreview')); } const imageUrlInput = screen.queryByTestId('postImageUrl'); if (imageUrlInput) { fireEvent.change(getByTestId('postImageUrl'), { target: { value: 'This is a updated image' }, }); - userEvent.click(screen.getByPlaceholderText(/image/i)); + await userEvent.click(screen.getByPlaceholderText(/image/i)); const input = getByTestId('postImageUrl'); const file = new File(['test-image'], 'test.jpg', { type: 'image/jpeg' }); Object.defineProperty(input, 'files', { @@ -298,7 +298,7 @@ describe('Testing Organization Post Card', () => { const clearImageButton = getByTestId('closeimage'); fireEvent.click(clearImageButton); } - userEvent.click(screen.getByTestId('updatePostBtn')); + await userEvent.click(screen.getByTestId('updatePostBtn')); await waitFor( () => { @@ -327,10 +327,10 @@ describe('Testing Organization Post Card', () => { ); await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); fireEvent.change(getByTestId('updateTitle'), { target: { value: 'updated title' }, }); @@ -342,7 +342,7 @@ describe('Testing Organization Post Card', () => { fireEvent.change(getByTestId('postVideoUrl'), { target: { value: 'This is a updated video' }, }); - userEvent.click(screen.getByPlaceholderText(/video/i)); + await userEvent.click(screen.getByPlaceholderText(/video/i)); const input = getByTestId('postVideoUrl'); const file = new File(['test-video'], 'test.mp4', { type: 'video/mp4' }); Object.defineProperty(input, 'files', { @@ -353,14 +353,14 @@ describe('Testing Organization Post Card', () => { convertToBase64(file); }); - userEvent.click(screen.getByTestId('closePreview')); + await userEvent.click(screen.getByTestId('closePreview')); } const imageUrlInput = screen.queryByTestId('postImageUrl'); if (imageUrlInput) { fireEvent.change(getByTestId('postImageUrl'), { target: { value: 'This is a updated image' }, }); - userEvent.click(screen.getByPlaceholderText(/image/i)); + await userEvent.click(screen.getByPlaceholderText(/image/i)); const input = getByTestId('postImageUrl'); const file = new File(['test-image'], 'test.jpg', { type: 'image/jpeg' }); Object.defineProperty(input, 'files', { @@ -376,7 +376,7 @@ describe('Testing Organization Post Card', () => { const clearImageButton = getByTestId('closeimage'); fireEvent.click(clearImageButton); } - userEvent.click(screen.getByTestId('updatePostBtn')); + await userEvent.click(screen.getByTestId('updatePostBtn')); await waitFor( () => { @@ -396,9 +396,9 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('pinpostBtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('pinpostBtn')); await waitFor( () => { @@ -428,9 +428,9 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('pinpostBtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('pinpostBtn')); }); it('Testing post delete functionality', async () => { render( @@ -445,10 +445,10 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('deletePostModalBtn')); + await userEvent.click(screen.getByTestId('deletePostModalBtn')); fireEvent.click(screen.getByTestId('deletePostBtn')); await waitFor( @@ -481,10 +481,10 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('deletePostModalBtn')); + await userEvent.click(screen.getByTestId('deletePostModalBtn')); fireEvent.click(screen.getByTestId('deletePostBtn')); }); it('Testing close functionality of primary modal', async () => { @@ -498,8 +498,8 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('closeiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('closeiconbtn')); //Primary Modal is closed expect(screen.queryByTestId('moreiconbtn')).not.toBeInTheDocument(); @@ -515,9 +515,9 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('closebtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('closebtn')); //Secondary Modal is closed expect(screen.queryByTestId('deletePostModalBtn')).not.toBeInTheDocument(); @@ -535,7 +535,7 @@ describe('Testing Organization Post Card', () => { ); expect(screen.queryByTestId('toggleBtn')).not.toBeInTheDocument(); }); - it('renders with "Read more" button when postInfo length is more than 43', () => { + it('renders with "Read more" button when postInfo length is more than 43', async () => { const props2 = { id: '12', postID: '123', @@ -554,24 +554,24 @@ describe('Testing Organization Post Card', () => { , ); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); expect(screen.getByTestId('toggleBtn')).toBeInTheDocument(); }); - it('updates state variables correctly when handleEditModal is called', () => { + it('updates state variables correctly when handleEditModal is called', async () => { const link2 = new StaticMockLink(MOCKS, true); render( , ); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('moreiconbtn')); expect(screen.queryByTestId('editPostModalBtn')).toBeInTheDocument(); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); //Primary Modal is closed expect(screen.queryByTestId('closeiconbtn')).not.toBeInTheDocument(); @@ -584,20 +584,20 @@ describe('Testing Organization Post Card', () => { expect(screen.queryByTestId('pinpostBtn')).not.toBeInTheDocument(); expect(screen.queryByTestId('closebtn')).not.toBeInTheDocument(); }); - it('updates state variables correctly when handleDeleteModal is called', () => { + it('updates state variables correctly when handleDeleteModal is called', async () => { const link2 = new StaticMockLink(MOCKS, true); render( , ); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('moreiconbtn')); expect(screen.queryByTestId('deletePostModalBtn')).toBeInTheDocument(); - userEvent.click(screen.getByTestId('deletePostModalBtn')); + await userEvent.click(screen.getByTestId('deletePostModalBtn')); //Primary Modal is closed expect(screen.queryByTestId('closeiconbtn')).not.toBeInTheDocument(); @@ -619,10 +619,10 @@ describe('Testing Organization Post Card', () => { , ); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); const postVideoUrlInput = screen.queryByTestId('postVideoUrl'); @@ -630,7 +630,7 @@ describe('Testing Organization Post Card', () => { fireEvent.change(getByTestId('postVideoUrl'), { target: { value: '' }, }); - userEvent.click(screen.getByPlaceholderText(/video/i)); + await userEvent.click(screen.getByPlaceholderText(/video/i)); const input = getByTestId('postVideoUrl'); const file = new File(['test-video'], 'test.mp4', { type: 'video/mp4' }); Object.defineProperty(input, 'files', { @@ -641,7 +641,7 @@ describe('Testing Organization Post Card', () => { convertToBase64(file); }); - userEvent.click(screen.getByTestId('closePreview')); + await userEvent.click(screen.getByTestId('closePreview')); } }); it('clears postimage state and resets file input value', async () => { @@ -653,10 +653,10 @@ describe('Testing Organization Post Card', () => { , ); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); const imageUrlInput = screen.queryByTestId('postImageUrl'); @@ -664,7 +664,7 @@ describe('Testing Organization Post Card', () => { fireEvent.change(getByTestId('postImageUrl'), { target: { value: '' }, }); - userEvent.click(screen.getByPlaceholderText(/image/i)); + await userEvent.click(screen.getByPlaceholderText(/image/i)); const input = getByTestId('postImageUrl'); const file = new File(['test-image'], 'test.jpg', { type: 'image/jpeg' }); Object.defineProperty(input, 'files', { @@ -692,15 +692,15 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); fireEvent.change(getByTestId('updateTitle'), { target: { value: '' }, }); - userEvent.click(screen.getByTestId('updatePostBtn')); // Should not update post + await userEvent.click(screen.getByTestId('updatePostBtn')); // Should not update post expect(screen.getByTestId('updateTitle')).toHaveValue(''); expect(screen.getByTestId('closeOrganizationModal')).toBeInTheDocument(); @@ -717,15 +717,15 @@ describe('Testing Organization Post Card', () => { await wait(); - userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); fireEvent.change(getByTestId('updateText'), { target: { value: '' }, }); - userEvent.click(screen.getByTestId('updatePostBtn')); // Should not update post + await userEvent.click(screen.getByTestId('updatePostBtn')); // Should not update post expect(screen.getByTestId('updateText')).toHaveValue(''); expect(screen.getByTestId('closeOrganizationModal')).toBeInTheDocument(); @@ -743,15 +743,15 @@ describe('Testing Organization Post Card', () => { ); await wait(); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('moreiconbtn')); - userEvent.click(screen.getByTestId('editPostModalBtn')); + await userEvent.click(screen.getByTestId('editPostModalBtn')); const createOrgBtn = screen.getByTestId('modalOrganizationHeader'); expect(createOrgBtn).toBeInTheDocument(); - userEvent.click(createOrgBtn); - userEvent.click(screen.getByTestId('closeOrganizationModal')); + await userEvent.click(createOrgBtn); + await userEvent.click(screen.getByTestId('closeOrganizationModal')); }); it('should toggle post pin when pin button is clicked', async () => { const { getByTestId } = render( @@ -761,9 +761,9 @@ describe('Testing Organization Post Card', () => { , ); - userEvent.click(screen.getByAltText('image')); + await userEvent.click(screen.getByAltText('image')); - userEvent.click(screen.getByTestId('moreiconbtn')); + await userEvent.click(screen.getByTestId('moreiconbtn')); const pinButton = getByTestId('pinpostBtn'); fireEvent.click(pinButton); await waitFor(() => { diff --git a/src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx b/src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx index e4b5663788..4111d710e6 100644 --- a/src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx +++ b/src/components/OrgSettings/ActionItemCategories/CategoryModal.spec.tsx @@ -104,9 +104,9 @@ const fillFormAndSubmit = async ( fireEvent.change(nameInput, { target: { value: name } }); if (isDisabled) { - userEvent.click(isDisabledSwitch); + await userEvent.click(isDisabledSwitch); } - userEvent.click(submitBtn); + await userEvent.click(submitBtn); }; describe('Testing Action Item Category Modal', () => { @@ -134,7 +134,7 @@ describe('Testing Action Item Category Modal', () => { renderCategoryModal(link1, categoryProps[1]); const isDisabledSwitch = screen.getByTestId('isDisabledSwitch'); expect(isDisabledSwitch).not.toBeChecked(); - userEvent.click(isDisabledSwitch); + await userEvent.click(isDisabledSwitch); expect(isDisabledSwitch).toBeChecked(); }); @@ -211,7 +211,7 @@ describe('Testing Action Item Category Modal', () => { it('Try to edit without changing any field', async () => { renderCategoryModal(link1, categoryProps[1]); const submitBtn = screen.getByTestId('formSubmitButton'); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith(translations.sameNameConflict); diff --git a/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.spec.tsx b/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.spec.tsx index 90c2a105ce..6ec90b169e 100644 --- a/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.spec.tsx +++ b/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.spec.tsx @@ -170,10 +170,12 @@ describe('Testing Organisation Action Item Categories', () => { 'createActionItemCategoryBtn', ); expect(addCategoryBtn).toBeInTheDocument(); - userEvent.click(addCategoryBtn); + await userEvent.click(addCategoryBtn); await waitFor(() => expect(screen.getAllByText(t.create)).toHaveLength(2)); - userEvent.click(screen.getByTestId('actionItemCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('actionItemCategoryModalCloseBtn'), + ); await waitFor(() => expect( screen.queryByTestId('actionItemCategoryModalCloseBtn'), @@ -186,12 +188,14 @@ describe('Testing Organisation Action Item Categories', () => { const editCategoryBtn = await screen.findByTestId('editCategoryBtn1'); await waitFor(() => expect(editCategoryBtn).toBeInTheDocument()); - userEvent.click(editCategoryBtn); + await userEvent.click(editCategoryBtn); await waitFor(() => expect(screen.getByText(t.updateActionItemCategory)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('actionItemCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('actionItemCategoryModalCloseBtn'), + ); await waitFor(() => expect( screen.queryByTestId('actionItemCategoryModalCloseBtn'), @@ -205,8 +209,8 @@ describe('Testing Organisation Action Item Categories', () => { const searchInput = await screen.findByTestId('searchByName'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'Category 1'); - userEvent.click(screen.getByTestId('searchBtn')); + await userEvent.type(searchInput, 'Category 1'); + await userEvent.click(screen.getByTestId('searchBtn')); await waitFor(() => { expect(screen.getByText('Category 1')).toBeInTheDocument(); expect(screen.queryByText('Category 2')).toBeNull(); @@ -220,7 +224,7 @@ describe('Testing Organisation Action Item Categories', () => { expect(searchInput).toBeInTheDocument(); // Clear the search input by backspace - userEvent.type(searchInput, 'A{backspace}'); + await userEvent.type(searchInput, 'A{backspace}'); await waitFor(() => { expect(screen.getByText('Category 1')).toBeInTheDocument(); expect(screen.getByText('Category 2')).toBeInTheDocument(); @@ -234,7 +238,7 @@ describe('Testing Organisation Action Item Categories', () => { expect(searchInput).toBeInTheDocument(); // Simulate typing and pressing ENTER - userEvent.type(searchInput, 'Category 1{enter}'); + await userEvent.type(searchInput, 'Category 1{enter}'); // Wait for the filtering to complete await waitFor(() => { diff --git a/src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx b/src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx index 8be982271c..48a1a5f254 100644 --- a/src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx +++ b/src/components/OrgSettings/AgendaItemCategories/AgendaCategoryUpdateModal.spec.tsx @@ -65,7 +65,7 @@ describe('AgendaCategoryUpdateModal', () => { ).toBeInTheDocument(); }); - it('calls hideUpdateModal when close button is clicked', () => { + it('calls hideUpdateModal when close button is clicked', async () => { render( @@ -87,7 +87,9 @@ describe('AgendaCategoryUpdateModal', () => { , ); - userEvent.click(screen.getByTestId('updateAgendaCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('updateAgendaCategoryModalCloseBtn'), + ); expect(mockHideUpdateModal).toHaveBeenCalledTimes(1); }); diff --git a/src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory.spec.tsx b/src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory.spec.tsx index 4ba81275ec..ad1f6043be 100644 --- a/src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory.spec.tsx +++ b/src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory.spec.tsx @@ -146,14 +146,16 @@ describe('Testing Agenda Categories Component', () => { await waitFor(() => { expect(screen.getByTestId('createAgendaCategoryBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('createAgendaCategoryBtn')); await waitFor(() => { return expect( screen.findByTestId('createAgendaCategoryModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaCategoryModalCloseBtn')); + await userEvent.click( + screen.getByTestId('createAgendaCategoryModalCloseBtn'), + ); await waitForElementToBeRemoved(() => screen.queryByTestId('createAgendaCategoryModalCloseBtn'), @@ -179,7 +181,7 @@ describe('Testing Agenda Categories Component', () => { await waitFor(() => { expect(screen.getByTestId('createAgendaCategoryBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('createAgendaCategoryBtn')); await waitFor(() => { return expect( @@ -187,16 +189,18 @@ describe('Testing Agenda Categories Component', () => { ).resolves.toBeInTheDocument(); }); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.name), formData.name, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.description), formData.description, ); - userEvent.click(screen.getByTestId('createAgendaCategoryFormSubmitBtn')); + await userEvent.click( + screen.getByTestId('createAgendaCategoryFormSubmitBtn'), + ); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -225,7 +229,7 @@ describe('Testing Agenda Categories Component', () => { await waitFor(() => { expect(screen.getByTestId('createAgendaCategoryBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createAgendaCategoryBtn')); + await userEvent.click(screen.getByTestId('createAgendaCategoryBtn')); await waitFor(() => { return expect( @@ -233,16 +237,18 @@ describe('Testing Agenda Categories Component', () => { ).resolves.toBeInTheDocument(); }); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.name), formData.name, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.description), formData.description, ); - userEvent.click(screen.getByTestId('createAgendaCategoryFormSubmitBtn')); + await userEvent.click( + screen.getByTestId('createAgendaCategoryFormSubmitBtn'), + ); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith('Mock Graphql Error'); @@ -265,7 +271,7 @@ describe('Testing Agenda Categories Component', () => { const searchInput = await screen.findByTestId('searchByName'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'Category 1'); + await userEvent.type(searchInput, 'Category 1'); await waitFor(() => { expect(searchInput).toHaveValue('Category 1'); }); @@ -287,7 +293,7 @@ describe('Testing Agenda Categories Component', () => { const searchInput = await screen.findByTestId('searchByName'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'Category'); + await userEvent.type(searchInput, 'Category'); await act(async () => { fireEvent.keyUp(searchInput, { key: 'Enter' }); }); @@ -312,10 +318,10 @@ describe('Testing Agenda Categories Component', () => { ); const searchInput = await screen.findByTestId('searchByName'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'Category'); + await userEvent.type(searchInput, 'Category'); const searchButton = await screen.findByTestId('searchBtn'); - userEvent.click(searchButton); + await userEvent.click(searchButton); await waitFor(() => { expect(screen.getAllByText('Category').length).toBe(2); }); @@ -336,7 +342,7 @@ describe('Testing Agenda Categories Component', () => { ); const searchInput = await screen.findByTestId('searchByName'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'A{backspace}'); + await userEvent.type(searchInput, 'A{backspace}'); await waitFor(() => { expect(screen.getAllByText('Category').length).toBe(2); }); diff --git a/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx b/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx index 45bdfbc122..3c042bfcf4 100644 --- a/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx +++ b/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.spec.tsx @@ -202,7 +202,7 @@ describe('Testing Save Button', () => { ); await wait(); - userEvent.click(screen.getByTestId('saveChangesBtn')); + await userEvent.click(screen.getByTestId('saveChangesBtn')); await wait(); expect(screen.queryByText('Field added successfully')).toBeInTheDocument(); }); @@ -217,13 +217,13 @@ describe('Testing Save Button', () => { , ); await wait(); - userEvent.click(screen.getByTestId('saveChangesBtn')); + await userEvent.click(screen.getByTestId('saveChangesBtn')); await wait(); expect( screen.queryByText('Failed to add custom field'), ).toBeInTheDocument(); await wait(); - userEvent.type(screen.getByTestId('customFieldInput'), 'Age{enter}'); + await userEvent.type(screen.getByTestId('customFieldInput'), 'Age{enter}'); await wait(); expect( screen.queryByText('Failed to add custom field'), @@ -242,7 +242,7 @@ describe('Testing Save Button', () => { await wait(); const fieldNameInput = getByTestId('customFieldInput'); - userEvent.type(fieldNameInput, 'Age'); + await userEvent.type(fieldNameInput, 'Age'); }); it('When No Custom Data is Present', async () => { const { getByText } = render( @@ -267,7 +267,7 @@ describe('Testing Save Button', () => { ); await wait(); - userEvent.click(screen.getByTestId('removeCustomFieldBtn')); + await userEvent.click(screen.getByTestId('removeCustomFieldBtn')); await wait(); expect( screen.queryByText('Field removed successfully'), @@ -285,7 +285,7 @@ describe('Testing Save Button', () => { , ); await wait(); - userEvent.click(screen.getByTestId('removeCustomFieldBtn')); + await userEvent.click(screen.getByTestId('removeCustomFieldBtn')); await wait(); expect(toastSpy).toHaveBeenCalledWith('Failed to remove custom field'); }); diff --git a/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx b/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx index 2a6496d69a..f7ef95d54e 100644 --- a/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx +++ b/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.spec.tsx @@ -149,21 +149,21 @@ describe('Testing Organization Update', () => { fireEvent.change(dependentLocality, { target: { value: '' } }); // Mocking filling form behaviour - userEvent.type(name, formData.name); - userEvent.type(des, formData.description); - userEvent.type(city, formData.address.city); - userEvent.selectOptions(countryCode, formData.address.countryCode); - userEvent.type(line1, formData.address.line1); - userEvent.type(line2, formData.address.line2); - userEvent.type(postalCode, formData.address.postalCode); - userEvent.type(dependentLocality, formData.address.dependentLocality); - userEvent.type(sortingCode, formData.address.sortingCode); - userEvent.upload(displayImage, formData.displayImage); - userEvent.click(userRegistrationRequired); - userEvent.click(isVisible); + await userEvent.type(name, formData.name); + await userEvent.type(des, formData.description); + await userEvent.type(city, formData.address.city); + await userEvent.selectOptions(countryCode, formData.address.countryCode); + await userEvent.type(line1, formData.address.line1); + await userEvent.type(line2, formData.address.line2); + await userEvent.type(postalCode, formData.address.postalCode); + await userEvent.type(dependentLocality, formData.address.dependentLocality); + await userEvent.type(sortingCode, formData.address.sortingCode); + await userEvent.upload(displayImage, formData.displayImage); + await userEvent.click(userRegistrationRequired); + await userEvent.click(isVisible); await wait(); - userEvent.click(saveChangesBtn); + await userEvent.click(saveChangesBtn); // Checking if the form got update accordingly expect(name).toHaveValue(formData.name); @@ -235,20 +235,20 @@ describe('Testing Organization Update', () => { fireEvent.change(dependentLocality, { target: { value: '' } }); // Mocking filling form behaviour - userEvent.type(name, formData.name); - userEvent.type(des, formData.description); - userEvent.type(city, formData.address.city); - userEvent.selectOptions(countryCode, formData.address.countryCode); - userEvent.type(line1, formData.address.line1); - userEvent.type(line2, formData.address.line2); - userEvent.type(postalCode, formData.address.postalCode); - userEvent.type(dependentLocality, formData.address.dependentLocality); - userEvent.type(sortingCode, formData.address.sortingCode); - userEvent.upload(displayImage, formData.displayImage); - userEvent.click(userRegistrationRequired); - userEvent.click(isVisible); + await userEvent.type(name, formData.name); + await userEvent.type(des, formData.description); + await userEvent.type(city, formData.address.city); + await userEvent.selectOptions(countryCode, formData.address.countryCode); + await userEvent.type(line1, formData.address.line1); + await userEvent.type(line2, formData.address.line2); + await userEvent.type(postalCode, formData.address.postalCode); + await userEvent.type(dependentLocality, formData.address.dependentLocality); + await userEvent.type(sortingCode, formData.address.sortingCode); + await userEvent.upload(displayImage, formData.displayImage); + await userEvent.click(userRegistrationRequired); + await userEvent.click(isVisible); await wait(); - userEvent.click(saveChangesBtn); + await userEvent.click(saveChangesBtn); }); }); diff --git a/src/components/ProfileDropdown/ProfileDropdown.spec.tsx b/src/components/ProfileDropdown/ProfileDropdown.spec.tsx index 769a084f9e..bb292ac9dc 100644 --- a/src/components/ProfileDropdown/ProfileDropdown.spec.tsx +++ b/src/components/ProfileDropdown/ProfileDropdown.spec.tsx @@ -132,10 +132,10 @@ describe('ProfileDropdown Component', () => { ); await act(async () => { - userEvent.click(screen.getByTestId('togDrop')); + await userEvent.click(screen.getByTestId('togDrop')); }); - userEvent.click(screen.getByTestId('logoutBtn')); + await userEvent.click(screen.getByTestId('logoutBtn')); expect(global.window.location.pathname).toBe('/'); }); @@ -156,11 +156,11 @@ describe('ProfileDropdown Component', () => { ); await act(async () => { - userEvent.click(screen.getByTestId('togDrop')); + await userEvent.click(screen.getByTestId('togDrop')); }); await act(async () => { - userEvent.click(screen.getByTestId('profileBtn')); + await userEvent.click(screen.getByTestId('profileBtn')); }); expect(mockNavigate).toHaveBeenCalledWith('/user/settings'); @@ -192,12 +192,12 @@ describe('ProfileDropdown Component', () => { // Open the dropdown await act(async () => { - userEvent.click(screen.getByTestId('togDrop')); + await userEvent.click(screen.getByTestId('togDrop')); }); // Click the logout button await act(async () => { - userEvent.click(screen.getByTestId('logoutBtn')); + await userEvent.click(screen.getByTestId('logoutBtn')); }); // Wait for any pending promises @@ -228,11 +228,11 @@ describe('ProfileDropdown Component', () => { ); await act(async () => { - userEvent.click(screen.getByTestId('togDrop')); + await userEvent.click(screen.getByTestId('togDrop')); }); await act(async () => { - userEvent.click(screen.getByTestId('profileBtn')); + await userEvent.click(screen.getByTestId('profileBtn')); }); expect(mockNavigate).toHaveBeenCalledWith('/user/settings'); @@ -256,11 +256,11 @@ describe('ProfileDropdown Component', () => { ); await act(async () => { - userEvent.click(screen.getByTestId('togDrop')); + await userEvent.click(screen.getByTestId('togDrop')); }); await act(async () => { - userEvent.click(screen.getByTestId('profileBtn')); + await userEvent.click(screen.getByTestId('profileBtn')); }); expect(mockNavigate).toHaveBeenCalledWith('/member/'); @@ -284,11 +284,11 @@ describe('ProfileDropdown Component', () => { ); await act(async () => { - userEvent.click(screen.getByTestId('togDrop')); + await userEvent.click(screen.getByTestId('togDrop')); }); await act(async () => { - userEvent.click(screen.getByTestId('profileBtn')); + await userEvent.click(screen.getByTestId('profileBtn')); }); expect(mockNavigate).toHaveBeenCalledWith('/member/321'); diff --git a/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx b/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx index 236e34e855..9bec66a9c6 100644 --- a/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx +++ b/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx @@ -100,7 +100,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); @@ -108,19 +108,19 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); await waitFor(() => { expect( @@ -128,12 +128,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customDailyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customDailyRecurrence')); + await userEvent.click(screen.getByTestId('customDailyRecurrence')); await waitFor(() => { expect( @@ -141,12 +143,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ).toHaveTextContent('Day'); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customWeeklyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customWeeklyRecurrence')); + await userEvent.click(screen.getByTestId('customWeeklyRecurrence')); await waitFor(() => { expect( @@ -154,12 +158,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ).toHaveTextContent('Week'); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customMonthlyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customMonthlyRecurrence')); + await userEvent.click(screen.getByTestId('customMonthlyRecurrence')); await waitFor(() => { expect( @@ -167,12 +173,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ).toHaveTextContent('Month'); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customYearlyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customYearlyRecurrence')); + await userEvent.click(screen.getByTestId('customYearlyRecurrence')); await waitFor(() => { expect( @@ -180,7 +188,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte ).toHaveTextContent('Year'); }); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect( screen.queryByTestId('customRecurrenceSubmitBtn'), @@ -211,7 +219,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); @@ -219,21 +227,21 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); - await waitFor(() => { + await waitFor(async () => { expect( screen.getByTestId('customRecurrenceSubmitBtn'), ).toBeInTheDocument(); @@ -241,15 +249,15 @@ describe('Testing the creaction of recurring events with custom recurrence patte const weekDaysOptions = screen.getAllByTestId('recurrenceWeekDay'); - weekDaysOptions.forEach((weekDay) => { - userEvent.click(weekDay); - }); + await Promise.all( + weekDaysOptions.map((weekDay) => userEvent.click(weekDay)), + ); - weekDaysOptions.forEach((weekDay) => { - userEvent.click(weekDay); - }); + await Promise.all( + weekDaysOptions.map((weekDay) => userEvent.click(weekDay)), + ); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect( screen.queryByTestId('customRecurrenceSubmitBtn'), @@ -280,7 +288,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); const startDatePicker = screen.getByLabelText('Start Date'); fireEvent.change(startDatePicker, { @@ -298,30 +306,32 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); await waitFor(() => { expect( screen.getByTestId('customRecurrenceFrequencyDropdown'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customMonthlyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customMonthlyRecurrence')); + await userEvent.click(screen.getByTestId('customMonthlyRecurrence')); await waitFor(() => { expect( @@ -335,14 +345,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); + await userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); await waitFor(() => { expect( screen.getByTestId('monthlyRecurrenceOptionOnThatOccurence'), ).toBeInTheDocument(); }); - userEvent.click( + await userEvent.click( screen.getByTestId('monthlyRecurrenceOptionOnThatOccurence'), ); @@ -352,14 +362,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); + await userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); await waitFor(() => { expect( screen.getByTestId('monthlyRecurrenceOptionOnLastOccurence'), ).toBeInTheDocument(); }); - userEvent.click( + await userEvent.click( screen.getByTestId('monthlyRecurrenceOptionOnLastOccurence'), ); @@ -369,14 +379,16 @@ describe('Testing the creaction of recurring events with custom recurrence patte ); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); + await userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); await waitFor(() => { expect( screen.getByTestId('monthlyRecurrenceOptionOnThatDay'), ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOptionOnThatDay')); + await userEvent.click( + screen.getByTestId('monthlyRecurrenceOptionOnThatDay'), + ); await waitFor(() => { expect(screen.getByTestId('monthlyRecurrenceOptions')).toHaveTextContent( @@ -409,7 +421,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); @@ -417,30 +429,30 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); await waitFor(() => { expect(screen.getByTestId('never')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('never')); - userEvent.click(screen.getByTestId('on')); - userEvent.click(screen.getByTestId('after')); - userEvent.click(screen.getByTestId('never')); + await userEvent.click(screen.getByTestId('never')); + await userEvent.click(screen.getByTestId('on')); + await userEvent.click(screen.getByTestId('after')); + await userEvent.click(screen.getByTestId('never')); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect( screen.queryByTestId('customRecurrenceSubmitBtn'), @@ -471,20 +483,23 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Location/i), formData.location, ); @@ -499,26 +514,28 @@ describe('Testing the creaction of recurring events with custom recurrence patte target: { value: formData.endDate }, }); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customMonthlyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customMonthlyRecurrence')); + await userEvent.click(screen.getByTestId('customMonthlyRecurrence')); await waitFor(() => { expect( @@ -526,14 +543,14 @@ describe('Testing the creaction of recurring events with custom recurrence patte ).toHaveTextContent('Month'); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); + await userEvent.click(screen.getByTestId('monthlyRecurrenceOptions')); await waitFor(() => { expect( screen.getByTestId('monthlyRecurrenceOptionOnThatOccurence'), ).toBeInTheDocument(); }); - userEvent.click( + await userEvent.click( screen.getByTestId('monthlyRecurrenceOptionOnThatOccurence'), ); @@ -541,7 +558,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('on')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('on')); + await userEvent.click(screen.getByTestId('on')); await waitFor(() => { expect(screen.getByTestId('on')).toBeChecked(); @@ -567,7 +584,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte target: { value: 2 }, }); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect( screen.queryByTestId('customRecurrenceSubmitBtn'), @@ -579,7 +596,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte // "..." because of the overlay component that would trim the recurrence rule text at 45 characters ); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventCreated); @@ -615,20 +632,23 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Location/i), formData.location, ); @@ -644,26 +664,28 @@ describe('Testing the creaction of recurring events with custom recurrence patte target: { value: formData.endDate }, }); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); - userEvent.click(screen.getByTestId('customRecurrenceFrequencyDropdown')); + await userEvent.click( + screen.getByTestId('customRecurrenceFrequencyDropdown'), + ); await waitFor(() => { expect(screen.getByTestId('customDailyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customDailyRecurrence')); + await userEvent.click(screen.getByTestId('customDailyRecurrence')); await waitFor(() => { expect( @@ -675,7 +697,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('after')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('after')); + await userEvent.click(screen.getByTestId('after')); await waitFor(() => { expect(screen.getByTestId('after')).toBeChecked(); @@ -696,7 +718,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte expect(screen.getByTestId('customRecurrenceCountInput')).toHaveValue(100); }); - userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceSubmitBtn')); await waitFor(() => { expect( screen.queryByTestId('customRecurrenceSubmitBtn'), @@ -707,7 +729,7 @@ describe('Testing the creaction of recurring events with custom recurrence patte 'Daily, 100 times', ); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventCreated); diff --git a/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx b/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx index 07adf7bd16..6b58eba2ac 100644 --- a/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx +++ b/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx @@ -103,7 +103,7 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); @@ -111,7 +111,7 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); @@ -141,7 +141,7 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); @@ -149,13 +149,13 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); @@ -185,7 +185,7 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); @@ -193,19 +193,19 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('customRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrence')); + await userEvent.click(screen.getByTestId('customRecurrence')); await waitFor(() => { expect( @@ -213,7 +213,7 @@ describe('Testing the creaction of recurring events through recurrence options', ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('customRecurrenceModalCloseBtn')); + await userEvent.click(screen.getByTestId('customRecurrenceModalCloseBtn')); await waitFor(() => { expect( @@ -245,7 +245,7 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); const startDatePicker = screen.getByLabelText('Start Date'); const endDatePicker = screen.getByLabelText('End Date'); @@ -264,29 +264,29 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.queryByTestId('recurrenceOptions')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('dailyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('dailyRecurrence')); + await userEvent.click(screen.getByTestId('dailyRecurrence')); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('weeklyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('weeklyRecurrence')); + await userEvent.click(screen.getByTestId('weeklyRecurrence')); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect( @@ -294,9 +294,9 @@ describe('Testing the creaction of recurring events through recurrence options', ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOnThatDay')); + await userEvent.click(screen.getByTestId('monthlyRecurrenceOnThatDay')); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect( @@ -304,9 +304,11 @@ describe('Testing the creaction of recurring events through recurrence options', ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOnThatOccurence')); + await userEvent.click( + screen.getByTestId('monthlyRecurrenceOnThatOccurence'), + ); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect( @@ -314,22 +316,24 @@ describe('Testing the creaction of recurring events through recurrence options', ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('monthlyRecurrenceOnLastOccurence')); + await userEvent.click( + screen.getByTestId('monthlyRecurrenceOnLastOccurence'), + ); // changing the startDate would change the weekDayOccurenceInMonth, if it is defined fireEvent.change(startDatePicker, { target: { value: formData.endDate }, }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('yearlyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('yearlyRecurrence')); + await userEvent.click(screen.getByTestId('yearlyRecurrence')); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect( @@ -337,7 +341,7 @@ describe('Testing the creaction of recurring events through recurrence options', ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('mondayToFridayRecurrence')); + await userEvent.click(screen.getByTestId('mondayToFridayRecurrence')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toHaveTextContent( @@ -369,20 +373,23 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Location/i), formData.location, ); @@ -398,7 +405,7 @@ describe('Testing the creaction of recurring events through recurrence options', target: { value: formData.endDate }, }); - userEvent.click(screen.getByTestId('alldayCheck')); + await userEvent.click(screen.getByTestId('alldayCheck')); await waitFor(() => { expect(screen.getByLabelText(translations.startTime)).toBeInTheDocument(); @@ -419,19 +426,19 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect(screen.getByTestId('dailyRecurrence')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('dailyRecurrence')); + await userEvent.click(screen.getByTestId('dailyRecurrence')); expect(screen.getByPlaceholderText(/Enter Title/i)).toHaveValue( formData.title, @@ -451,7 +458,7 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('recurrenceOptions')).toHaveTextContent('Daily'); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventCreated); @@ -487,20 +494,23 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Location/i), formData.location, ); @@ -516,7 +526,7 @@ describe('Testing the creaction of recurring events through recurrence options', target: { value: formData.endDate }, }); - userEvent.click(screen.getByTestId('alldayCheck')); + await userEvent.click(screen.getByTestId('alldayCheck')); await waitFor(() => { expect(screen.getByLabelText(translations.startTime)).toBeInTheDocument(); @@ -537,13 +547,13 @@ describe('Testing the creaction of recurring events through recurrence options', expect(screen.getByTestId('recurringCheck')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); await waitFor(() => { expect(screen.getByTestId('recurrenceOptions')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('recurrenceOptions')); + await userEvent.click(screen.getByTestId('recurrenceOptions')); await waitFor(() => { expect( @@ -551,7 +561,7 @@ describe('Testing the creaction of recurring events through recurrence options', ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('mondayToFridayRecurrence')); + await userEvent.click(screen.getByTestId('mondayToFridayRecurrence')); expect(screen.getByPlaceholderText(/Enter Title/i)).toHaveValue( formData.title, @@ -573,7 +583,7 @@ describe('Testing the creaction of recurring events through recurrence options', 'Monday to Friday', ); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventCreated); diff --git a/src/components/RequestsTableItem/RequestsTableItem.spec.tsx b/src/components/RequestsTableItem/RequestsTableItem.spec.tsx index 737b0fa926..92ce215357 100644 --- a/src/components/RequestsTableItem/RequestsTableItem.spec.tsx +++ b/src/components/RequestsTableItem/RequestsTableItem.spec.tsx @@ -109,7 +109,7 @@ describe('Testing User Table Item', () => { ); await wait(); - userEvent.click(screen.getByTestId('acceptMembershipRequestBtn123')); + await userEvent.click(screen.getByTestId('acceptMembershipRequestBtn123')); }); it('Accept MembershipRequest handles error', async () => { @@ -141,7 +141,7 @@ describe('Testing User Table Item', () => { ); await wait(); - userEvent.click(screen.getByTestId('acceptMembershipRequestBtn1')); + await userEvent.click(screen.getByTestId('acceptMembershipRequestBtn1')); }); it('Reject MembershipRequest Button works properly', async () => { @@ -173,7 +173,7 @@ describe('Testing User Table Item', () => { ); await wait(); - userEvent.click(screen.getByTestId('rejectMembershipRequestBtn123')); + await userEvent.click(screen.getByTestId('rejectMembershipRequestBtn123')); }); it('Reject MembershipRequest handles error', async () => { @@ -205,6 +205,6 @@ describe('Testing User Table Item', () => { ); await wait(); - userEvent.click(screen.getByTestId('rejectMembershipRequestBtn1')); + await userEvent.click(screen.getByTestId('rejectMembershipRequestBtn1')); }); }); diff --git a/src/components/TagActions/TagActions.test.tsx b/src/components/TagActions/TagActions.test.tsx index d27f177ebe..e1c34c2490 100644 --- a/src/components/TagActions/TagActions.test.tsx +++ b/src/components/TagActions/TagActions.test.tsx @@ -164,7 +164,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('closeTagActionsModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('closeTagActionsModalBtn')); + await userEvent.click(screen.getByTestId('closeTagActionsModalBtn')); await waitFor(() => { expect(hideTagActionsModalMock).toHaveBeenCalled(); @@ -190,7 +190,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('expandSubTags1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('expandSubTags1')); + await userEvent.click(screen.getByTestId('expandSubTags1')); await waitFor(() => { expect( @@ -255,22 +255,22 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('checkTag1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag1')); + await userEvent.click(screen.getByTestId('checkTag1')); await waitFor(() => { expect(screen.getByTestId('checkTag2')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag2')); + await userEvent.click(screen.getByTestId('checkTag2')); await waitFor(() => { expect(screen.getByTestId('checkTag1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag1')); + await userEvent.click(screen.getByTestId('checkTag1')); await waitFor(() => { expect(screen.getByTestId('clearSelectedTag2')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('clearSelectedTag2')); + await userEvent.click(screen.getByTestId('clearSelectedTag2')); }); test('fetches and lists the child tags and then selects and deselects them', async () => { @@ -282,7 +282,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('expandSubTags1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('expandSubTags1')); + await userEvent.click(screen.getByTestId('expandSubTags1')); await waitFor(() => { expect(screen.getByTestId('subTagsScrollableDiv1')).toBeInTheDocument(); @@ -308,34 +308,34 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('checkTagsubTag1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTagsubTag1')); + await userEvent.click(screen.getByTestId('checkTagsubTag1')); await waitFor(() => { expect(screen.getByTestId('checkTagsubTag2')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTagsubTag2')); + await userEvent.click(screen.getByTestId('checkTagsubTag2')); await waitFor(() => { expect(screen.getByTestId('checkTag1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag1')); + await userEvent.click(screen.getByTestId('checkTag1')); // deselect subtags 1 & 2 await waitFor(() => { expect(screen.getByTestId('checkTagsubTag1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTagsubTag1')); + await userEvent.click(screen.getByTestId('checkTagsubTag1')); await waitFor(() => { expect(screen.getByTestId('checkTagsubTag2')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTagsubTag2')); + await userEvent.click(screen.getByTestId('checkTagsubTag2')); // hide subtags of tag 1 await waitFor(() => { expect(screen.getByTestId('expandSubTags1')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('expandSubTags1')); + await userEvent.click(screen.getByTestId('expandSubTags1')); }); test('Toasts error when no tag is selected while assigning', async () => { @@ -346,7 +346,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('tagActionSubmitBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('tagActionSubmitBtn')); + await userEvent.click(screen.getByTestId('tagActionSubmitBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith(translations.noTagSelected); @@ -362,14 +362,14 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('checkTag2')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag2')); + await userEvent.click(screen.getByTestId('checkTag2')); await waitFor(() => { expect(screen.getByTestId('checkTag3')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag3')); + await userEvent.click(screen.getByTestId('checkTag3')); - userEvent.click(screen.getByTestId('tagActionSubmitBtn')); + await userEvent.click(screen.getByTestId('tagActionSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -387,9 +387,9 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('checkTag2')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('checkTag2')); + await userEvent.click(screen.getByTestId('checkTag2')); - userEvent.click(screen.getByTestId('tagActionSubmitBtn')); + await userEvent.click(screen.getByTestId('tagActionSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( diff --git a/src/components/UpdateSession/UpdateSession.spec.tsx b/src/components/UpdateSession/UpdateSession.spec.tsx index 21c70dbe5f..076bed12e3 100644 --- a/src/components/UpdateSession/UpdateSession.spec.tsx +++ b/src/components/UpdateSession/UpdateSession.spec.tsx @@ -105,8 +105,9 @@ describe('Testing UpdateTimeout Component', () => { const slider = await screen.findByTestId('slider-thumb'); // Simulate dragging to minimum value - userEvent.click(slider, { + await userEvent.click(slider, { // Simulate clicking on the slider to focus + // @ts-expect-error: Explanation for why this error is ignored clientX: -999, // Adjust the clientX to simulate different slider positions }); @@ -125,8 +126,9 @@ describe('Testing UpdateTimeout Component', () => { const slider = await screen.findByTestId('slider-thumb'); // Simulate dragging to maximum value - userEvent.click(slider, { + await userEvent.click(slider, { // Simulate clicking on the slider to focus + // @ts-expect-error: Explanation for why this error is ignored clientX: 999, // Adjust the clientX to simulate different slider positions }); @@ -145,8 +147,9 @@ describe('Testing UpdateTimeout Component', () => { const slider = await screen.findByTestId('slider-thumb'); // Simulate invalid value handling - userEvent.click(slider, { + await userEvent.click(slider, { // Simulate clicking on the slider to focus + // @ts-expect-error: Explanation for why this error is ignored clientX: 0, // Adjust the clientX to simulate different slider positions }); @@ -167,7 +170,7 @@ describe('Testing UpdateTimeout Component', () => { const slider = await screen.findByTestId('slider-thumb'); // Simulate slider interaction - userEvent.type(slider, '45'); // Simulate typing value + await userEvent.type(slider, '45'); // Simulate typing value // Assert that the callback was called with the expected value expect(mockOnValueChange).toHaveBeenCalledWith(expect.any(Number)); // Adjust as needed @@ -221,7 +224,7 @@ describe('Testing UpdateTimeout Component', () => { await wait(); const submitButton = screen.getByTestId('update-button'); - userEvent.click(submitButton); + await userEvent.click(submitButton); // Wait for the toast success call @@ -303,7 +306,7 @@ describe('Testing UpdateTimeout Component', () => { await wait(); const submitButton = screen.getByTestId('update-button'); - userEvent.click(submitButton); + await userEvent.click(submitButton); await wait(); diff --git a/src/components/UserListCard/UserListCard.spec.tsx b/src/components/UserListCard/UserListCard.spec.tsx index 6a3b2d42d8..ad2a776f4c 100644 --- a/src/components/UserListCard/UserListCard.spec.tsx +++ b/src/components/UserListCard/UserListCard.spec.tsx @@ -73,7 +73,63 @@ describe('Testing User List Card', () => { , ); - await wait(); - userEvent.click(screen.getByText(/Add Admin/i)); + const button = screen.getByText(/Add Admin/i); + await userEvent.click(button); + + await waitFor( + () => { + expect(toast.error).toHaveBeenCalled(); + }, + { timeout: DEFAULT_TIMEOUT }, + ); + }); + + test('Should render button with correct styling', () => { + const props = { + id: TEST_USER_ID, + key: 1, + }; + + render( + + + + + + + , + ); + + const button = screen.getByRole('button', { name: /Add Admin/i }); + expect(button).toBeInTheDocument(); + expect(button.className).toContain('memberfontcreatedbtn'); + }); + + test('Should handle translations and URL parameters correctly', async () => { + const props = { + id: TEST_USER_ID, + }; + + render( + + + + + + + , + ); + + const button = screen.getByText(/Add Admin/i); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + + await waitFor( + () => { + expect(toast.success).toHaveBeenCalled(); + }, + { timeout: DEFAULT_TIMEOUT }, + ); }); }); diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx index 0d704eaed8..a3f1e41686 100644 --- a/src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx +++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.spec.tsx @@ -48,20 +48,20 @@ describe('Testing User Password Update', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Previous Password/i), formData.previousPassword, ); - userEvent.type( + await userEvent.type( screen.getAllByPlaceholderText(/New Password/i)[0], formData.newPassword, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Confirm New Password/i), formData.confirmNewPassword, ); - userEvent.click(screen.getByText(/Save Changes/i)); + await userEvent.click(screen.getByText(/Save Changes/i)); expect(screen.getByText(/Cancel/i)).toBeTruthy(); expect( @@ -81,7 +81,7 @@ describe('Testing User Password Update', () => { , ); - userEvent.click(screen.getByText(/Save Changes/i)); + await userEvent.click(screen.getByText(/Save Changes/i)); await wait(); expect(mockToast.error).toHaveBeenCalledWith(`Password can't be empty`); @@ -98,20 +98,20 @@ describe('Testing User Password Update', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Previous Password/i), formData.previousPassword, ); - userEvent.type( + await userEvent.type( screen.getAllByPlaceholderText(/New Password/i)[0], formData.wrongPassword, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Confirm New Password/i), formData.confirmNewPassword, ); - userEvent.click(screen.getByText(/Save Changes/i)); + await userEvent.click(screen.getByText(/Save Changes/i)); expect(screen.getByText(/Cancel/i)).toBeTruthy(); await wait(); @@ -131,20 +131,20 @@ describe('Testing User Password Update', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Previous Password/i), formData.previousPassword, ); - userEvent.type( + await userEvent.type( screen.getAllByPlaceholderText(/New Password/i)[0], formData.newPassword, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Confirm New Password/i), formData.confirmNewPassword, ); - userEvent.click(screen.getByText(/Save Changes/i)); + await userEvent.click(screen.getByText(/Save Changes/i)); expect(mockToast.success).toHaveBeenCalledWith( 'Password updated Successfully', ); @@ -161,20 +161,20 @@ describe('Testing User Password Update', () => { // await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Previous Password/i), formData.wrongPassword, ); - userEvent.type( + await userEvent.type( screen.getAllByPlaceholderText(/New Password/i)[0], formData.newPassword, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Confirm New Password/i), formData.confirmNewPassword, ); - userEvent.click(screen.getByText(/Save Changes/i)); + await userEvent.click(screen.getByText(/Save Changes/i)); await waitFor(() => expect(mockToast.error).toHaveBeenCalledWith( diff --git a/src/components/UserPortal/CommentCard/CommentCard.spec.tsx b/src/components/UserPortal/CommentCard/CommentCard.spec.tsx index 57a708f793..7d53931787 100644 --- a/src/components/UserPortal/CommentCard/CommentCard.spec.tsx +++ b/src/components/UserPortal/CommentCard/CommentCard.spec.tsx @@ -223,7 +223,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); @@ -269,7 +269,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); if (beforeUserId) { setItem('userId', beforeUserId); @@ -302,7 +302,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); expect(toast.error).toHaveBeenCalled(); @@ -335,7 +335,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); expect(toast.error).toHaveBeenCalled(); @@ -375,7 +375,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); const initialLikes = container.textContent?.match(/\d+ Likes/)?.[0]; - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); const updatedLikes = container.textContent?.match(/\d+ Likes/)?.[0]; @@ -416,7 +416,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); const initialLikes = container.textContent?.match(/\d+ Likes/)?.[0]; - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); const updatedLikes = container.textContent?.match(/\d+ Likes/)?.[0]; @@ -457,7 +457,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); // HourglassBottomIcon should be visible during loading expect( @@ -501,7 +501,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); const initialLikes = container.textContent?.match(/\d+ Likes/)?.[0]; - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); const updatedLikes = container.textContent?.match(/\d+ Likes/)?.[0]; @@ -541,7 +541,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); // Verify that the likes count hasn't changed @@ -584,7 +584,7 @@ describe('Testing CommentCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('likeCommentBtn')); + await userEvent.click(screen.getByTestId('likeCommentBtn')); await wait(); // Verify that the likes count hasn't changed diff --git a/src/components/UserPortal/ContactCard/ContactCard.spec.tsx b/src/components/UserPortal/ContactCard/ContactCard.spec.tsx index 572a38feb7..dd1ac0d6dd 100644 --- a/src/components/UserPortal/ContactCard/ContactCard.spec.tsx +++ b/src/components/UserPortal/ContactCard/ContactCard.spec.tsx @@ -101,7 +101,7 @@ describe('Testing ContactCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('contactContainer')); + await userEvent.click(screen.getByTestId('contactContainer')); await wait(); }); @@ -126,7 +126,7 @@ describe('Testing ContactCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('contactContainer')); + await userEvent.click(screen.getByTestId('contactContainer')); await wait(); }); diff --git a/src/components/UserPortal/EventCard/EventCard.spec.tsx b/src/components/UserPortal/EventCard/EventCard.spec.tsx index 1a4806ee18..1086a5dbd5 100644 --- a/src/components/UserPortal/EventCard/EventCard.spec.tsx +++ b/src/components/UserPortal/EventCard/EventCard.spec.tsx @@ -137,7 +137,7 @@ describe('Testing Event Card In User portal', () => { , ); - userEvent.click(screen.getByText('Register')); + await userEvent.click(screen.getByText('Register')); await waitFor(() => expect( queryByText('Successfully registered for Test Event'), diff --git a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx index d0296b1221..8863227694 100644 --- a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx +++ b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx @@ -261,7 +261,7 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { const peoplePlugin = screen.getByText('People'); expect(peoplePlugin).toBeInTheDocument(); - userEvent.click(peoplePlugin); + await userEvent.click(peoplePlugin); await wait(); expect(history.location.pathname).toBe(`/user/people/${organizationId}`); @@ -282,9 +282,9 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn0')); + await userEvent.click(screen.getByTestId('changeLanguageBtn0')); await wait(); @@ -312,9 +312,9 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn1')); + await userEvent.click(screen.getByTestId('changeLanguageBtn1')); await wait(); @@ -336,9 +336,9 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn2')); + await userEvent.click(screen.getByTestId('changeLanguageBtn2')); await wait(); @@ -360,9 +360,9 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn3')); + await userEvent.click(screen.getByTestId('changeLanguageBtn3')); await wait(); @@ -384,9 +384,9 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn4')); + await userEvent.click(screen.getByTestId('changeLanguageBtn4')); await wait(); @@ -514,8 +514,8 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { , ); await wait(); - userEvent.click(screen.getByTestId('personIcon')); - userEvent.click(screen.getByTestId('logoutBtn')); + await userEvent.click(screen.getByTestId('personIcon')); + await userEvent.click(screen.getByTestId('logoutBtn')); expect(mockStorage.clear).toHaveBeenCalled(); expect(mockLocation.replace).toHaveBeenCalledWith('/'); }); @@ -537,7 +537,7 @@ describe('Testing OrganizationNavbar Component [User Portal]', () => { ); const homeLink = screen.getByText('Home'); expect(homeLink).toBeInTheDocument(); - userEvent.click(homeLink); + await userEvent.click(homeLink); await wait(); expect(history.location.pathname).toBe( `/user/organization/${organizationId}`, diff --git a/src/components/UserPortal/PostCard/PostCard.spec.tsx b/src/components/UserPortal/PostCard/PostCard.spec.tsx index 824c033d37..4016b11743 100644 --- a/src/components/UserPortal/PostCard/PostCard.spec.tsx +++ b/src/components/UserPortal/PostCard/PostCard.spec.tsx @@ -298,7 +298,7 @@ describe('Testing PostCard Component [User Portal]', () => { ); await wait(); - userEvent.click(screen.getByTestId('dropdown')); + await userEvent.click(screen.getByTestId('dropdown')); await wait(); expect(screen.getByText('Edit')).toBeInTheDocument(); expect(screen.getByText('Delete')).toBeInTheDocument(); @@ -347,14 +347,14 @@ describe('Testing PostCard Component [User Portal]', () => { ); await wait(); - userEvent.click(screen.getByTestId('dropdown')); - userEvent.click(screen.getByTestId('editPost')); + await userEvent.click(screen.getByTestId('dropdown')); + await userEvent.click(screen.getByTestId('editPost')); await wait(); expect(screen.getByTestId('editPostModalTitle')).toBeInTheDocument(); - userEvent.clear(screen.getByTestId('postInput')); - userEvent.type(screen.getByTestId('postInput'), 'Edited Post'); - userEvent.click(screen.getByTestId('editPostBtn')); + await userEvent.clear(screen.getByTestId('postInput')); + await userEvent.type(screen.getByTestId('postInput'), 'Edited Post'); + await userEvent.click(screen.getByTestId('editPostBtn')); await wait(); expect(toast.success).toHaveBeenCalledWith('Post updated Successfully'); @@ -403,8 +403,8 @@ describe('Testing PostCard Component [User Portal]', () => { ); await wait(); - userEvent.click(screen.getByTestId('dropdown')); - userEvent.click(screen.getByTestId('deletePost')); + await userEvent.click(screen.getByTestId('dropdown')); + await userEvent.click(screen.getByTestId('deletePost')); await wait(); expect(toast.success).toHaveBeenCalledWith( @@ -507,8 +507,8 @@ describe('Testing PostCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('viewPostBtn')); - userEvent.click(screen.getByTestId('likePostBtn')); + await userEvent.click(screen.getByTestId('viewPostBtn')); + await userEvent.click(screen.getByTestId('likePostBtn')); if (beforeUserId) { setItem('userId', beforeUserId); @@ -560,8 +560,8 @@ describe('Testing PostCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('viewPostBtn')); - userEvent.click(screen.getByTestId('likePostBtn')); + await userEvent.click(screen.getByTestId('viewPostBtn')); + await userEvent.click(screen.getByTestId('likePostBtn')); if (beforeUserId) { setItem('userId', beforeUserId); @@ -653,10 +653,10 @@ describe('Testing PostCard Component [User Portal]', () => { const randomComment = 'testComment'; - userEvent.click(screen.getByTestId('viewPostBtn')); + await userEvent.click(screen.getByTestId('viewPostBtn')); - userEvent.type(screen.getByTestId('commentInput'), randomComment); - userEvent.click(screen.getByTestId('createCommentBtn')); + await userEvent.type(screen.getByTestId('commentInput'), randomComment); + await userEvent.click(screen.getByTestId('createCommentBtn')); await wait(); }); @@ -856,9 +856,9 @@ describe('Testing PostCard Component [User Portal]', () => { , ); - userEvent.click(screen.getByTestId('viewPostBtn')); + await userEvent.click(screen.getByTestId('viewPostBtn')); - userEvent.click(screen.getAllByTestId('likeCommentBtn')[0]); + await userEvent.click(screen.getAllByTestId('likeCommentBtn')[0]); await wait(); @@ -943,9 +943,9 @@ describe('Testing PostCard Component [User Portal]', () => { , ); - userEvent.click(screen.getByTestId('viewPostBtn')); + await userEvent.click(screen.getByTestId('viewPostBtn')); - userEvent.click(screen.getAllByTestId('likeCommentBtn')[0]); + await userEvent.click(screen.getAllByTestId('likeCommentBtn')[0]); await wait(); @@ -995,7 +995,7 @@ describe('Testing PostCard Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('viewPostBtn')); + await userEvent.click(screen.getByTestId('viewPostBtn')); expect(screen.findAllByText('Comments')).not.toBeNull(); }); }); diff --git a/src/components/UserPortal/Register/Register.spec.tsx b/src/components/UserPortal/Register/Register.spec.tsx index d0d43ba3b8..b715804cf1 100644 --- a/src/components/UserPortal/Register/Register.spec.tsx +++ b/src/components/UserPortal/Register/Register.spec.tsx @@ -136,7 +136,7 @@ describe('Testing Register Component [User Portal]', () => { await waitForAsync(); - userEvent.click(screen.getByTestId('setLoginBtn')); + await userEvent.click(screen.getByTestId('setLoginBtn')); expect(setCurrentMode).toHaveBeenCalledWith('login'); }); @@ -156,7 +156,7 @@ describe('Testing Register Component [User Portal]', () => { await waitForAsync(); - userEvent.click(screen.getByTestId('registerBtn')); + await userEvent.click(screen.getByTestId('registerBtn')); expect(toast.error).toHaveBeenCalledWith('Please enter valid details.'); }); @@ -175,10 +175,8 @@ describe('Testing Register Component [User Portal]', () => { ); await waitForAsync(); - - userEvent.type(screen.getByTestId('emailInput'), formData.email); - userEvent.click(screen.getByTestId('registerBtn')); - + await userEvent.type(screen.getByTestId('emailInput'), formData.email); + await userEvent.click(screen.getByTestId('registerBtn')); expect(toast.error).toHaveBeenCalledWith('Please enter valid details.'); }); @@ -196,11 +194,12 @@ describe('Testing Register Component [User Portal]', () => { ); await waitForAsync(); - - userEvent.type(screen.getByTestId('passwordInput'), formData.password); - userEvent.type(screen.getByTestId('emailInput'), formData.email); - userEvent.click(screen.getByTestId('registerBtn')); - + await userEvent.type( + screen.getByTestId('passwordInput'), + formData.password, + ); + await userEvent.type(screen.getByTestId('emailInput'), formData.email); + await userEvent.click(screen.getByTestId('registerBtn')); expect(toast.error).toHaveBeenCalledWith('Please enter valid details.'); }); @@ -218,12 +217,18 @@ describe('Testing Register Component [User Portal]', () => { ); await waitForAsync(); + await userEvent.type( + screen.getByTestId('passwordInput'), + formData.password, + ); - userEvent.type(screen.getByTestId('passwordInput'), formData.password); - userEvent.type(screen.getByTestId('emailInput'), formData.email); - userEvent.type(screen.getByTestId('firstNameInput'), formData.firstName); - userEvent.click(screen.getByTestId('registerBtn')); + await userEvent.type(screen.getByTestId('emailInput'), formData.email); + await userEvent.type( + screen.getByTestId('firstNameInput'), + formData.firstName, + ); + await userEvent.click(screen.getByTestId('registerBtn')); expect(toast.error).toHaveBeenCalledWith('Please enter valid details.'); }); @@ -242,11 +247,24 @@ describe('Testing Register Component [User Portal]', () => { await waitForAsync(); - userEvent.type(screen.getByTestId('passwordInput'), formData.password); - userEvent.type(screen.getByTestId('emailInput'), formData.email); - userEvent.type(screen.getByTestId('firstNameInput'), formData.firstName); - userEvent.type(screen.getByTestId('lastNameInput'), formData.lastName); - userEvent.click(screen.getByTestId('registerBtn')); + await userEvent.type( + screen.getByTestId('passwordInput'), + formData.password, + ); + + await userEvent.type(screen.getByTestId('emailInput'), formData.email); + + await userEvent.type( + screen.getByTestId('firstNameInput'), + formData.firstName, + ); + + await userEvent.type( + screen.getByTestId('lastNameInput'), + formData.lastName, + ); + + await userEvent.click(screen.getByTestId('registerBtn')); expect(toast.error).toHaveBeenCalledWith( "Password doesn't match. Confirm Password and try again.", @@ -268,16 +286,29 @@ describe('Testing Register Component [User Portal]', () => { await waitForAsync(); - userEvent.type(screen.getByTestId('passwordInput'), formData.password); - userEvent.type( + await userEvent.type( + screen.getByTestId('passwordInput'), + formData.password, + ); + + await userEvent.type( screen.getByTestId('confirmPasswordInput'), formData.confirmPassword, ); - userEvent.type(screen.getByTestId('emailInput'), formData.email); - userEvent.type(screen.getByTestId('firstNameInput'), formData.firstName); - userEvent.type(screen.getByTestId('lastNameInput'), formData.lastName); - userEvent.click(screen.getByTestId('registerBtn')); + await userEvent.type(screen.getByTestId('emailInput'), formData.email); + + await userEvent.type( + screen.getByTestId('firstNameInput'), + formData.firstName, + ); + + await userEvent.type( + screen.getByTestId('lastNameInput'), + formData.lastName, + ); + + await userEvent.click(screen.getByTestId('registerBtn')); await waitForAsync(); expect(toast.success).toHaveBeenCalledWith( @@ -298,17 +329,18 @@ describe('Testing Register Component [User Portal]', () => { , ); - await waitForAsync(); // Fill out the form with error-triggering values - userEvent.type(screen.getByTestId('passwordInput'), 'password'); - userEvent.type(screen.getByTestId('confirmPasswordInput'), 'password'); - userEvent.type(screen.getByTestId('emailInput'), 'error@test.com'); - userEvent.type(screen.getByTestId('firstNameInput'), 'Error'); - userEvent.type(screen.getByTestId('lastNameInput'), 'Test'); - userEvent.click(screen.getByTestId('registerBtn')); - + await userEvent.type(screen.getByTestId('passwordInput'), 'password'); + await userEvent.type( + screen.getByTestId('confirmPasswordInput'), + 'password', + ); + await userEvent.type(screen.getByTestId('emailInput'), 'error@test.com'); + await userEvent.type(screen.getByTestId('firstNameInput'), 'Error'); + await userEvent.type(screen.getByTestId('lastNameInput'), 'Test'); + await userEvent.click(screen.getByTestId('registerBtn')); await waitForAsync(); // Assert that toast.error is called with the error message diff --git a/src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx b/src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx index fb33e3c1eb..fe18123fe6 100644 --- a/src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx +++ b/src/components/UserPortal/StartPostModal/StartPostModal.spec.tsx @@ -130,7 +130,7 @@ describe('Testing StartPostModal Component: User Portal', () => { renderStartPostModal(true, null); await wait(); - userEvent.click(screen.getByTestId('createPostBtn')); + await userEvent.click(screen.getByTestId('createPostBtn')); expect(toastSpy).toHaveBeenCalledWith( "Can't create a post with an empty body.", ); @@ -141,10 +141,10 @@ describe('Testing StartPostModal Component: User Portal', () => { await wait(); const randomPostInput = 'This is dummy text'; - userEvent.type(screen.getByTestId('postInput'), randomPostInput); + await userEvent.type(screen.getByTestId('postInput'), randomPostInput); expect(screen.queryByText(randomPostInput)).toBeInTheDocument(); - userEvent.click(screen.getByTestId('createPostBtn')); + await userEvent.click(screen.getByTestId('createPostBtn')); expect(toast.error).not.toHaveBeenCalled(); expect(toast.info).toHaveBeenCalledWith( @@ -185,10 +185,10 @@ describe('Testing StartPostModal Component: User Portal', () => { await wait(); const input = screen.getByTestId('postInput'); - userEvent.type(input, 'Test content'); + await userEvent.type(input, 'Test content'); const closeButton = screen.getByRole('button', { name: /close/i }); - userEvent.click(closeButton); + await userEvent.click(closeButton); expect(onHideMock).toHaveBeenCalled(); expect(input).toHaveValue(''); @@ -229,8 +229,8 @@ describe('Testing StartPostModal Component: User Portal', () => { ); await wait(); - userEvent.type(screen.getByTestId('postInput'), 'Test content'); - userEvent.click(screen.getByTestId('createPostBtn')); + await userEvent.type(screen.getByTestId('postInput'), 'Test content'); + await userEvent.click(screen.getByTestId('createPostBtn')); await wait(); @@ -260,8 +260,8 @@ describe('Testing StartPostModal Component: User Portal', () => { renderStartPostModal(true, null, null, vi.fn(), vi.fn(), customLink); await wait(); - userEvent.type(screen.getByTestId('postInput'), 'Test content'); - userEvent.click(screen.getByTestId('createPostBtn')); + await userEvent.type(screen.getByTestId('postInput'), 'Test content'); + await userEvent.click(screen.getByTestId('createPostBtn')); await wait(); diff --git a/src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx b/src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx index 0e00645c1f..8ba81ef055 100644 --- a/src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx +++ b/src/components/UserPortal/UserNavbar/UserNavbar.spec.tsx @@ -86,9 +86,9 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn0')); + await userEvent.click(screen.getByTestId('changeLanguageBtn0')); await wait(); @@ -110,9 +110,9 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn1')); + await userEvent.click(screen.getByTestId('changeLanguageBtn1')); await wait(); @@ -134,9 +134,9 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn2')); + await userEvent.click(screen.getByTestId('changeLanguageBtn2')); await wait(); @@ -158,9 +158,9 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn3')); + await userEvent.click(screen.getByTestId('changeLanguageBtn3')); await wait(); @@ -182,9 +182,9 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('languageIcon')); + await userEvent.click(screen.getByTestId('languageIcon')); - userEvent.click(screen.getByTestId('changeLanguageBtn4')); + await userEvent.click(screen.getByTestId('changeLanguageBtn4')); await wait(); @@ -206,7 +206,7 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('logoutDropdown')); + await userEvent.click(screen.getByTestId('logoutDropdown')); expect(screen.getByText('Settings')).toBeInTheDocument(); expect(screen.getByTestId('logoutBtn')).toBeInTheDocument(); }); @@ -226,8 +226,8 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('logoutDropdown')); - userEvent.click(screen.getByText('Settings')); + await userEvent.click(screen.getByTestId('logoutDropdown')); + await userEvent.click(screen.getByText('Settings')); expect(window.location.pathname).toBe('/user/settings'); }); it('Logs out the user and clears local storage', async () => { @@ -247,8 +247,8 @@ describe('Testing UserNavbar Component [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('logoutDropdown')); - userEvent.click(screen.getByTestId('logoutBtn')); + await userEvent.click(screen.getByTestId('logoutDropdown')); + await userEvent.click(screen.getByTestId('logoutBtn')); await wait(); diff --git a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.spec.tsx b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.spec.tsx index f26997f572..bcfa7d8b75 100644 --- a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.spec.tsx +++ b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.spec.tsx @@ -327,7 +327,7 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => { , ); await wait(); - userEvent.click(screen.getByText('People')); + await userEvent.click(screen.getByText('People')); expect(global.window.location.pathname).toContain('/user/people/123'); }); @@ -349,7 +349,7 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => { expect(screen.getAllByText(/People/i)[0]).toBeInTheDocument(); const peopelBtn = screen.getByTestId(/People/i); - userEvent.click(peopelBtn); + await userEvent.click(peopelBtn); await wait(); expect(window.location.pathname).toContain('user/people/123'); }); diff --git a/src/components/UsersTableItem/UserTableItem.spec.tsx b/src/components/UsersTableItem/UserTableItem.spec.tsx index a0b0c39c86..c551ceb4dc 100644 --- a/src/components/UsersTableItem/UserTableItem.spec.tsx +++ b/src/components/UsersTableItem/UserTableItem.spec.tsx @@ -1315,9 +1315,9 @@ describe('Testing User Table Item', () => { `changeRoleInOrg${'abc'}`, ) as HTMLSelectElement; expect(changeRoleBtn).toBeInTheDocument(); - userEvent.selectOptions(changeRoleBtn, 'ADMIN'); + await userEvent.selectOptions(changeRoleBtn, 'ADMIN'); await wait(); - userEvent.selectOptions(changeRoleBtn, 'USER'); + await userEvent.selectOptions(changeRoleBtn, 'USER'); await wait(); expect(changeRoleBtn.value).toBe(`USER?abc`); await wait(); diff --git a/src/components/Venues/VenueModal.spec.tsx b/src/components/Venues/VenueModal.spec.tsx index c840b6de53..3f9a43b162 100644 --- a/src/components/Venues/VenueModal.spec.tsx +++ b/src/components/Venues/VenueModal.spec.tsx @@ -177,7 +177,7 @@ describe('VenueModal', () => { const file = new File(['chad'], 'chad.png', { type: 'image/png' }); const fileInput = screen.getByTestId('venueImgUrl'); - userEvent.upload(fileInput, file); + await userEvent.upload(fileInput, file); await wait(); @@ -190,7 +190,7 @@ describe('VenueModal', () => { const file = new File(['chad'], 'chad.png', { type: 'image/png' }); const fileInput = screen.getByTestId('venueImgUrl'); - userEvent.upload(fileInput, file); + await userEvent.upload(fileInput, file); await wait(); diff --git a/src/screens/BlockUser/BlockUser.spec.tsx b/src/screens/BlockUser/BlockUser.spec.tsx index 6f787ce71d..c0aaafc4d6 100644 --- a/src/screens/BlockUser/BlockUser.spec.tsx +++ b/src/screens/BlockUser/BlockUser.spec.tsx @@ -352,14 +352,14 @@ describe('Testing Block/Unblock user screen', () => { , ); - userEvent.click(screen.getByTestId('userFilter')); - userEvent.click(screen.getByTestId('allMembers')); + await userEvent.click(screen.getByTestId('userFilter')); + await userEvent.click(screen.getByTestId('allMembers')); await wait(); expect(screen.getByTestId('unBlockUser123')).toBeInTheDocument(); expect(screen.getByTestId('blockUser456')).toBeInTheDocument(); - userEvent.click(screen.getByTestId('unBlockUser123')); + await userEvent.click(screen.getByTestId('unBlockUser123')); await wait(); expect(screen.getByTestId('blockUser123')).toBeInTheDocument(); @@ -382,15 +382,15 @@ describe('Testing Block/Unblock user screen', () => { , ); - userEvent.click(screen.getByTestId('userFilter')); - userEvent.click(screen.getByTestId('allMembers')); + await userEvent.click(screen.getByTestId('userFilter')); + await userEvent.click(screen.getByTestId('allMembers')); await wait(); expect(screen.getByTestId('unBlockUser123')).toBeInTheDocument(); expect(screen.getByTestId('blockUser456')).toBeInTheDocument(); - userEvent.click(screen.getByTestId('blockUser456')); + await userEvent.click(screen.getByTestId('blockUser456')); await wait(); expect(screen.getByTestId('blockUser123')).toBeInTheDocument(); @@ -414,26 +414,26 @@ describe('Testing Block/Unblock user screen', () => { , ); - userEvent.click(screen.getByTestId('userFilter')); - userEvent.click(screen.getByTestId('blockedUsers')); + await userEvent.click(screen.getByTestId('userFilter')); + await userEvent.click(screen.getByTestId('blockedUsers')); await wait(); expect(screen.getByText('John Doe')).toBeInTheDocument(); expect(screen.queryByText('Sam Smith')).not.toBeInTheDocument(); - userEvent.click(screen.getByTestId('userFilter')); - userEvent.click(screen.getByTestId('allMembers')); + await userEvent.click(screen.getByTestId('userFilter')); + await userEvent.click(screen.getByTestId('allMembers')); await wait(); expect(screen.getByText('John Doe')).toBeInTheDocument(); expect(screen.getByText('Sam Smith')).toBeInTheDocument(); // Open Dropdown - userEvent.click(screen.getByTestId('nameFilter')); + await userEvent.click(screen.getByTestId('nameFilter')); // Select option and enter first name - userEvent.click(screen.getByTestId('searchByFirstName')); + await userEvent.click(screen.getByTestId('searchByFirstName')); const firstNameInput = screen.getByPlaceholderText(/Search by First Name/i); - userEvent.type(firstNameInput, 'john{enter}'); + await userEvent.type(firstNameInput, 'john{enter}'); await wait(700); @@ -458,19 +458,19 @@ describe('Testing Block/Unblock user screen', () => { , ); - userEvent.click(screen.getByTestId('userFilter')); - userEvent.click(screen.getByTestId('allMembers')); + await userEvent.click(screen.getByTestId('userFilter')); + await userEvent.click(screen.getByTestId('allMembers')); await wait(); expect(screen.getByText('John Doe')).toBeInTheDocument(); expect(screen.getByText('Sam Smith')).toBeInTheDocument(); // Open Dropdown - userEvent.click(screen.getByTestId('nameFilter')); + await userEvent.click(screen.getByTestId('nameFilter')); // Select option and enter first name - userEvent.click(screen.getByTestId('searchByLastName')); + await userEvent.click(screen.getByTestId('searchByLastName')); const firstNameInput = screen.getByPlaceholderText(/Search by Last Name/i); - userEvent.type(firstNameInput, 'doe{enter}'); + await userEvent.type(firstNameInput, 'doe{enter}'); await wait(700); @@ -481,15 +481,15 @@ describe('Testing Block/Unblock user screen', () => { const searchBar = screen.getByTestId(/searchByName/i); const searchBtn = screen.getByTestId(/searchBtn/i); expect(searchBar).toBeInTheDocument(); - userEvent.type(searchBar, 'Dummy{enter}'); + await userEvent.type(searchBar, 'Dummy{enter}'); await wait(); - userEvent.clear(searchBar); - userEvent.type(searchBar, 'Dummy'); - userEvent.click(searchBtn); + await userEvent.clear(searchBar); + await userEvent.type(searchBar, 'Dummy'); + await userEvent.click(searchBtn); await wait(); - userEvent.clear(searchBar); - userEvent.type(searchBar, ''); - userEvent.click(searchBtn); + await userEvent.clear(searchBar); + await userEvent.type(searchBar, ''); + await userEvent.click(searchBtn); }); test('Testing Error while mutation from server side', async () => { @@ -507,15 +507,15 @@ describe('Testing Block/Unblock user screen', () => { , ); - userEvent.click(screen.getByTestId('userFilter')); - userEvent.click(screen.getByTestId('allMembers')); + await userEvent.click(screen.getByTestId('userFilter')); + await userEvent.click(screen.getByTestId('allMembers')); await wait(); - userEvent.click(screen.getByTestId('blockUser456')); + await userEvent.click(screen.getByTestId('blockUser456')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); }); - userEvent.click(screen.getByTestId('unBlockUser123')); + await userEvent.click(screen.getByTestId('unBlockUser123')); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); }); diff --git a/src/screens/CommunityProfile/CommunityProfile.spec.tsx b/src/screens/CommunityProfile/CommunityProfile.spec.tsx index 1cfb70a2cd..f1610ee648 100644 --- a/src/screens/CommunityProfile/CommunityProfile.spec.tsx +++ b/src/screens/CommunityProfile/CommunityProfile.spec.tsx @@ -373,17 +373,17 @@ describe('Testing Community Profile Screen', () => { const saveChangesBtn = screen.getByTestId(/saveChangesBtn/i); const resetChangeBtn = screen.getByTestId(/resetChangesBtn/i); - userEvent.type(communityName, profileVariables.name); - userEvent.type(websiteLink, profileVariables.websiteLink); - userEvent.type(facebook, profileVariables.socialUrl); - userEvent.type(instagram, profileVariables.socialUrl); - userEvent.type(X, profileVariables.socialUrl); - userEvent.type(linkedIn, profileVariables.socialUrl); - userEvent.type(github, profileVariables.socialUrl); - userEvent.type(youtube, profileVariables.socialUrl); - userEvent.type(reddit, profileVariables.socialUrl); - userEvent.type(slack, profileVariables.socialUrl); - userEvent.upload(logo, profileVariables.logo); + await userEvent.type(communityName, profileVariables.name); + await userEvent.type(websiteLink, profileVariables.websiteLink); + await userEvent.type(facebook, profileVariables.socialUrl); + await userEvent.type(instagram, profileVariables.socialUrl); + await userEvent.type(X, profileVariables.socialUrl); + await userEvent.type(linkedIn, profileVariables.socialUrl); + await userEvent.type(github, profileVariables.socialUrl); + await userEvent.type(youtube, profileVariables.socialUrl); + await userEvent.type(reddit, profileVariables.socialUrl); + await userEvent.type(slack, profileVariables.socialUrl); + await userEvent.upload(logo, profileVariables.logo); await wait(); expect(communityName).toHaveValue(profileVariables.name); @@ -401,7 +401,7 @@ describe('Testing Community Profile Screen', () => { expect(resetChangeBtn).not.toBeDisabled(); await wait(); - userEvent.click(saveChangesBtn); + await userEvent.click(saveChangesBtn); await wait(); }); @@ -438,7 +438,7 @@ describe('Testing Community Profile Screen', () => { await wait(); const resetChangesBtn = screen.getByTestId('resetChangesBtn'); - userEvent.click(resetChangesBtn); + await userEvent.click(resetChangesBtn); await wait(); expect(screen.getByPlaceholderText(/Community Name/i)).toHaveValue(''); diff --git a/src/screens/EventManagement/EventManagement.spec.tsx b/src/screens/EventManagement/EventManagement.spec.tsx index 49b50e4b36..bb8ea5b058 100644 --- a/src/screens/EventManagement/EventManagement.spec.tsx +++ b/src/screens/EventManagement/EventManagement.spec.tsx @@ -83,7 +83,7 @@ describe('Event Management', () => { renderEventManagement(); const backButton = screen.getByTestId('backBtn'); - userEvent.click(backButton); + await userEvent.click(backButton); await waitFor(() => { const eventsScreen = screen.getByTestId('eventsScreen'); expect(eventsScreen).toBeInTheDocument(); @@ -97,7 +97,7 @@ describe('Event Management', () => { renderEventManagement(); const backButton = screen.getByTestId('backBtn'); - userEvent.click(backButton); + await userEvent.click(backButton); await waitFor(() => { const userEventsScreen = screen.getByTestId('userEventsScreen'); @@ -112,7 +112,7 @@ describe('Event Management', () => { renderEventManagement(); const backButton = screen.getByTestId('backBtn'); - userEvent.click(backButton); + await userEvent.click(backButton); await waitFor(() => { const eventsScreen = screen.getByTestId('eventsScreen'); @@ -157,7 +157,7 @@ describe('Event Management', () => { ]; for (const { button, tab } of tabsToTest) { - userEvent.click(screen.getByTestId(button)); + await userEvent.click(screen.getByTestId(button)); expect(screen.getByTestId(tab)).toBeInTheDocument(); } }); @@ -203,7 +203,7 @@ describe('Event Management', () => { expect(dropdownContainer).toBeInTheDocument(); await act(async () => { - userEvent.click(screen.getByTestId('tabsDropdownToggle')); + await userEvent.click(screen.getByTestId('tabsDropdownToggle')); }); const tabOptions = [ @@ -226,7 +226,7 @@ describe('Event Management', () => { renderEventManagement(); }); await act(async () => { - userEvent.click(screen.getByTestId('tabsDropdownToggle')); + await userEvent.click(screen.getByTestId('tabsDropdownToggle')); }); const tabOptions = [ @@ -240,8 +240,8 @@ describe('Event Management', () => { ]; for (const option of tabOptions) { - act(() => { - userEvent.click(screen.getByTestId(`${option}DropdownItem`)); + await act(async () => { + await userEvent.click(screen.getByTestId(`${option}DropdownItem`)); }); expect(screen.getByTestId(`${option}DropdownItem`)).toHaveClass( diff --git a/src/screens/EventVolunteers/Requests/Requests.spec.tsx b/src/screens/EventVolunteers/Requests/Requests.spec.tsx index e51e28ab3f..477980b19a 100644 --- a/src/screens/EventVolunteers/Requests/Requests.spec.tsx +++ b/src/screens/EventVolunteers/Requests/Requests.spec.tsx @@ -158,7 +158,7 @@ describe('Testing Requests Screen', () => { expect(searchInput).toBeInTheDocument(); // Search by name on press of ENTER - userEvent.type(searchInput, 'T'); + await userEvent.type(searchInput, 'T'); await debounceWait(); await waitFor(() => { @@ -194,7 +194,7 @@ describe('Testing Requests Screen', () => { expect(acceptBtn).toHaveLength(2); // Accept Request - userEvent.click(acceptBtn[0]); + await userEvent.click(acceptBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.requestAccepted); @@ -211,7 +211,7 @@ describe('Testing Requests Screen', () => { expect(rejectBtn).toHaveLength(2); // Reject Request - userEvent.click(rejectBtn[0]); + await userEvent.click(rejectBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.requestRejected); @@ -228,7 +228,7 @@ describe('Testing Requests Screen', () => { expect(acceptBtn).toHaveLength(2); // Accept Request - userEvent.click(acceptBtn[0]); + await userEvent.click(acceptBtn[0]); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupDeleteModal.spec.tsx b/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupDeleteModal.spec.tsx index 8e726028db..33635146e0 100644 --- a/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupDeleteModal.spec.tsx +++ b/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupDeleteModal.spec.tsx @@ -111,7 +111,7 @@ describe('Testing Group Delete Modal', () => { const yesBtn = screen.getByTestId('deleteyesbtn'); expect(yesBtn).toBeInTheDocument(); - userEvent.click(yesBtn); + await userEvent.click(yesBtn); await waitFor(() => { expect(itemProps[0].refetchGroups).toHaveBeenCalled(); @@ -126,7 +126,7 @@ describe('Testing Group Delete Modal', () => { const noBtn = screen.getByTestId('deletenobtn'); expect(noBtn).toBeInTheDocument(); - userEvent.click(noBtn); + await userEvent.click(noBtn); await waitFor(() => { expect(itemProps[0].hide).toHaveBeenCalled(); @@ -139,7 +139,7 @@ describe('Testing Group Delete Modal', () => { const yesBtn = screen.getByTestId('deleteyesbtn'); expect(yesBtn).toBeInTheDocument(); - userEvent.click(yesBtn); + await userEvent.click(yesBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupModal.spec.tsx b/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupModal.spec.tsx index 79b1d94545..d0a6e9296d 100644 --- a/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupModal.spec.tsx +++ b/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroupModal.spec.tsx @@ -196,7 +196,7 @@ describe('Testing VolunteerGroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.volunteerGroupCreated); @@ -246,7 +246,7 @@ describe('Testing VolunteerGroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -274,7 +274,7 @@ describe('Testing VolunteerGroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.volunteerGroupUpdated); @@ -304,7 +304,7 @@ describe('Testing VolunteerGroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -323,8 +323,8 @@ describe('Testing VolunteerGroupModal', () => { expect(vrInput).toHaveValue(''); }); - userEvent.clear(vrInput); - userEvent.type(vrInput, '1{backspace}'); + await userEvent.clear(vrInput); + await userEvent.type(vrInput, '1{backspace}'); await waitFor(() => { expect(vrInput).toHaveValue(''); @@ -347,7 +347,7 @@ describe('Testing VolunteerGroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.success).toHaveBeenCalled(); diff --git a/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroups.spec.tsx b/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroups.spec.tsx index 2ce6e6a9dd..e0ca5c476e 100644 --- a/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroups.spec.tsx +++ b/src/screens/EventVolunteers/VolunteerGroups/VolunteerGroups.spec.tsx @@ -154,13 +154,13 @@ describe('Testing VolunteerGroups Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expect(searchToggle).toBeInTheDocument(); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByGroup = await screen.findByTestId('group'); expect(searchByGroup).toBeInTheDocument(); - userEvent.click(searchByGroup); + await userEvent.click(searchByGroup); - userEvent.type(searchInput, '1'); + await userEvent.type(searchInput, '1'); await debounceWait(); const groupName = await screen.findAllByTestId('groupName'); @@ -175,14 +175,14 @@ describe('Testing VolunteerGroups Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expect(searchToggle).toBeInTheDocument(); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByLeader = await screen.findByTestId('leader'); expect(searchByLeader).toBeInTheDocument(); - userEvent.click(searchByLeader); + await userEvent.click(searchByLeader); // Search by name on press of ENTER - userEvent.type(searchInput, 'Bruce'); + await userEvent.type(searchInput, 'Bruce'); await debounceWait(); const groupName = await screen.findAllByTestId('groupName'); @@ -213,10 +213,12 @@ describe('Testing VolunteerGroups Screen', () => { renderVolunteerGroups(link1); const viewGroupBtn = await screen.findAllByTestId('viewGroupBtn'); - userEvent.click(viewGroupBtn[0]); + await userEvent.click(viewGroupBtn[0]); expect(await screen.findByText(t.groupDetails)).toBeInTheDocument(); - userEvent.click(await screen.findByTestId('volunteerViewModalCloseBtn')); + await userEvent.click( + await screen.findByTestId('volunteerViewModalCloseBtn'), + ); }); it('Open and Close Delete Modal', async () => { @@ -224,10 +226,10 @@ describe('Testing VolunteerGroups Screen', () => { renderVolunteerGroups(link1); const deleteGroupBtn = await screen.findAllByTestId('deleteGroupBtn'); - userEvent.click(deleteGroupBtn[0]); + await userEvent.click(deleteGroupBtn[0]); expect(await screen.findByText(t.deleteGroup)).toBeInTheDocument(); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); it('Open and close GroupModal (Edit)', async () => { @@ -235,10 +237,10 @@ describe('Testing VolunteerGroups Screen', () => { renderVolunteerGroups(link1); const editGroupBtn = await screen.findAllByTestId('editGroupBtn'); - userEvent.click(editGroupBtn[0]); + await userEvent.click(editGroupBtn[0]); expect(await screen.findAllByText(t.updateGroup)).toHaveLength(2); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); it('Open and close GroupModal (Create)', async () => { @@ -246,9 +248,9 @@ describe('Testing VolunteerGroups Screen', () => { renderVolunteerGroups(link1); const createGroupBtn = await screen.findByTestId('createGroupBtn'); - userEvent.click(createGroupBtn); + await userEvent.click(createGroupBtn); expect(await screen.findAllByText(t.createGroup)).toHaveLength(2); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); }); diff --git a/src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx b/src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx index 77fe028655..5d5df73cc1 100644 --- a/src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx +++ b/src/screens/EventVolunteers/Volunteers/VolunteerCreateModal.spec.tsx @@ -95,7 +95,7 @@ describe('Testing VolunteerCreateModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.volunteerAdded); @@ -120,7 +120,7 @@ describe('Testing VolunteerCreateModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/screens/EventVolunteers/Volunteers/VolunteerDeleteModal.spec.tsx b/src/screens/EventVolunteers/Volunteers/VolunteerDeleteModal.spec.tsx index 575670a887..07cf5dcab3 100644 --- a/src/screens/EventVolunteers/Volunteers/VolunteerDeleteModal.spec.tsx +++ b/src/screens/EventVolunteers/Volunteers/VolunteerDeleteModal.spec.tsx @@ -99,7 +99,7 @@ describe('Testing Volunteer Delete Modal', () => { const yesBtn = screen.getByTestId('deleteyesbtn'); expect(yesBtn).toBeInTheDocument(); - userEvent.click(yesBtn); + await userEvent.click(yesBtn); await waitFor(() => { expect(itemProps[0].refetchVolunteers).toHaveBeenCalled(); @@ -114,7 +114,7 @@ describe('Testing Volunteer Delete Modal', () => { const noBtn = screen.getByTestId('deletenobtn'); expect(noBtn).toBeInTheDocument(); - userEvent.click(noBtn); + await userEvent.click(noBtn); await waitFor(() => { expect(itemProps[0].hide).toHaveBeenCalled(); @@ -127,7 +127,7 @@ describe('Testing Volunteer Delete Modal', () => { const yesBtn = screen.getByTestId('deleteyesbtn'); expect(yesBtn).toBeInTheDocument(); - userEvent.click(yesBtn); + await userEvent.click(yesBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx b/src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx index cc3291274a..7a2e5dbeea 100644 --- a/src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx +++ b/src/screens/EventVolunteers/Volunteers/Volunteers.spec.tsx @@ -221,7 +221,7 @@ describe('Testing Volunteers Screen', () => { const searchInput = await screen.findByTestId('searchBy'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'T'); + await userEvent.type(searchInput, 'T'); await debounceWait(); const volunteerName = await screen.findAllByTestId('volunteerName'); @@ -261,10 +261,10 @@ describe('Testing Volunteers Screen', () => { renderVolunteers(link1); const viewItemBtn = await screen.findAllByTestId('viewItemBtn'); - userEvent.click(viewItemBtn[0]); + await userEvent.click(viewItemBtn[0]); expect(await screen.findByText(t.volunteerDetails)).toBeInTheDocument(); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); it('Open and Close Volunteer Modal (Delete)', async () => { @@ -275,10 +275,10 @@ describe('Testing Volunteers Screen', () => { renderVolunteers(link1); const deleteItemBtn = await screen.findAllByTestId('deleteItemBtn'); - userEvent.click(deleteItemBtn[0]); + await userEvent.click(deleteItemBtn[0]); expect(await screen.findByText(t.removeVolunteer)).toBeInTheDocument(); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); it('Open and close Volunteer Modal (Create)', async () => { @@ -289,9 +289,9 @@ describe('Testing Volunteers Screen', () => { renderVolunteers(link1); const addVolunteerBtn = await screen.findByTestId('addVolunteerBtn'); - userEvent.click(addVolunteerBtn); + await userEvent.click(addVolunteerBtn); expect(await screen.findAllByText(t.addVolunteer)).toHaveLength(2); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); }); diff --git a/src/screens/ForgotPassword/ForgotPassword.spec.tsx b/src/screens/ForgotPassword/ForgotPassword.spec.tsx index 6c534905e1..7f3259ceb1 100644 --- a/src/screens/ForgotPassword/ForgotPassword.spec.tsx +++ b/src/screens/ForgotPassword/ForgotPassword.spec.tsx @@ -178,12 +178,12 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await waitFor(() => { expect(toast.success).toHaveBeenCalled(); }); @@ -211,22 +211,28 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await wait(); - userEvent.type(screen.getByPlaceholderText('e.g. 12345'), formData.userOtp); - userEvent.type(screen.getByTestId('newPassword'), formData.newPassword); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText('e.g. 12345'), + formData.userOtp, + ); + await userEvent.type( + screen.getByTestId('newPassword'), + formData.newPassword, + ); + await userEvent.type( screen.getByTestId('confirmNewPassword'), formData.confirmNewPassword, ); setItem('otpToken', 'lorem ipsum'); - userEvent.click(screen.getByText('Change Password')); + await userEvent.click(screen.getByText('Change Password')); await wait(); }); @@ -252,22 +258,28 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await wait(); - userEvent.type(screen.getByPlaceholderText('e.g. 12345'), formData.userOtp); - userEvent.type(screen.getByTestId('newPassword'), formData.newPassword); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText('e.g. 12345'), + formData.userOtp, + ); + await userEvent.type( + screen.getByTestId('newPassword'), + formData.newPassword, + ); + await userEvent.type( screen.getByTestId('confirmNewPassword'), formData.confirmNewPassword, ); removeItem('otpToken'); - userEvent.click(screen.getByText('Change Password')); + await userEvent.click(screen.getByText('Change Password')); await wait(); }); @@ -293,22 +305,28 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await wait(); - userEvent.type(screen.getByPlaceholderText('e.g. 12345'), formData.userOtp); - userEvent.type(screen.getByTestId('newPassword'), formData.newPassword); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText('e.g. 12345'), + formData.userOtp, + ); + await userEvent.type( + screen.getByTestId('newPassword'), + formData.newPassword, + ); + await userEvent.type( screen.getByTestId('confirmNewPassword'), formData.confirmNewPassword, ); - userEvent.click(screen.getByText('Change Password')); + await userEvent.click(screen.getByText('Change Password')); }); it('Testing forgot password functionality, when the user is not found', async () => { @@ -330,12 +348,12 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await waitFor(() => { expect(toast.warn).toHaveBeenCalledWith(translations.emailNotRegistered); }); @@ -353,7 +371,7 @@ describe('Testing Forgot Password screen', () => { , ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith(translations.errorSendingMail); }); @@ -377,11 +395,11 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith( translations.talawaApiUnavailable, @@ -413,20 +431,26 @@ describe('Testing Forgot Password screen', () => { await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Registered email/i), formData.email, ); - userEvent.click(screen.getByText('Get OTP')); + await userEvent.click(screen.getByText('Get OTP')); await wait(); - userEvent.type(screen.getByPlaceholderText('e.g. 12345'), formData.userOtp); - userEvent.type(screen.getByTestId('newPassword'), formData.newPassword); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText('e.g. 12345'), + formData.userOtp, + ); + await userEvent.type( + screen.getByTestId('newPassword'), + formData.newPassword, + ); + await userEvent.type( screen.getByTestId('confirmNewPassword'), formData.confirmNewPassword, ); - userEvent.click(screen.getByText('Change Password')); + await userEvent.click(screen.getByText('Change Password')); }); }); diff --git a/src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx b/src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx index 3e6ecb74ae..61690e2d39 100644 --- a/src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx +++ b/src/screens/FundCampaignPledge/FundCampaignPledge.spec.tsx @@ -135,12 +135,12 @@ describe('Testing Campaign Pledge Screen', () => { const addPledgeBtn = await screen.findByTestId('addPledgeBtn'); expect(addPledgeBtn).toBeInTheDocument(); - userEvent.click(addPledgeBtn); + await userEvent.click(addPledgeBtn); await waitFor(() => expect(screen.getAllByText(translations.createPledge)).toHaveLength(2), ); - userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); + await userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('pledgeModalCloseBtn')).toBeNull(), ); @@ -151,12 +151,12 @@ describe('Testing Campaign Pledge Screen', () => { const editPledgeBtn = await screen.findAllByTestId('editPledgeBtn'); await waitFor(() => expect(editPledgeBtn[0]).toBeInTheDocument()); - userEvent.click(editPledgeBtn[0]); + await userEvent.click(editPledgeBtn[0]); await waitFor(() => expect(screen.getByText(translations.editPledge)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); + await userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('pledgeModalCloseBtn')).toBeNull(), ); @@ -167,12 +167,12 @@ describe('Testing Campaign Pledge Screen', () => { const deletePledgeBtn = await screen.findAllByTestId('deletePledgeBtn'); await waitFor(() => expect(deletePledgeBtn[0]).toBeInTheDocument()); - userEvent.click(deletePledgeBtn[0]); + await userEvent.click(deletePledgeBtn[0]); await waitFor(() => expect(screen.getByText(translations.deletePledge)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('deletePledgeCloseBtn')); + await userEvent.click(screen.getByTestId('deletePledgeCloseBtn')); await waitFor(() => expect(screen.queryByTestId('deletePledgeCloseBtn')).toBeNull(), ); @@ -241,7 +241,7 @@ describe('Testing Campaign Pledge Screen', () => { expect(screen.queryByText('John Doe4')).toBeNull(); const moreContainer = await screen.findAllByTestId('moreContainer'); - userEvent.click(moreContainer[0]); + await userEvent.click(moreContainer[0]); await waitFor(() => { expect(screen.getByText('John Doe3')).toBeInTheDocument(); @@ -254,7 +254,7 @@ describe('Testing Campaign Pledge Screen', () => { expect(image).toHaveAttribute('src', 'img-url3'); }); - userEvent.click(moreContainer[0]); + await userEvent.click(moreContainer[0]); await waitFor(() => { expect(screen.queryByText('John Doe3')).toBeNull(); expect(screen.queryByText('John Doe4')).toBeNull(); @@ -271,14 +271,14 @@ describe('Testing Campaign Pledge Screen', () => { expect(pledged).toBeInTheDocument(); expect(raised).toBeInTheDocument(); - userEvent.click(raised); + await userEvent.click(raised); await waitFor(() => { expect(screen.getByTestId('progressBar')).toBeInTheDocument(); expect(screen.getByTestId('progressBar')).toHaveTextContent('$0'); }); - userEvent.click(pledged); + await userEvent.click(pledged); await waitFor(() => { expect(screen.getByTestId('progressBar')).toBeInTheDocument(); diff --git a/src/screens/Leaderboard/Leaderboard.spec.tsx b/src/screens/Leaderboard/Leaderboard.spec.tsx index 3ef73835a6..0799178e55 100644 --- a/src/screens/Leaderboard/Leaderboard.spec.tsx +++ b/src/screens/Leaderboard/Leaderboard.spec.tsx @@ -254,7 +254,7 @@ describe('Testing Leaderboard Screen', () => { expect(searchInput).toBeInTheDocument(); // Search by name on press of ENTER - userEvent.type(searchInput, 'T'); + await userEvent.type(searchInput, 'T'); await debounceWait(); await waitFor(() => { @@ -271,7 +271,7 @@ describe('Testing Leaderboard Screen', () => { expect(searchInput).toBeInTheDocument(); const userName = screen.getAllByTestId('userName'); - userEvent.click(userName[0]); + await userEvent.click(userName[0]); await waitFor(() => { expect(screen.getByTestId('memberScreen')).toBeInTheDocument(); diff --git a/src/screens/LoginPage/LoginPage.spec.tsx b/src/screens/LoginPage/LoginPage.spec.tsx index 242f00f2b2..d6754c0c7d 100644 --- a/src/screens/LoginPage/LoginPage.spec.tsx +++ b/src/screens/LoginPage/LoginPage.spec.tsx @@ -303,7 +303,7 @@ describe('Testing Login Page Screen', () => { await wait(); const adminLink = screen.getByText(/Admin/i); - userEvent.click(adminLink); + await userEvent.click(adminLink); await wait(); expect(screen.getByText(/Admin/i)).toBeInTheDocument(); expect(window.location.pathname).toBe('/orglist'); @@ -377,26 +377,29 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Last name/i), formData.lastName, ); - userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); - userEvent.type(screen.getByPlaceholderText('Password'), formData.password); - userEvent.type( + await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); + await userEvent.type( + screen.getByPlaceholderText('Password'), + formData.password, + ); + await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword, ); - userEvent.click(screen.getByTestId('registrationBtn')); + await userEvent.click(screen.getByTestId('registrationBtn')); }); it('Testing registration functionality when all inputs are invalid', async () => { @@ -422,25 +425,28 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Last name/i), formData.lastName, ); - userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); - userEvent.type(screen.getByPlaceholderText('Password'), formData.password); - userEvent.type( + await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); + await userEvent.type( + screen.getByPlaceholderText('Password'), + formData.password, + ); + await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword, ); - userEvent.click(screen.getByTestId('registrationBtn')); + await userEvent.click(screen.getByTestId('registrationBtn')); }); it('Testing registration functionality, when password and confirm password is not same', async () => { @@ -466,24 +472,27 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Last Name/i), formData.lastName, ); - userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); - userEvent.type(screen.getByPlaceholderText('Password'), formData.password); - userEvent.type( + await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); + await userEvent.type( + screen.getByPlaceholderText('Password'), + formData.password, + ); + await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword, ); - userEvent.click(screen.getByTestId('registrationBtn')); + await userEvent.click(screen.getByTestId('registrationBtn')); }); it('Testing registration functionality, when input is not filled correctly', async () => { @@ -509,24 +518,27 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Last Name/i), formData.lastName, ); - userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); - userEvent.type(screen.getByPlaceholderText('Password'), formData.password); - userEvent.type( + await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); + await userEvent.type( + screen.getByPlaceholderText('Password'), + formData.password, + ); + await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword, ); - userEvent.click(screen.getByTestId('registrationBtn')); + await userEvent.click(screen.getByTestId('registrationBtn')); }); it('switches to login tab on successful registration', async () => { @@ -552,23 +564,26 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); - userEvent.type( + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Last name/i), formData.lastName, ); - userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); - userEvent.type(screen.getByPlaceholderText('Password'), formData.password); - userEvent.type( + await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); + await userEvent.type( + screen.getByPlaceholderText('Password'), + formData.password, + ); + await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword, ); - userEvent.click(screen.getByTestId('registrationBtn')); + await userEvent.click(screen.getByTestId('registrationBtn')); await wait(); @@ -592,9 +607,9 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); - userEvent.click(screen.getByTestId('goToLoginPortion')); + await userEvent.click(screen.getByTestId('goToLoginPortion')); await wait(); }); @@ -619,13 +634,13 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.type(screen.getByTestId(/loginEmail/i), formData.email); - userEvent.type( + await userEvent.type(screen.getByTestId(/loginEmail/i), formData.email); + await userEvent.type( screen.getByPlaceholderText(/Enter Password/i), formData.password, ); - userEvent.click(screen.getByTestId('loginBtn')); + await userEvent.click(screen.getByTestId('loginBtn')); await wait(); }); @@ -653,24 +668,27 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Last Name/i), formData.lastName, ); - userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); - userEvent.type(screen.getByPlaceholderText('Password'), formData.password); - userEvent.type( + await userEvent.type(screen.getByTestId(/signInEmail/i), formData.email); + await userEvent.type( + screen.getByPlaceholderText('Password'), + formData.password, + ); + await userEvent.type( screen.getByPlaceholderText('Confirm Password'), formData.confirmPassword, ); - userEvent.click(screen.getByTestId('registrationBtn')); + await userEvent.click(screen.getByTestId('registrationBtn')); await waitFor(() => { expect(resetReCAPTCHA).toBeCalled(); @@ -697,13 +715,13 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.type(screen.getByTestId(/loginEmail/i), formData.email); - userEvent.type( + await userEvent.type(screen.getByTestId(/loginEmail/i), formData.email); + await userEvent.type( screen.getByPlaceholderText(/Enter Password/i), formData.password, ); - userEvent.click(screen.getByTestId('loginBtn')); + await userEvent.click(screen.getByTestId('loginBtn')); await waitFor(() => { expect(resetReCAPTCHA).toBeCalled(); @@ -730,10 +748,10 @@ describe('Testing Login Page Screen', () => { // password should be hidden expect(input.type).toBe('password'); // click the toggle button to show password - userEvent.click(toggleText); + await userEvent.click(toggleText); expect(input.type).toBe('text'); // click the toggle button to hide password - userEvent.click(toggleText); + await userEvent.click(toggleText); expect(input.type).toBe('password'); await wait(); @@ -754,17 +772,17 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); const input = screen.getByTestId('passwordField') as HTMLInputElement; const toggleText = screen.getByTestId('showPassword'); // password should be hidden expect(input.type).toBe('password'); // click the toggle button to show password - userEvent.click(toggleText); + await userEvent.click(toggleText); expect(input.type).toBe('text'); // click the toggle button to hide password - userEvent.click(toggleText); + await userEvent.click(toggleText); expect(input.type).toBe('password'); await wait(); @@ -785,17 +803,17 @@ describe('Testing Login Page Screen', () => { await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); const input = screen.getByTestId('cpassword') as HTMLInputElement; const toggleText = screen.getByTestId('showPasswordCon'); // password should be hidden expect(input.type).toBe('password'); // click the toggle button to show password - userEvent.click(toggleText); + await userEvent.click(toggleText); expect(input.type).toBe('text'); // click the toggle button to hide password - userEvent.click(toggleText); + await userEvent.click(toggleText); expect(input.type).toBe('password'); await wait(); @@ -836,9 +854,12 @@ describe('Testing Login Page Screen', () => { ); await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); - userEvent.type(screen.getByPlaceholderText('Password'), password.password); + await userEvent.type( + screen.getByPlaceholderText('Password'), + password.password, + ); expect(screen.getByTestId('passwordField')).toHaveFocus(); @@ -865,9 +886,12 @@ describe('Testing Login Page Screen', () => { ); await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); - userEvent.type(screen.getByPlaceholderText('Password'), password.password); + await userEvent.type( + screen.getByPlaceholderText('Password'), + password.password, + ); expect(screen.getByTestId('passwordField')).toHaveFocus(); @@ -894,11 +918,14 @@ describe('Testing Login Page Screen', () => { ); await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); expect(screen.getByPlaceholderText('Password')).not.toHaveFocus(); - userEvent.type(screen.getByPlaceholderText('Password'), password.password); + await userEvent.type( + screen.getByPlaceholderText('Password'), + password.password, + ); expect(password.password.length).toBeLessThan(8); @@ -923,13 +950,16 @@ describe('Testing Login Page Screen', () => { ); await wait(); - userEvent.click(screen.getByTestId('goToRegisterPortion')); + await userEvent.click(screen.getByTestId('goToRegisterPortion')); await wait(); expect(screen.getByPlaceholderText('Password')).not.toHaveFocus(); - userEvent.type(screen.getByPlaceholderText('Password'), password.password); + await userEvent.type( + screen.getByPlaceholderText('Password'), + password.password, + ); expect(password.password.length).toBeGreaterThanOrEqual(8); @@ -961,7 +991,7 @@ describe('Testing Login Page Screen', () => { await wait(); const userLink = screen.getByText(/User/i); - userEvent.click(userLink); + await userEvent.click(userLink); await wait(); expect(screen.getByText(/User Login/i)).toBeInTheDocument(); expect(window.location.pathname).toBe('/user/organizations'); @@ -1051,7 +1081,7 @@ it('Render the Select Organization list and change the option', async () => { ); await wait(); - userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); + await userEvent.click(screen.getByTestId(/goToRegisterPortion/i)); await wait(); const autocomplete = screen.getByTestId('selectOrg'); const input = within(autocomplete).getByRole('combobox'); diff --git a/src/screens/ManageTag/ManageTag.spec.tsx b/src/screens/ManageTag/ManageTag.spec.tsx index 03c7eea393..842b532ba8 100644 --- a/src/screens/ManageTag/ManageTag.spec.tsx +++ b/src/screens/ManageTag/ManageTag.spec.tsx @@ -128,13 +128,13 @@ describe('Manage Tag Page', () => { expect(screen.getByTestId('addPeopleToTagBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('addPeopleToTagBtn')); + await userEvent.click(screen.getByTestId('addPeopleToTagBtn')); await waitFor(() => { expect(screen.getByTestId('addPeopleToTagModal')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('closeAddPeopleToTagModal')); + await userEvent.click(screen.getByTestId('closeAddPeopleToTagModal')); await waitFor(() => { expect( @@ -151,14 +151,14 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getAllByTestId('unassignTagBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); + await userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); await waitFor(() => { return expect( screen.findByTestId('unassignTagModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('unassignTagModalCloseBtn')); + await userEvent.click(screen.getByTestId('unassignTagModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('unassignTagModalCloseBtn'), @@ -174,7 +174,7 @@ describe('Manage Tag Page', () => { }); // Click the assignToTags button to open the modal - userEvent.click(screen.getByTestId('assignToTags')); + await userEvent.click(screen.getByTestId('assignToTags')); // Wait for the close button in the modal to be present await waitFor(() => { @@ -182,7 +182,7 @@ describe('Manage Tag Page', () => { }); // Click the close button to close the modal - userEvent.click(screen.getByTestId('closeTagActionsModalBtn')); + await userEvent.click(screen.getByTestId('closeTagActionsModalBtn')); // Wait for the modal to be removed from the document await waitFor(() => { @@ -199,7 +199,7 @@ describe('Manage Tag Page', () => { }); // Click the removeFromTags button to open the modal - userEvent.click(screen.getByTestId('removeFromTags')); + await userEvent.click(screen.getByTestId('removeFromTags')); // Wait for the close button in the modal to be present await waitFor(() => { @@ -207,7 +207,7 @@ describe('Manage Tag Page', () => { }); // Click the close button to close the modal - userEvent.click(screen.getByTestId('closeTagActionsModalBtn')); + await userEvent.click(screen.getByTestId('closeTagActionsModalBtn')); // Wait for the modal to be removed from the document await waitFor(() => { @@ -223,14 +223,14 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('editUserTag')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('editUserTag')); + await userEvent.click(screen.getByTestId('editUserTag')); await waitFor(() => { return expect( screen.findByTestId('closeEditTagModalBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('closeEditTagModalBtn')); + await userEvent.click(screen.getByTestId('closeEditTagModalBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('closeEditTagModalBtn'), @@ -245,14 +245,14 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('removeTag')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('removeTag')); + await userEvent.click(screen.getByTestId('removeTag')); await waitFor(() => { return expect( screen.findByTestId('removeUserTagModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('removeUserTagModalCloseBtn')); + await userEvent.click(screen.getByTestId('removeUserTagModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('removeUserTagModalCloseBtn'), @@ -267,7 +267,7 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getAllByTestId('viewProfileBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('viewProfileBtn')[0]); + await userEvent.click(screen.getAllByTestId('viewProfileBtn')[0]); await waitFor(() => { expect(screen.getByTestId('memberProfileScreen')).toBeInTheDocument(); @@ -282,7 +282,7 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('subTagsBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('subTagsBtn')); + await userEvent.click(screen.getByTestId('subTagsBtn')); await waitFor(() => { expect(screen.getByTestId('subTagsScreen')).toBeInTheDocument(); @@ -299,7 +299,7 @@ describe('Manage Tag Page', () => { screen.getAllByTestId('redirectToManageTag')[0], ).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('redirectToManageTag')[0]); + await userEvent.click(screen.getAllByTestId('redirectToManageTag')[0]); await waitFor(() => { expect(screen.getByTestId('addPeopleToTagBtn')).toBeInTheDocument(); @@ -314,7 +314,7 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('allTagsBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('allTagsBtn')); + await userEvent.click(screen.getByTestId('allTagsBtn')); await waitFor(() => { expect(screen.getByTestId('organizationTagsScreen')).toBeInTheDocument(); @@ -367,12 +367,12 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('sortPeople')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('sortPeople')); + await userEvent.click(screen.getByTestId('sortPeople')); await waitFor(() => { expect(screen.getByTestId('ASCENDING')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('ASCENDING')); + await userEvent.click(screen.getByTestId('ASCENDING')); // returns the tags in reverse order await waitFor(() => { @@ -384,12 +384,12 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('sortPeople')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('sortPeople')); + await userEvent.click(screen.getByTestId('sortPeople')); await waitFor(() => { expect(screen.getByTestId('DESCENDING')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('DESCENDING')); + await userEvent.click(screen.getByTestId('DESCENDING')); // reverse the order again await waitFor(() => { @@ -438,9 +438,9 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getAllByTestId('unassignTagBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); + await userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); - userEvent.click(screen.getByTestId('unassignTagModalSubmitBtn')); + await userEvent.click(screen.getByTestId('unassignTagModalSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -457,20 +457,20 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('editUserTag')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('editUserTag')); + await userEvent.click(screen.getByTestId('editUserTag')); - userEvent.click(screen.getByTestId('editTagSubmitBtn')); + await userEvent.click(screen.getByTestId('editTagSubmitBtn')); await waitFor(() => { expect(toast.info).toHaveBeenCalledWith(translations.changeNameToEdit); }); const tagNameInput = screen.getByTestId('tagNameInput'); - await userEvent.clear(tagNameInput); + await await userEvent.clear(tagNameInput); await userEvent.type(tagNameInput, 'tag 1 edited'); expect(tagNameInput).toHaveValue('tag 1 edited'); - userEvent.click(screen.getByTestId('editTagSubmitBtn')); + await userEvent.click(screen.getByTestId('editTagSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( @@ -487,9 +487,9 @@ describe('Manage Tag Page', () => { await waitFor(() => { expect(screen.getByTestId('removeTag')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('removeTag')); + await userEvent.click(screen.getByTestId('removeTag')); - userEvent.click(screen.getByTestId('removeUserTagSubmitBtn')); + await userEvent.click(screen.getByTestId('removeUserTagSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( diff --git a/src/screens/MemberDetail/MemberDetail.spec.tsx b/src/screens/MemberDetail/MemberDetail.spec.tsx index 4c1a68369f..a2febe43de 100644 --- a/src/screens/MemberDetail/MemberDetail.spec.tsx +++ b/src/screens/MemberDetail/MemberDetail.spec.tsx @@ -164,45 +164,51 @@ describe('MemberDetail', () => { target: { value: formData.birthDate }, }); - userEvent.clear(screen.getByPlaceholderText(/First Name/i)); - userEvent.type( + await userEvent.clear(screen.getByPlaceholderText(/First Name/i)); + await userEvent.type( screen.getByPlaceholderText(/First Name/i), formData.firstName, ); - userEvent.clear(screen.getByPlaceholderText(/Last Name/i)); - userEvent.type( + await userEvent.clear(screen.getByPlaceholderText(/Last Name/i)); + await userEvent.type( screen.getByPlaceholderText(/Last Name/i), formData.lastName, ); - userEvent.clear(screen.getByPlaceholderText(/Address/i)); - userEvent.type(screen.getByPlaceholderText(/Address/i), formData.address); + await userEvent.clear(screen.getByPlaceholderText(/Address/i)); + await userEvent.type( + screen.getByPlaceholderText(/Address/i), + formData.address, + ); - userEvent.clear(screen.getByPlaceholderText(/Country Code/i)); - userEvent.type( + await userEvent.clear(screen.getByPlaceholderText(/Country Code/i)); + await userEvent.type( screen.getByPlaceholderText(/Country Code/i), formData.countryCode, ); - userEvent.clear(screen.getByPlaceholderText(/State/i)); - userEvent.type(screen.getByPlaceholderText(/State/i), formData.state); + await userEvent.clear(screen.getByPlaceholderText(/State/i)); + await userEvent.type(screen.getByPlaceholderText(/State/i), formData.state); - userEvent.clear(screen.getByPlaceholderText(/City/i)); - userEvent.type(screen.getByPlaceholderText(/City/i), formData.city); + await userEvent.clear(screen.getByPlaceholderText(/City/i)); + await userEvent.type(screen.getByPlaceholderText(/City/i), formData.city); - userEvent.clear(screen.getByPlaceholderText(/Email/i)); - userEvent.type(screen.getByPlaceholderText(/Email/i), formData.email); + await userEvent.clear(screen.getByPlaceholderText(/Email/i)); + await userEvent.type(screen.getByPlaceholderText(/Email/i), formData.email); - userEvent.clear(screen.getByPlaceholderText(/Phone/i)); - userEvent.type(screen.getByPlaceholderText(/Phone/i), formData.phoneNumber); + await userEvent.clear(screen.getByPlaceholderText(/Phone/i)); + await userEvent.type( + screen.getByPlaceholderText(/Phone/i), + formData.phoneNumber, + ); - // userEvent.click(screen.getByPlaceholderText(/pluginCreationAllowed/i)); - // userEvent.selectOptions(screen.getByTestId('applangcode'), 'Français'); - // userEvent.upload(screen.getByLabelText(/Display Image:/i), formData.image); + // await userEvent.click(screen.getByPlaceholderText(/pluginCreationAllowed/i)); + // await userEvent.selectOptions(screen.getByTestId('applangcode'), 'Français'); + // await userEvent.upload(screen.getByLabelText(/Display Image:/i), formData.image); await wait(); - userEvent.click(screen.getByText(/Save Changes/i)); + await userEvent.click(screen.getByText(/Save Changes/i)); expect(screen.getByPlaceholderText(/First Name/i)).toHaveValue( formData.firstName, @@ -262,10 +268,10 @@ describe('MemberDetail', () => { expect(screen.getByPlaceholderText(/Address/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Address/i), 'random'); - userEvent.type(screen.getByPlaceholderText(/State/i), 'random'); + await userEvent.type(screen.getByPlaceholderText(/Address/i), 'random'); + await userEvent.type(screen.getByPlaceholderText(/State/i), 'random'); - userEvent.click(screen.getByTestId('resetChangesBtn')); + await userEvent.click(screen.getByTestId('resetChangesBtn')); await wait(); expect(screen.getByPlaceholderText(/First Name/i)).toHaveValue('Aditya'); expect(screen.getByPlaceholderText(/Last Name/i)).toHaveValue('Agarwal'); @@ -307,7 +313,7 @@ describe('MemberDetail', () => { // Find and click the "View All" button const viewAllButton = screen.getByText('View All'); - userEvent.click(viewAllButton); + await userEvent.click(viewAllButton); // Check if the modal with the title "Events Attended List" is now visible const modalTitle = await screen.findByText('Events Attended List'); @@ -332,7 +338,7 @@ describe('MemberDetail', () => { await waitFor(() => { expect(screen.getAllByTestId('tagName')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('tagName')[0]); + await userEvent.click(screen.getAllByTestId('tagName')[0]); await waitFor(() => { expect(screen.getByTestId('manageTagScreen')).toBeInTheDocument(); @@ -373,14 +379,14 @@ describe('MemberDetail', () => { await waitFor(() => { expect(screen.getAllByTestId('unassignTagBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); + await userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); await waitFor(() => { return expect( screen.findByTestId('unassignTagModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('unassignTagModalCloseBtn')); + await userEvent.click(screen.getByTestId('unassignTagModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('unassignTagModalCloseBtn'), @@ -395,9 +401,9 @@ describe('MemberDetail', () => { await waitFor(() => { expect(screen.getAllByTestId('unassignTagBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); + await userEvent.click(screen.getAllByTestId('unassignTagBtn')[0]); - userEvent.click(screen.getByTestId('unassignTagModalSubmitBtn')); + await userEvent.click(screen.getByTestId('unassignTagModalSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( diff --git a/src/screens/OrgList/OrgList.spec.tsx b/src/screens/OrgList/OrgList.spec.tsx index 80a0bf1233..4afdc61bdd 100644 --- a/src/screens/OrgList/OrgList.spec.tsx +++ b/src/screens/OrgList/OrgList.spec.tsx @@ -116,7 +116,7 @@ describe('Organisations Page testing as SuperAdmin', () => { // Test that the search bar filters organizations by name const searchBar = screen.getByTestId(/searchByName/i); expect(searchBar).toBeInTheDocument(); - userEvent.type(searchBar, 'Dummy{enter}'); + await userEvent.type(searchBar, 'Dummy{enter}'); }); test('Testing search functionality by Btn click', async () => { @@ -138,7 +138,7 @@ describe('Organisations Page testing as SuperAdmin', () => { const searchBar = screen.getByTestId('searchByName'); const searchBtn = screen.getByTestId('searchBtn'); - userEvent.type(searchBar, 'Dummy'); + await userEvent.type(searchBar, 'Dummy'); fireEvent.click(searchBtn); }); @@ -237,45 +237,51 @@ describe('Organisations Page testing as SuperAdmin', () => { JSON.stringify([{ name: 'adi', _id: '1234', image: '' }]), ); - userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); + await userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); - userEvent.type(screen.getByTestId(/modalOrganizationName/i), formData.name); - userEvent.type( + await userEvent.type( + screen.getByTestId(/modalOrganizationName/i), + formData.name, + ); + await userEvent.type( screen.getByPlaceholderText(/Description/i), formData.description, ); - userEvent.type(screen.getByPlaceholderText(/City/i), formData.address.city); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText(/City/i), + formData.address.city, + ); + await userEvent.type( screen.getByPlaceholderText(/Postal Code/i), formData.address.postalCode, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/State \/ Province/i), formData.address.state, ); - userEvent.selectOptions( + await userEvent.selectOptions( screen.getByTestId('countrycode'), formData.address.countryCode, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Line 1/i), formData.address.line1, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Line 2/i), formData.address.line2, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Sorting Code/i), formData.address.sortingCode, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Dependent Locality/i), formData.address.dependentLocality, ); - userEvent.click(screen.getByTestId(/userRegistrationRequired/i)); - userEvent.click(screen.getByTestId(/visibleInSearch/i)); + await userEvent.click(screen.getByTestId(/userRegistrationRequired/i)); + await userEvent.click(screen.getByTestId(/visibleInSearch/i)); expect(screen.getByTestId(/modalOrganizationName/i)).toHaveValue( formData.name, @@ -305,8 +311,8 @@ describe('Organisations Page testing as SuperAdmin', () => { expect(screen.getByTestId(/visibleInSearch/i)).toBeChecked(); expect(screen.getByLabelText(/Display Image/i)).toBeTruthy(); const displayImage = screen.getByTestId('organisationImage'); - userEvent.upload(displayImage, formData.image); - userEvent.click(screen.getByTestId(/submitOrganizationForm/i)); + await userEvent.upload(displayImage, formData.image); + await userEvent.click(screen.getByTestId(/submitOrganizationForm/i)); await waitFor(() => { expect( screen.queryByText(/Congratulation the Organization is created/i), @@ -339,44 +345,50 @@ describe('Organisations Page testing as SuperAdmin', () => { JSON.stringify([{ name: 'adi', _id: '1234', image: '' }]), ); - userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); + await userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); - userEvent.type(screen.getByTestId(/modalOrganizationName/i), formData.name); - userEvent.type( + await userEvent.type( + screen.getByTestId(/modalOrganizationName/i), + formData.name, + ); + await userEvent.type( screen.getByPlaceholderText(/Description/i), formData.description, ); - userEvent.type(screen.getByPlaceholderText(/City/i), formData.address.city); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText(/City/i), + formData.address.city, + ); + await userEvent.type( screen.getByPlaceholderText(/State \/ Province/i), formData.address.state, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Postal Code/i), formData.address.postalCode, ); - userEvent.selectOptions( + await userEvent.selectOptions( screen.getByTestId('countrycode'), formData.address.countryCode, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Line 1/i), formData.address.line1, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Line 2/i), formData.address.line2, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Sorting Code/i), formData.address.sortingCode, ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Dependent Locality/i), formData.address.dependentLocality, ); - userEvent.click(screen.getByTestId(/userRegistrationRequired/i)); - userEvent.click(screen.getByTestId(/visibleInSearch/i)); + await userEvent.click(screen.getByTestId(/userRegistrationRequired/i)); + await userEvent.click(screen.getByTestId(/visibleInSearch/i)); expect(screen.getByTestId(/modalOrganizationName/i)).toHaveValue( formData.name, @@ -406,7 +418,7 @@ describe('Organisations Page testing as SuperAdmin', () => { expect(screen.getByTestId(/visibleInSearch/i)).toBeChecked(); expect(screen.getByLabelText(/Display Image/i)).toBeTruthy(); - userEvent.click(screen.getByTestId(/submitOrganizationForm/i)); + await userEvent.click(screen.getByTestId(/submitOrganizationForm/i)); // await act(async () => { // await new Promise((resolve) => setTimeout(resolve, 1000)); // }); @@ -418,8 +430,8 @@ describe('Organisations Page testing as SuperAdmin', () => { await waitFor(() => { screen.findByTestId(/pluginNotificationHeader/i); }); - // userEvent.click(screen.getByTestId(/enableEverythingForm/i)); - userEvent.click(screen.getByTestId(/enableEverythingForm/i)); + // await userEvent.click(screen.getByTestId(/enableEverythingForm/i)); + await userEvent.click(screen.getByTestId(/enableEverythingForm/i)); }); test('Testing create sample organization working properly', async () => { @@ -440,8 +452,8 @@ describe('Organisations Page testing as SuperAdmin', () => { , ); await wait(); - userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); - userEvent.click(screen.getByTestId(/createSampleOrganizationBtn/i)); + await userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); + await userEvent.click(screen.getByTestId(/createSampleOrganizationBtn/i)); await waitFor(() => expect( screen.queryByText(/Sample Organization Successfully created/i), @@ -465,8 +477,8 @@ describe('Organisations Page testing as SuperAdmin', () => { , ); await wait(); - userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); - userEvent.click(screen.getByTestId(/createSampleOrganizationBtn/i)); + await userEvent.click(screen.getByTestId(/createOrganizationBtn/i)); + await userEvent.click(screen.getByTestId(/createSampleOrganizationBtn/i)); await waitFor(() => expect( screen.queryByText(/Only one sample organization allowed/i), diff --git a/src/screens/OrgPost/OrgPost.test.tsx b/src/screens/OrgPost/OrgPost.test.tsx index e9952db7bd..b971eb342c 100644 --- a/src/screens/OrgPost/OrgPost.test.tsx +++ b/src/screens/OrgPost/OrgPost.test.tsx @@ -214,37 +214,54 @@ describe('Organisation Post Page', () => { }); test('Testing create post functionality', async () => { - render( - - - - - - - - - , - ); - - await wait(); + await act(async () => { + render( + + + + + + + + + , + ); + }); + await act(async () => { + await wait(); + }); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await userEvent.click(screen.getByTestId('createPostModalBtn')); - userEvent.type(screen.getByTestId('modalTitle'), formData.posttitle); + await userEvent.type(screen.getByTestId('modalTitle'), formData.posttitle); - userEvent.type(screen.getByTestId('modalinfo'), formData.postinfo); - userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); - userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); - userEvent.upload(screen.getByTestId('addMediaField'), formData.postImage); - userEvent.upload(screen.getByTestId('addMediaField'), formData.postVideo); - userEvent.click(screen.getByTestId('pinPost')); + await userEvent.type(screen.getByTestId('modalinfo'), formData.postinfo); + await userEvent.upload( + screen.getByTestId('addMediaField'), + formData.postImage, + ); + await userEvent.upload( + screen.getByTestId('addMediaField'), + formData.postVideo, + ); + await userEvent.upload( + screen.getByTestId('addMediaField'), + formData.postImage, + ); + await userEvent.upload( + screen.getByTestId('addMediaField'), + formData.postVideo, + ); + await userEvent.click(screen.getByTestId('pinPost')); expect(screen.getByTestId('pinPost')).toBeChecked(); - userEvent.click(screen.getByTestId('createPostBtn')); + await userEvent.click(screen.getByTestId('createPostBtn')); - await wait(); + await act(async () => { + await wait(); + }); - userEvent.click(screen.getByTestId('closeOrganizationModal')); + await userEvent.click(screen.getByTestId('closeOrganizationModal')); }, 15000); test('Testing search functionality', async () => { @@ -267,10 +284,13 @@ describe('Organisation Post Page', () => { }); } await debounceWait(); - userEvent.type(screen.getByPlaceholderText(/Search By/i), 'postone{enter}'); + await userEvent.type( + screen.getByPlaceholderText(/Search By/i), + 'postone{enter}', + ); await debounceWait(); const sortDropdown = screen.getByTestId('sort'); - userEvent.click(sortDropdown); + await userEvent.click(sortDropdown); }); test('Testing search text and title toggle', async () => { await act(async () => { @@ -287,7 +307,9 @@ describe('Organisation Post Page', () => { , ); }); - await wait(); + await act(async () => { + await wait(); + }); const searchInput = screen.getByTestId('searchByName'); expect(searchInput).toHaveAttribute('placeholder', 'Search By Title'); @@ -330,7 +352,9 @@ describe('Organisation Post Page', () => { , ); }); - await wait(); + await act(async () => { + await wait(); + }); const searchInput = screen.getByTestId('sort'); expect(searchInput).toBeInTheDocument(); @@ -374,35 +398,43 @@ describe('Organisation Post Page', () => { , ); - await wait(); + await act(async () => { + await wait(); + }); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await userEvent.click(screen.getByTestId('createPostModalBtn')); // Fill in post form fields... - userEvent.click(screen.getByTestId('createPostBtn')); + await userEvent.click(screen.getByTestId('createPostBtn')); - await wait(); + await act(async () => { + await wait(); + }); expect(refetchMock).toHaveBeenCalledTimes(0); }); test('Create post without media', async () => { - render( - - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + + , + ); + }); + await act(async () => { + await wait(); + }); - await wait(); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await userEvent.click(screen.getByTestId('createPostModalBtn')); const postTitleInput = screen.getByTestId('modalTitle'); fireEvent.change(postTitleInput, { target: { value: 'Test Post' } }); @@ -430,8 +462,11 @@ describe('Organisation Post Page', () => { , ); - await wait(); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await act(async () => { + await wait(); + }); + + await userEvent.click(screen.getByTestId('createPostModalBtn')); const postTitleInput = screen.getByTestId('modalTitle'); fireEvent.change(postTitleInput, { target: { value: 'Test Post' } }); @@ -446,7 +481,7 @@ describe('Organisation Post Page', () => { type: 'image/png', }); const imageInput = screen.getByTestId('addMediaField'); - userEvent.upload(imageInput, imageFile); + await userEvent.upload(imageInput, imageFile); // Check if the image is displayed const imagePreview = await screen.findByAltText('Post Image Preview'); @@ -473,19 +508,23 @@ describe('Organisation Post Page', () => { , ); - await wait(); + await act(async () => { + await wait(); + }); const createPostModalBtn = screen.getByTestId('createPostModalBtn'); - userEvent.click(createPostModalBtn); + await userEvent.click(createPostModalBtn); const modalTitle = screen.getByTestId('modalOrganizationHeader'); expect(modalTitle).toBeInTheDocument(); const closeButton = screen.getByTestId(/modalOrganizationHeader/i); - userEvent.click(closeButton); + await userEvent.click(closeButton); - await wait(); + await act(async () => { + await wait(); + }); const closedModalTitle = screen.queryByText(/postDetail/i); expect(closedModalTitle).not.toBeInTheDocument(); @@ -504,8 +543,11 @@ describe('Organisation Post Page', () => { , ); - await wait(); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await act(async () => { + await wait(); + }); + + await userEvent.click(screen.getByTestId('createPostModalBtn')); // Check if input fields and buttons are present expect(screen.getByTestId('modalTitle')).toBeInTheDocument(); @@ -527,8 +569,11 @@ describe('Organisation Post Page', () => { , ); - await wait(); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await act(async () => { + await wait(); + }); + + await userEvent.click(screen.getByTestId('createPostModalBtn')); // Simulate user input fireEvent.change(screen.getByTestId('modalTitle'), { @@ -557,8 +602,11 @@ describe('Organisation Post Page', () => { , ); - await wait(); - userEvent.click(screen.getByTestId('createPostModalBtn')); + await act(async () => { + await wait(); + }); + + await userEvent.click(screen.getByTestId('createPostModalBtn')); const postTitleInput = screen.getByTestId('modalTitle'); fireEvent.change(postTitleInput, { target: { value: 'Test Post' } }); @@ -571,7 +619,7 @@ describe('Organisation Post Page', () => { type: 'image/png', }); const input = screen.getByTestId('addMediaField'); - userEvent.upload(input, file); + await userEvent.upload(input, file); await screen.findByAltText('Post Image Preview'); expect(screen.getByAltText('Post Image Preview')).toBeInTheDocument(); @@ -594,10 +642,12 @@ describe('Organisation Post Page', () => { , ); }); - await wait(); + await act(async () => { + await wait(); + }); await act(async () => { - userEvent.click(screen.getByTestId('createPostModalBtn')); + await userEvent.click(screen.getByTestId('createPostModalBtn')); }); const postTitleInput = screen.getByTestId('modalTitle'); @@ -617,7 +667,7 @@ describe('Organisation Post Page', () => { }); await act(async () => { - userEvent.upload(screen.getByTestId('addMediaField'), videoFile); + await userEvent.upload(screen.getByTestId('addMediaField'), videoFile); }); // Check if the video is displayed @@ -657,20 +707,24 @@ describe('Organisation Post Page', () => { ]; // Render the OrgPost component and pass the mocked data to it - render( - - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + + , + ); + }); - await wait(); + await act(async () => { + await wait(); + }); const sortedPosts = screen.getAllByTestId('post-item'); diff --git a/src/screens/OrgSettings/OrgSettings.spec.tsx b/src/screens/OrgSettings/OrgSettings.spec.tsx index e7d417e179..8822ec850a 100644 --- a/src/screens/OrgSettings/OrgSettings.spec.tsx +++ b/src/screens/OrgSettings/OrgSettings.spec.tsx @@ -113,18 +113,18 @@ describe('Organisation Settings Page', () => { ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('generalSettings')); + await userEvent.click(screen.getByTestId('generalSettings')); await waitFor(() => { expect(screen.getByTestId('generalTab')).toBeInTheDocument(); expect(screen.getByTestId('generalTab')).toBeVisible(); }); - userEvent.click(screen.getByTestId('actionItemCategoriesSettings')); + await userEvent.click(screen.getByTestId('actionItemCategoriesSettings')); await waitFor(() => { expect(screen.getByTestId('actionItemCategoriesTab')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('agendaItemCategoriesSettings')); + await userEvent.click(screen.getByTestId('agendaItemCategoriesSettings')); await waitFor(() => { expect(screen.getByTestId('agendaItemCategoriesTab')).toBeInTheDocument(); }); @@ -140,14 +140,14 @@ describe('Organisation Settings Page', () => { // }); // const dropdownToggle = screen.getByTestId('settingsDropdownToggle'); - // userEvent.click(dropdownToggle); + // await userEvent.click(dropdownToggle); // // Find all dropdown items // const dropdownItems = screen.getAllByRole('menuitem'); // expect(dropdownItems).toHaveLength(3); // for (const item of dropdownItems) { - // userEvent.click(item); + // await userEvent.click(item); // if (item.textContent?.includes('general')) { // await waitFor(() => { @@ -168,7 +168,7 @@ describe('Organisation Settings Page', () => { // } // if (item !== dropdownItems[dropdownItems.length - 1]) { - // userEvent.click(dropdownToggle); + // await userEvent.click(dropdownToggle); // } // } diff --git a/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx b/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx index 89bcc5d824..401e122aab 100644 --- a/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx +++ b/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx @@ -353,12 +353,12 @@ describe('Testing Organization Action Items Screen', () => { const addItemBtn = await screen.findByTestId('createActionItemBtn'); expect(addItemBtn).toBeInTheDocument(); - userEvent.click(addItemBtn); + await userEvent.click(addItemBtn); await waitFor(() => expect(screen.getAllByText(t.createActionItem)).toHaveLength(2), ); - userEvent.click(screen.getByTestId('modalCloseBtn')); + await userEvent.click(screen.getByTestId('modalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('modalCloseBtn')).toBeNull(), ); @@ -390,12 +390,12 @@ describe('Testing Organization Action Items Screen', () => { const viewItemBtn = await screen.findByTestId('viewItemBtn1'); expect(viewItemBtn).toBeInTheDocument(); - userEvent.click(viewItemBtn); + await userEvent.click(viewItemBtn); await waitFor(() => expect(screen.getByText(t.actionItemDetails)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('modalCloseBtn')); + await userEvent.click(screen.getByTestId('modalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('modalCloseBtn')).toBeNull(), ); @@ -427,12 +427,12 @@ describe('Testing Organization Action Items Screen', () => { const editItemBtn = await screen.findByTestId('editItemBtn1'); await waitFor(() => expect(editItemBtn).toBeInTheDocument()); - userEvent.click(editItemBtn); + await userEvent.click(editItemBtn); await waitFor(() => expect(screen.getAllByText(t.updateActionItem)).toHaveLength(2), ); - userEvent.click(screen.getByTestId('modalCloseBtn')); + await userEvent.click(screen.getByTestId('modalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('modalCloseBtn')).toBeNull(), ); @@ -464,12 +464,12 @@ describe('Testing Organization Action Items Screen', () => { const deleteItemBtn = await screen.findByTestId('deleteItemBtn1'); expect(deleteItemBtn).toBeInTheDocument(); - userEvent.click(deleteItemBtn); + await userEvent.click(deleteItemBtn); await waitFor(() => expect(screen.getByText(t.deleteActionItem)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('modalCloseBtn')); + await userEvent.click(screen.getByTestId('modalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('modalCloseBtn')).toBeNull(), ); @@ -501,12 +501,12 @@ describe('Testing Organization Action Items Screen', () => { const statusCheckbox = await screen.findByTestId('statusCheckbox1'); expect(statusCheckbox).toBeInTheDocument(); - userEvent.click(statusCheckbox); + await userEvent.click(statusCheckbox); await waitFor(() => expect(screen.getByText(t.actionItemStatus)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('modalCloseBtn')); + await userEvent.click(screen.getByTestId('modalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('modalCloseBtn')).toBeNull(), ); @@ -539,17 +539,17 @@ describe('Testing Organization Action Items Screen', () => { const searchByToggle = await screen.findByTestId('searchByToggle'); expect(searchByToggle).toBeInTheDocument(); - userEvent.click(searchByToggle); + await userEvent.click(searchByToggle); await waitFor(() => { expect(screen.getByTestId('assignee')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('assignee')); + await userEvent.click(screen.getByTestId('assignee')); const searchInput = await screen.findByTestId('searchBy'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'John'); + await userEvent.type(searchInput, 'John'); await debounceWait(); await waitFor(() => { @@ -585,17 +585,17 @@ describe('Testing Organization Action Items Screen', () => { const searchByToggle = await screen.findByTestId('searchByToggle'); expect(searchByToggle).toBeInTheDocument(); - userEvent.click(searchByToggle); + await userEvent.click(searchByToggle); await waitFor(() => { expect(screen.getByTestId('category')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('category')); + await userEvent.click(screen.getByTestId('category')); const searchInput = await screen.findByTestId('searchBy'); expect(searchInput).toBeInTheDocument(); - userEvent.type(searchInput, 'Category 1'); + await userEvent.type(searchInput, 'Category 1'); await debounceWait(); await waitFor(() => { diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx index 6fd27ce429..79368273c8 100644 --- a/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx +++ b/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx @@ -182,7 +182,7 @@ describe('Testing Organization Dashboard Screen', () => { const membersBtn = await screen.findByText(t.members); expect(membersBtn).toBeInTheDocument(); - userEvent.click(membersBtn); + await userEvent.click(membersBtn); await waitFor(() => { expect(screen.getByTestId('orgpeople')).toBeInTheDocument(); }); @@ -202,7 +202,7 @@ it('Click Post Card', async () => { const postsBtn = await screen.findByText(t.posts); expect(postsBtn).toBeInTheDocument(); - userEvent.click(postsBtn); + await userEvent.click(postsBtn); await waitFor(() => { expect(screen.getByTestId('orgpost')).toBeInTheDocument(); }); @@ -214,7 +214,7 @@ it('Click Events Card', async () => { const eventsBtn = await screen.findByText(t.events); expect(eventsBtn).toBeInTheDocument(); - userEvent.click(eventsBtn); + await userEvent.click(eventsBtn); await waitFor(() => { expect(screen.getByTestId('orgevents')).toBeInTheDocument(); }); @@ -226,7 +226,7 @@ it('Click Blocked Users Card', async () => { const blockedUsersBtn = await screen.findByText(t.blockedUsers); expect(blockedUsersBtn).toBeInTheDocument(); - userEvent.click(blockedUsersBtn); + await userEvent.click(blockedUsersBtn); await waitFor(() => { expect(screen.getByTestId('blockuser')).toBeInTheDocument(); }); @@ -238,7 +238,7 @@ it('Click Requests Card', async () => { const requestsBtn = await screen.findByText(t.requests); expect(requestsBtn).toBeInTheDocument(); - userEvent.click(requestsBtn); + await userEvent.click(requestsBtn); await waitFor(() => { expect(screen.getByTestId('requests')).toBeInTheDocument(); }); @@ -250,7 +250,7 @@ it('Click View All Events', async () => { const viewAllBtn = await screen.findAllByText(t.viewAll); expect(viewAllBtn[0]).toBeInTheDocument(); - userEvent.click(viewAllBtn[0]); + await userEvent.click(viewAllBtn[0]); await waitFor(() => { expect(screen.getByTestId('orgevents')).toBeInTheDocument(); }); @@ -262,7 +262,7 @@ it('Click View All Posts', async () => { const viewAllBtn = await screen.findAllByText(t.viewAll); expect(viewAllBtn[1]).toBeInTheDocument(); - userEvent.click(viewAllBtn[1]); + await userEvent.click(viewAllBtn[1]); await waitFor(() => { expect(screen.getByTestId('orgpost')).toBeInTheDocument(); }); @@ -274,7 +274,7 @@ it('Click View All Requests', async () => { const viewAllBtn = await screen.findAllByText(t.viewAll); expect(viewAllBtn[2]).toBeInTheDocument(); - userEvent.click(viewAllBtn[2]); + await userEvent.click(viewAllBtn[2]); await waitFor(() => { expect(toast.success).toHaveBeenCalled(); }); @@ -286,7 +286,7 @@ it('Click View All Leaderboard', async () => { const viewAllBtn = await screen.findAllByText(t.viewAll); expect(viewAllBtn[3]).toBeInTheDocument(); - userEvent.click(viewAllBtn[3]); + await userEvent.click(viewAllBtn[3]); await waitFor(() => { expect(screen.getByTestId('leaderboard')).toBeInTheDocument(); }); diff --git a/src/screens/OrganizationEvents/OrganizationEvents.spec.tsx b/src/screens/OrganizationEvents/OrganizationEvents.spec.tsx index e329130895..12892be68d 100644 --- a/src/screens/OrganizationEvents/OrganizationEvents.spec.tsx +++ b/src/screens/OrganizationEvents/OrganizationEvents.spec.tsx @@ -214,7 +214,7 @@ describe('Organisation Events Page', () => { expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect( @@ -222,7 +222,7 @@ describe('Organisation Events Page', () => { ).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalCloseBtn')); + await userEvent.click(screen.getByTestId('createEventModalCloseBtn')); await waitFor(() => { expect( @@ -254,19 +254,25 @@ describe('Organisation Events Page', () => { expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type(screen.getByPlaceholderText(/Location/i), formData.location); + await userEvent.type( + screen.getByPlaceholderText(/Location/i), + formData.location, + ); const endDatePicker = screen.getByLabelText('End Date'); const startDatePicker = screen.getByLabelText('Start Date'); @@ -278,8 +284,8 @@ describe('Organisation Events Page', () => { target: { value: formData.startDate }, }); - userEvent.click(screen.getByTestId('ispublicCheck')); - userEvent.click(screen.getByTestId('registrableCheck')); + await userEvent.click(screen.getByTestId('ispublicCheck')); + await userEvent.click(screen.getByTestId('registrableCheck')); await wait(); @@ -295,7 +301,7 @@ describe('Organisation Events Page', () => { expect(screen.getByTestId('ispublicCheck')).not.toBeChecked(); expect(screen.getByTestId('registrableCheck')).toBeChecked(); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventCreated); @@ -345,19 +351,28 @@ describe('Organisation Events Page', () => { expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); - userEvent.type( + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type(screen.getByPlaceholderText(/Location/i), formData.location); - userEvent.type(screen.getByPlaceholderText(/Location/i), formData.location); + await userEvent.type( + screen.getByPlaceholderText(/Location/i), + formData.location, + ); + await userEvent.type( + screen.getByPlaceholderText(/Location/i), + formData.location, + ); const endDatePicker = screen.getByLabelText('End Date'); const startDatePicker = screen.getByLabelText('Start Date'); @@ -369,10 +384,10 @@ describe('Organisation Events Page', () => { target: { value: formData.startDate }, }); - userEvent.click(screen.getByTestId('alldayCheck')); - userEvent.click(screen.getByTestId('recurringCheck')); - userEvent.click(screen.getByTestId('ispublicCheck')); - userEvent.click(screen.getByTestId('registrableCheck')); + await userEvent.click(screen.getByTestId('alldayCheck')); + await userEvent.click(screen.getByTestId('recurringCheck')); + await userEvent.click(screen.getByTestId('ispublicCheck')); + await userEvent.click(screen.getByTestId('registrableCheck')); await wait(); @@ -386,12 +401,12 @@ describe('Organisation Events Page', () => { expect(screen.getByTestId('ispublicCheck')).not.toBeChecked(); expect(screen.getByTestId('registrableCheck')).toBeChecked(); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); expect(toast.warning).toHaveBeenCalledWith('Title can not be blank!'); expect(toast.warning).toHaveBeenCalledWith('Description can not be blank!'); expect(toast.warning).toHaveBeenCalledWith('Location can not be blank!'); - userEvent.click(screen.getByTestId('createEventModalCloseBtn')); + await userEvent.click(screen.getByTestId('createEventModalCloseBtn')); await waitFor(() => { expect( @@ -423,20 +438,26 @@ describe('Organisation Events Page', () => { expect(screen.getByTestId('createEventModalBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); await waitFor(() => { expect(screen.getByPlaceholderText(/Enter Title/i)).toBeInTheDocument(); }); - userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + await userEvent.type( + screen.getByPlaceholderText(/Enter Title/i), + formData.title, + ); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Description/i), formData.description, ); - userEvent.type(screen.getByPlaceholderText(/Location/i), formData.location); + await userEvent.type( + screen.getByPlaceholderText(/Location/i), + formData.location, + ); const endDatePicker = screen.getByLabelText('End Date'); const startDatePicker = screen.getByLabelText('Start Date'); @@ -448,7 +469,7 @@ describe('Organisation Events Page', () => { target: { value: formData.startDate }, }); - userEvent.click(screen.getByTestId('alldayCheck')); + await userEvent.click(screen.getByTestId('alldayCheck')); await waitFor(() => { expect(screen.getByLabelText(translations.startTime)).toBeInTheDocument(); @@ -465,7 +486,7 @@ describe('Organisation Events Page', () => { target: { value: formData.endTime }, }); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(translations.eventCreated); diff --git a/src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx b/src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx index 68bbc325b0..e3f52d9c00 100644 --- a/src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx +++ b/src/screens/OrganizationFundCampaign/OrganizationFundCampaign.spec.tsx @@ -142,12 +142,12 @@ describe('FundCampaigns Screen', () => { const addCampaignBtn = await screen.findByTestId('addCampaignBtn'); expect(addCampaignBtn).toBeInTheDocument(); - userEvent.click(addCampaignBtn); + await userEvent.click(addCampaignBtn); await waitFor(() => expect(screen.getAllByText(translations.createCampaign)).toHaveLength(2), ); - userEvent.click(screen.getByTestId('campaignCloseBtn')); + await userEvent.click(screen.getByTestId('campaignCloseBtn')); await waitFor(() => expect(screen.queryByTestId('campaignCloseBtn')).toBeNull(), ); @@ -163,14 +163,14 @@ describe('FundCampaigns Screen', () => { const editCampaignBtn = await screen.findAllByTestId('editCampaignBtn'); await waitFor(() => expect(editCampaignBtn[0]).toBeInTheDocument()); - userEvent.click(editCampaignBtn[0]); + await userEvent.click(editCampaignBtn[0]); await waitFor(() => expect( screen.getAllByText(translations.updateCampaign)[0], ).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('campaignCloseBtn')); + await userEvent.click(screen.getByTestId('campaignCloseBtn')); await waitFor(() => expect(screen.queryByTestId('campaignCloseBtn')).toBeNull(), ); diff --git a/src/screens/OrganizationFunds/OrganizationFunds.spec.tsx b/src/screens/OrganizationFunds/OrganizationFunds.spec.tsx index b259b7da65..1c20b2f23b 100644 --- a/src/screens/OrganizationFunds/OrganizationFunds.spec.tsx +++ b/src/screens/OrganizationFunds/OrganizationFunds.spec.tsx @@ -123,12 +123,12 @@ describe('OrganizationFunds Screen =>', () => { const createFundBtn = await screen.findByTestId('createFundBtn'); expect(createFundBtn).toBeInTheDocument(); - userEvent.click(createFundBtn); + await userEvent.click(createFundBtn); await waitFor(() => expect(screen.getAllByText(translations.fundCreate)).toHaveLength(3), ); - userEvent.click(screen.getByTestId('fundModalCloseBtn')); + await userEvent.click(screen.getByTestId('fundModalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('fundModalCloseBtn')).toBeNull(), ); @@ -144,14 +144,14 @@ describe('OrganizationFunds Screen =>', () => { const editFundBtn = await screen.findAllByTestId('editFundBtn'); await waitFor(() => expect(editFundBtn[0]).toBeInTheDocument()); - userEvent.click(editFundBtn[0]); + await userEvent.click(editFundBtn[0]); await waitFor(() => expect( screen.getAllByText(translations.fundUpdate)[0], ).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('fundModalCloseBtn')); + await userEvent.click(screen.getByTestId('fundModalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('fundModalCloseBtn')).toBeNull(), ); diff --git a/src/screens/OrganizationPeople/OrganizationPeople.spec.tsx b/src/screens/OrganizationPeople/OrganizationPeople.spec.tsx index 6d0926613f..80e7144ec0 100644 --- a/src/screens/OrganizationPeople/OrganizationPeople.spec.tsx +++ b/src/screens/OrganizationPeople/OrganizationPeople.spec.tsx @@ -828,19 +828,19 @@ describe('Organization People Page', () => { await wait(); const dropdownToggles = screen.getAllByTestId('role'); - dropdownToggles.forEach((dropdownToggle) => { - userEvent.click(dropdownToggle); + dropdownToggles.forEach(async (dropdownToggle) => { + await userEvent.click(dropdownToggle); }); const memebersDropdownItem = screen.getByTestId('members'); - userEvent.click(memebersDropdownItem); + await userEvent.click(memebersDropdownItem); await wait(); const findtext = screen.getByText(/Aditya Memberguy/i); await wait(); expect(findtext).toBeInTheDocument(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Full Name/i), searchData.fullNameMember, ); @@ -919,16 +919,16 @@ describe('Organization People Page', () => { , ); - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); expect(addmembersBtn).toBeInTheDocument(); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(newUserBtn).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); await waitFor(() => { @@ -979,16 +979,16 @@ describe('Organization People Page', () => { , ); - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); expect(addmembersBtn).toBeInTheDocument(); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(newUserBtn).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); await waitFor(() => { @@ -1058,16 +1058,16 @@ describe('Organization People Page', () => { ); // Open modal and fill form - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); expect(addmembersBtn).toBeInTheDocument(); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(newUserBtn).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); await waitFor(() => { @@ -1119,7 +1119,7 @@ describe('Organization People Page', () => { const fullNameInput = screen.getByPlaceholderText(/Enter Full Name/i); // Only First Name - userEvent.type(fullNameInput, searchData.fullNameMember); + await userEvent.type(fullNameInput, searchData.fullNameMember); await wait(); let findtext = screen.getByText(/Aditya Memberguy/i); @@ -1161,16 +1161,16 @@ describe('Organization People Page', () => { const dropdownToggles = screen.getAllByTestId('role'); // Click the dropdown toggle to open the dropdown menu - dropdownToggles.forEach((dropdownToggle) => { - userEvent.click(dropdownToggle); + dropdownToggles.forEach(async (dropdownToggle) => { + await userEvent.click(dropdownToggle); }); // Click the "Admin" dropdown item const adminDropdownItem = screen.getByTestId('admins'); - userEvent.click(adminDropdownItem); + await userEvent.click(adminDropdownItem); await wait(); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(/Enter Full Name/i), searchData.fullNameAdmin, ); @@ -1214,21 +1214,21 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('role')); + await userEvent.click(screen.getByTestId('role')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('admins')); + await userEvent.click(screen.getByTestId('admins')); await wait(); // Type the full name into the input field const fullNameInput = screen.getByPlaceholderText(/Enter Full Name/i); - userEvent.type(fullNameInput, searchData.fullNameAdmin); + await userEvent.type(fullNameInput, searchData.fullNameAdmin); // Wait for the results to update await wait(); const btn = screen.getByTestId('searchbtn'); - userEvent.click(btn); + await userEvent.click(btn); // remove this comment when table fecthing functionality is fixed // Check if the expected name is present in the results // let findtext = screen.getByText(/Aditya Adminguy/i); @@ -1264,13 +1264,13 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); expect(screen.getByTestId('existingUser')).toBeInTheDocument(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('existingUser')); + await userEvent.click(screen.getByTestId('existingUser')); await wait(); expect( @@ -1279,7 +1279,7 @@ describe('Organization People Page', () => { await wait(); const addBtn = screen.getAllByTestId('addBtn'); - userEvent.click(addBtn[0]); + await userEvent.click(addBtn[0]); }); test('Open and search existing user', async () => { @@ -1307,11 +1307,11 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('existingUser')); + await userEvent.click(screen.getByTestId('existingUser')); await wait(); expect(screen.getByTestId('addExistingUserModal')).toBeInTheDocument(); @@ -1346,16 +1346,16 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('newUser')); + await userEvent.click(screen.getByTestId('newUser')); await wait(); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); - userEvent.click(screen.getByTestId('closeBtn')); + await userEvent.click(screen.getByTestId('closeBtn')); }); test('Testing add new user modal', async () => { @@ -1383,11 +1383,11 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('newUser')); + await userEvent.click(screen.getByTestId('newUser')); await wait(); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); @@ -1410,18 +1410,18 @@ describe('Organization People Page', () => { fireEvent.change(screen.getByTestId('passwordInput'), { target: { value: 'dishatalreja' }, }); - userEvent.click(screen.getByTestId('showPassword')); + await userEvent.click(screen.getByTestId('showPassword')); expect(screen.getByTestId('passwordInput')).toHaveValue('dishatalreja'); fireEvent.change(screen.getByTestId('confirmPasswordInput'), { target: { value: 'dishatalreja' }, }); - userEvent.click(screen.getByTestId('showConfirmPassword')); + await userEvent.click(screen.getByTestId('showConfirmPassword')); expect(screen.getByTestId('confirmPasswordInput')).toHaveValue( 'dishatalreja', ); - userEvent.click(screen.getByTestId('createBtn')); + await userEvent.click(screen.getByTestId('createBtn')); }); test('Throw invalid details error in add new user modal', async () => { @@ -1449,11 +1449,11 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('newUser')); + await userEvent.click(screen.getByTestId('newUser')); await wait(); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); @@ -1476,16 +1476,16 @@ describe('Organization People Page', () => { fireEvent.change(screen.getByTestId('passwordInput'), { target: { value: 'dishatalreja' }, }); - userEvent.click(screen.getByTestId('showPassword')); + await userEvent.click(screen.getByTestId('showPassword')); expect(screen.getByTestId('passwordInput')).toHaveValue('dishatalreja'); fireEvent.change(screen.getByTestId('confirmPasswordInput'), { target: { value: 'disha' }, }); - userEvent.click(screen.getByTestId('showConfirmPassword')); + await userEvent.click(screen.getByTestId('showConfirmPassword')); expect(screen.getByTestId('confirmPasswordInput')).toHaveValue('disha'); - userEvent.click(screen.getByTestId('createBtn')); + await userEvent.click(screen.getByTestId('createBtn')); }); test('Throw passwordNotMatch error in add new user modal', async () => { @@ -1513,11 +1513,11 @@ describe('Organization People Page', () => { await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('newUser')); + await userEvent.click(screen.getByTestId('newUser')); await wait(); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); @@ -1535,18 +1535,18 @@ describe('Organization People Page', () => { fireEvent.change(screen.getByTestId('passwordInput'), { target: { value: 'dishatalreja' }, }); - userEvent.click(screen.getByTestId('showPassword')); + await userEvent.click(screen.getByTestId('showPassword')); expect(screen.getByTestId('passwordInput')).toHaveValue('dishatalreja'); fireEvent.change(screen.getByTestId('confirmPasswordInput'), { target: { value: 'dishatalreja' }, }); - userEvent.click(screen.getByTestId('showConfirmPassword')); + await userEvent.click(screen.getByTestId('showConfirmPassword')); expect(screen.getByTestId('confirmPasswordInput')).toHaveValue( 'dishatalreja', ); - userEvent.click(screen.getByTestId('createBtn')); + await userEvent.click(screen.getByTestId('createBtn')); }); test('Testing USERS list', async () => { @@ -1577,15 +1577,15 @@ describe('Organization People Page', () => { const dropdownToggles = screen.getAllByTestId('role'); - dropdownToggles.forEach((dropdownToggle) => { - userEvent.click(dropdownToggle); + dropdownToggles.forEach(async (dropdownToggle) => { + await userEvent.click(dropdownToggle); }); const usersDropdownItem = screen.getByTestId('users'); - userEvent.click(usersDropdownItem); + await userEvent.click(usersDropdownItem); await wait(); const btn = screen.getByTestId('searchbtn'); - userEvent.click(btn); + await userEvent.click(btn); await wait(); expect(window.location.href).toBe( 'http://localhost/orgpeople/6401ff65ce8e8406b8f07af1', @@ -1618,9 +1618,9 @@ describe('Organization People Page', () => { const fullNameInput = screen.getByPlaceholderText(/Enter Full Name/i); // Only Full Name - userEvent.type(fullNameInput, searchData.fullNameUser); + await userEvent.type(fullNameInput, searchData.fullNameUser); const btn = screen.getByTestId('searchbtn'); - userEvent.click(btn); + await userEvent.click(btn); await wait(); expect(window.location.href).toBe( 'http://localhost/orgpeople/6401ff65ce8e8406b8f07af2', @@ -1647,12 +1647,12 @@ describe('Organization People Page', () => { , ); await wait(); - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); - userEvent.click(screen.getByTestId('existingUser')); + await userEvent.click(screen.getByTestId('existingUser')); await wait(); const btn = screen.getByTestId('submitBtn'); - userEvent.click(btn); + await userEvent.click(btn); }); test('Datagrid renders with members data', async () => { @@ -1670,7 +1670,7 @@ describe('Organization People Page', () => { const dataGrid = screen.getByRole('grid'); expect(dataGrid).toBeInTheDocument(); const removeButtons = screen.getAllByTestId('removeMemberModalBtn'); - userEvent.click(removeButtons[0]); + await userEvent.click(removeButtons[0]); }); test('Datagrid renders with admin data', async () => { @@ -1687,14 +1687,14 @@ describe('Organization People Page', () => { await wait(); const dropdownToggles = screen.getAllByTestId('role'); - dropdownToggles.forEach((dropdownToggle) => { - userEvent.click(dropdownToggle); + dropdownToggles.forEach(async (dropdownToggle) => { + await userEvent.click(dropdownToggle); }); const adminDropdownItem = screen.getByTestId('admins'); - userEvent.click(adminDropdownItem); + await userEvent.click(adminDropdownItem); await wait(); const removeButtons = screen.getAllByTestId('removeAdminModalBtn'); - userEvent.click(removeButtons[0]); + await userEvent.click(removeButtons[0]); }); test('No Mock Data test', async () => { @@ -1888,11 +1888,11 @@ test('Open and check if profile image is displayed for existing user', async () await wait(); // Click on the dropdown toggle to open the menu - userEvent.click(screen.getByTestId('addMembers')); + await userEvent.click(screen.getByTestId('addMembers')); await wait(); // Click on the "Admins" option in the dropdown menu - userEvent.click(screen.getByTestId('existingUser')); + await userEvent.click(screen.getByTestId('existingUser')); await wait(); expect(screen.getByTestId('addExistingUserModal')).toBeInTheDocument(); @@ -1937,16 +1937,16 @@ test('opening add user modal', async () => { await wait(); const addmemberBtn = screen.getByTestId('addMembers'); - userEvent.click(addmemberBtn); + await userEvent.click(addmemberBtn); const existUserBtn = screen.getByTestId('existingUser'); - userEvent.click(existUserBtn); + await userEvent.click(existUserBtn); expect(screen.getByTestId('addExistingUserModal')).toBeInTheDocument(); expect(screen.getByTestId('pluginNotificationHeader')).toBeInTheDocument(); const closeButton = screen.getByLabelText('Close'); - userEvent.click(closeButton); + await userEvent.click(closeButton); await wait(); expect(screen.queryByTestId('addExistingUserModal')).not.toBeInTheDocument(); }); @@ -1976,34 +1976,34 @@ test('modal state management - open, close, and toggle', async () => { expect(screen.queryByTestId('addNewUserModal')).not.toBeInTheDocument(); - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(screen.getByTestId('newUser')).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); const modalHeader = screen.getByTestId('createUser'); - userEvent.click(modalHeader); + await userEvent.click(modalHeader); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); const closeBtn = screen.getByTestId('closeBtn'); - userEvent.click(closeBtn); + await userEvent.click(closeBtn); await waitFor(() => { expect(screen.queryByTestId('addNewUserModal')).not.toBeInTheDocument(); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); @@ -2011,13 +2011,13 @@ test('modal state management - open, close, and toggle', async () => { const modal = screen.getByTestId('addNewUserModal'); fireEvent.keyDown(modal, { key: 'Escape', code: 'Escape' }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); const firstNameInput = screen.getByTestId('firstNameInput'); - userEvent.type(firstNameInput, 'John'); + await userEvent.type(firstNameInput, 'John'); fireEvent.keyDown(modal, { key: 'Escape', code: 'Escape' }); }); @@ -2043,25 +2043,25 @@ test('testing out toast errors', async () => { , ); - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(screen.getByTestId('newUser')).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); const modalHeader = screen.getByTestId('createUser'); - userEvent.click(modalHeader); + await userEvent.click(modalHeader); const createBtn = screen.getByTestId('createBtn'); expect(createBtn).toBeInTheDocument(); - userEvent.click(createBtn); + await userEvent.click(createBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -2101,35 +2101,35 @@ test('handles GraphQL error when adding member', async () => { await wait(); - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(screen.getByTestId('newUser')).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); const modalHeader = screen.getByTestId('createUser'); - userEvent.click(modalHeader); + await userEvent.click(modalHeader); const firstNameInput = screen.getByTestId('firstNameInput'); const lastNameInput = screen.getByTestId('lastNameInput'); const emailInput = screen.getByTestId('emailInput'); const passwordInput = screen.getByTestId('passwordInput'); - userEvent.type(firstNameInput, 'Abhishek'); - userEvent.type(lastNameInput, 'Raj'); - userEvent.type(emailInput, 'test@gmail.com'); - userEvent.type(passwordInput, 'abhishek'); + await userEvent.type(firstNameInput, 'Abhishek'); + await userEvent.type(lastNameInput, 'Raj'); + await userEvent.type(emailInput, 'test@gmail.com'); + await userEvent.type(passwordInput, 'abhishek'); const createBtn = screen.getByTestId('createBtn'); expect(createBtn).toBeInTheDocument(); - userEvent.click(createBtn); + await userEvent.click(createBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -2168,15 +2168,15 @@ test('createMember handles error and shows toast notification', async () => { , ); - await waitFor(() => { + await waitFor(async () => { const addmembersBtn = screen.getByTestId('addMembers'); - userEvent.click(addmembersBtn); + await userEvent.click(addmembersBtn); }); - await waitFor(() => { + await waitFor(async () => { const newUserBtn = screen.getByTestId('newUser'); expect(screen.getByTestId('newUser')).toBeInTheDocument(); - userEvent.click(newUserBtn); + await userEvent.click(newUserBtn); }); expect(screen.getByTestId('addNewUserModal')).toBeInTheDocument(); diff --git a/src/screens/OrganizationTags/OrganizationTags.spec.tsx b/src/screens/OrganizationTags/OrganizationTags.spec.tsx index 0ef64d538b..226e70627b 100644 --- a/src/screens/OrganizationTags/OrganizationTags.spec.tsx +++ b/src/screens/OrganizationTags/OrganizationTags.spec.tsx @@ -128,14 +128,14 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('createTagBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createTagBtn')); + await userEvent.click(screen.getByTestId('createTagBtn')); await waitFor(() => { return expect( screen.findByTestId('closeCreateTagModal'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('closeCreateTagModal')); + await userEvent.click(screen.getByTestId('closeCreateTagModal')); await waitForElementToBeRemoved(() => screen.queryByTestId('closeCreateTagModal'), @@ -149,7 +149,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('tagName')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('tagName')[0]); + await userEvent.click(screen.getAllByTestId('tagName')[0]); await waitFor(() => { expect(screen.getByTestId('subTagsScreen')).toBeInTheDocument(); @@ -163,7 +163,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('manageTagBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('manageTagBtn')[0]); + await userEvent.click(screen.getAllByTestId('manageTagBtn')[0]); await waitFor(() => { expect(screen.getByTestId('manageTagScreen')).toBeInTheDocument(); @@ -214,12 +214,12 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('sortTags')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('sortTags')); + await userEvent.click(screen.getByTestId('sortTags')); await waitFor(() => { expect(screen.getByTestId('oldest')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('oldest')); + await userEvent.click(screen.getByTestId('oldest')); // returns the tags in reverse order await waitFor(() => { @@ -231,12 +231,12 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('sortTags')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('sortTags')); + await userEvent.click(screen.getByTestId('sortTags')); await waitFor(() => { expect(screen.getByTestId('latest')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('latest')); + await userEvent.click(screen.getByTestId('latest')); // reverse the order again await waitFor(() => { @@ -281,20 +281,20 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('createTagBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('createTagBtn')); + await userEvent.click(screen.getByTestId('createTagBtn')); - userEvent.click(screen.getByTestId('createTagSubmitBtn')); + await userEvent.click(screen.getByTestId('createTagSubmitBtn')); await waitFor(() => { expect(toast.error).toHaveBeenCalledWith(translations.enterTagName); }); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.tagNamePlaceholder), 'userTag 12', ); - userEvent.click(screen.getByTestId('createTagSubmitBtn')); + await userEvent.click(screen.getByTestId('createTagSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( diff --git a/src/screens/Requests/Requests.spec.tsx b/src/screens/Requests/Requests.spec.tsx index 820b24c40d..53f1910dd1 100644 --- a/src/screens/Requests/Requests.spec.tsx +++ b/src/screens/Requests/Requests.spec.tsx @@ -174,25 +174,25 @@ describe('Testing Requests screen', () => { await wait(); const searchBtn = screen.getByTestId('searchButton'); const search1 = 'John'; - userEvent.type(screen.getByTestId(/searchByName/i), search1); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId(/searchByName/i), search1); + await userEvent.click(searchBtn); await wait(); const search2 = 'Pete{backspace}{backspace}{backspace}{backspace}'; - userEvent.type(screen.getByTestId(/searchByName/i), search2); + await userEvent.type(screen.getByTestId(/searchByName/i), search2); const search3 = 'John{backspace}{backspace}{backspace}{backspace}Sam{backspace}{backspace}{backspace}'; - userEvent.type(screen.getByTestId(/searchByName/i), search3); + await userEvent.type(screen.getByTestId(/searchByName/i), search3); const search4 = 'Sam{backspace}{backspace}P{backspace}'; - userEvent.type(screen.getByTestId(/searchByName/i), search4); + await userEvent.type(screen.getByTestId(/searchByName/i), search4); const search5 = 'Xe'; - userEvent.type(screen.getByTestId(/searchByName/i), search5); - userEvent.clear(screen.getByTestId(/searchByName/i)); - userEvent.type(screen.getByTestId(/searchByName/i), ''); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId(/searchByName/i), search5); + await userEvent.clear(screen.getByTestId(/searchByName/i)); + await userEvent.type(screen.getByTestId(/searchByName/i), ''); + await userEvent.click(searchBtn); await wait(); }); @@ -212,8 +212,9 @@ describe('Testing Requests screen', () => { await wait(); const search = 'hello{enter}'; - await act(() => - userEvent.type(screen.getByTestId(/searchByName/i), search), + await act( + async () => + await userEvent.type(screen.getByTestId(/searchByName/i), search), ); }); diff --git a/src/screens/SubTags/SubTags.spec.tsx b/src/screens/SubTags/SubTags.spec.tsx index e61d3c98db..113dfd0003 100644 --- a/src/screens/SubTags/SubTags.spec.tsx +++ b/src/screens/SubTags/SubTags.spec.tsx @@ -146,14 +146,14 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('addSubTagBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('addSubTagBtn')); + await userEvent.click(screen.getByTestId('addSubTagBtn')); await waitFor(() => { return expect( screen.findByTestId('addSubTagModalCloseBtn'), ).resolves.toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('addSubTagModalCloseBtn')); + await userEvent.click(screen.getByTestId('addSubTagModalCloseBtn')); await waitForElementToBeRemoved(() => screen.queryByTestId('addSubTagModalCloseBtn'), @@ -168,7 +168,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('manageTagBtn')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('manageTagBtn')[0]); + await userEvent.click(screen.getAllByTestId('manageTagBtn')[0]); await waitFor(() => { expect(screen.getByTestId('manageTagScreen')).toBeInTheDocument(); @@ -183,7 +183,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('tagName')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('tagName')[0]); + await userEvent.click(screen.getAllByTestId('tagName')[0]); await waitFor(() => { expect(screen.getByTestId('addSubTagBtn')).toBeInTheDocument(); @@ -198,7 +198,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getAllByTestId('redirectToSubTags')[0]).toBeInTheDocument(); }); - userEvent.click(screen.getAllByTestId('redirectToSubTags')[0]); + await userEvent.click(screen.getAllByTestId('redirectToSubTags')[0]); await waitFor(() => { expect(screen.getByTestId('addSubTagBtn')).toBeInTheDocument(); @@ -213,7 +213,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('allTagsBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('allTagsBtn')); + await userEvent.click(screen.getByTestId('allTagsBtn')); await waitFor(() => { expect(screen.getByTestId('orgtagsScreen')).toBeInTheDocument(); @@ -228,7 +228,7 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('manageCurrentTagBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('manageCurrentTagBtn')); + await userEvent.click(screen.getByTestId('manageCurrentTagBtn')); await waitFor(() => { expect(screen.getByTestId('manageTagScreen')).toBeInTheDocument(); @@ -281,12 +281,12 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('sortTags')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('sortTags')); + await userEvent.click(screen.getByTestId('sortTags')); await waitFor(() => { expect(screen.getByTestId('ASCENDING')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('ASCENDING')); + await userEvent.click(screen.getByTestId('ASCENDING')); // returns the tags in reverse order await waitFor(() => { @@ -298,12 +298,12 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('sortTags')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('sortTags')); + await userEvent.click(screen.getByTestId('sortTags')); await waitFor(() => { expect(screen.getByTestId('DESCENDING')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('DESCENDING')); + await userEvent.click(screen.getByTestId('DESCENDING')); // reverse the order again await waitFor(() => { @@ -350,14 +350,14 @@ describe('Organisation Tags Page', () => { await waitFor(() => { expect(screen.getByTestId('addSubTagBtn')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('addSubTagBtn')); + await userEvent.click(screen.getByTestId('addSubTagBtn')); - userEvent.type( + await userEvent.type( screen.getByPlaceholderText(translations.tagNamePlaceholder), 'subTag 12', ); - userEvent.click(screen.getByTestId('addSubTagSubmitBtn')); + await userEvent.click(screen.getByTestId('addSubTagSubmitBtn')); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith( diff --git a/src/screens/UserPortal/Campaigns/Campaigns.spec.tsx b/src/screens/UserPortal/Campaigns/Campaigns.spec.tsx index 09cde6b25d..095e3cb9c2 100644 --- a/src/screens/UserPortal/Campaigns/Campaigns.spec.tsx +++ b/src/screens/UserPortal/Campaigns/Campaigns.spec.tsx @@ -217,11 +217,11 @@ describe('Testing User Campaigns Screen', () => { const searchCampaigns = await screen.findByTestId('searchCampaigns'); expect(searchCampaigns).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('fundingGoal_ASC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('fundingGoal_ASC')); + await userEvent.click(screen.getByTestId('fundingGoal_ASC')); await waitFor(() => { expect(screen.getByText('School Campaign')).toBeInTheDocument(); @@ -243,11 +243,11 @@ describe('Testing User Campaigns Screen', () => { const searchCampaigns = await screen.findByTestId('searchCampaigns'); expect(searchCampaigns).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('fundingGoal_DESC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('fundingGoal_DESC')); + await userEvent.click(screen.getByTestId('fundingGoal_DESC')); await waitFor(() => { expect(screen.getByText('School Campaign')).toBeInTheDocument(); @@ -269,11 +269,11 @@ describe('Testing User Campaigns Screen', () => { const searchCampaigns = await screen.findByTestId('searchCampaigns'); expect(searchCampaigns).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('endDate_ASC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('endDate_ASC')); + await userEvent.click(screen.getByTestId('endDate_ASC')); await waitFor(() => { expect(screen.getByText('School Campaign')).toBeInTheDocument(); @@ -295,11 +295,11 @@ describe('Testing User Campaigns Screen', () => { const searchCampaigns = await screen.findByTestId('searchCampaigns'); expect(searchCampaigns).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('endDate_DESC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('endDate_DESC')); + await userEvent.click(screen.getByTestId('endDate_DESC')); await waitFor(() => { expect(screen.getByText('School Campaign')).toBeInTheDocument(); @@ -336,12 +336,12 @@ describe('Testing User Campaigns Screen', () => { const addPledgeBtn = await screen.findAllByTestId('addPledgeBtn'); await waitFor(() => expect(addPledgeBtn[0]).toBeInTheDocument()); - userEvent.click(addPledgeBtn[0]); + await userEvent.click(addPledgeBtn[0]); await waitFor(() => expect(screen.getAllByText(pTranslations.createPledge)).toHaveLength(2), ); - userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); + await userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('pledgeModalCloseBtn')).toBeNull(), ); @@ -352,7 +352,7 @@ describe('Testing User Campaigns Screen', () => { const myPledgesBtn = await screen.findByText(cTranslations.myPledges); expect(myPledgesBtn).toBeInTheDocument(); - userEvent.click(myPledgesBtn); + await userEvent.click(myPledgesBtn); await waitFor(() => { expect(screen.getByTestId('pledgeScreen')).toBeInTheDocument(); diff --git a/src/screens/UserPortal/Donate/Donate.spec.tsx b/src/screens/UserPortal/Donate/Donate.spec.tsx index 2f235c9a01..d3123271ed 100644 --- a/src/screens/UserPortal/Donate/Donate.spec.tsx +++ b/src/screens/UserPortal/Donate/Donate.spec.tsx @@ -440,9 +440,9 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('changeCurrencyBtn')); + await userEvent.click(screen.getByTestId('changeCurrencyBtn')); - userEvent.click(screen.getByTestId('currency0')); + await userEvent.click(screen.getByTestId('currency0')); await wait(); expect(screen.getByTestId('currency0')).toBeInTheDocument(); @@ -463,9 +463,9 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('changeCurrencyBtn')); + await userEvent.click(screen.getByTestId('changeCurrencyBtn')); - userEvent.click(screen.getByTestId('currency1')); + await userEvent.click(screen.getByTestId('currency1')); await wait(); }); @@ -485,9 +485,9 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('changeCurrencyBtn')); + await userEvent.click(screen.getByTestId('changeCurrencyBtn')); - userEvent.click(screen.getByTestId('currency2')); + await userEvent.click(screen.getByTestId('currency2')); await wait(); }); @@ -527,8 +527,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '123'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '123'); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(); }); @@ -547,8 +547,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '0.5'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '0.5'); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(); @@ -572,8 +572,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '10000001'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '10000001'); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(); @@ -597,7 +597,7 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(); @@ -621,8 +621,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), 'abc'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), 'abc'); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(); @@ -650,8 +650,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), ' 123 '); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), ' 123 '); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(); expect(toast.success).toHaveBeenCalled(); @@ -728,7 +728,7 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); // Leave amount empty - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.click(screen.getByTestId('donateBtn')); expect(toast.error).toHaveBeenCalledWith( 'Please enter a numerical value for the donation amount.', @@ -794,8 +794,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), 'abc'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), 'abc'); + await userEvent.click(screen.getByTestId('donateBtn')); expect(toast.error).toHaveBeenCalledWith( 'Please enter a numerical value for the donation amount.', @@ -817,8 +817,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '0.5'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '0.5'); + await userEvent.click(screen.getByTestId('donateBtn')); expect(toast.error).toHaveBeenCalledWith( 'Donation amount must be between 1 and 10000000.', @@ -840,8 +840,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '10000001'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '10000001'); + await userEvent.click(screen.getByTestId('donateBtn')); expect(toast.error).toHaveBeenCalledWith( 'Donation amount must be between 1 and 10000000.', @@ -890,8 +890,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '100'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '100'); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(500); expect(mockErrorHandler).toHaveBeenCalledWith( @@ -944,8 +944,8 @@ describe('Testing Donate Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('donationAmount'), '100'); - userEvent.click(screen.getByTestId('donateBtn')); + await userEvent.type(screen.getByTestId('donationAmount'), '100'); + await userEvent.click(screen.getByTestId('donateBtn')); await wait(500); expect(mockErrorHandler).toHaveBeenCalled(); diff --git a/src/screens/UserPortal/Events/Events.spec.tsx b/src/screens/UserPortal/Events/Events.spec.tsx index 86d257a937..3abd50eb90 100644 --- a/src/screens/UserPortal/Events/Events.spec.tsx +++ b/src/screens/UserPortal/Events/Events.spec.tsx @@ -539,40 +539,43 @@ describe('Testing Events Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); const randomEventTitle = 'testEventTitle'; const randomEventDescription = 'testEventDescription'; const randomEventLocation = 'testEventLocation'; - userEvent.type(screen.getByTestId('eventTitleInput'), randomEventTitle); - userEvent.type( + await userEvent.type( + screen.getByTestId('eventTitleInput'), + randomEventTitle, + ); + await userEvent.type( screen.getByTestId('eventDescriptionInput'), randomEventDescription, ); - userEvent.type( + await userEvent.type( screen.getByTestId('eventLocationInput'), randomEventLocation, ); - userEvent.click(screen.getByTestId('publicEventCheck')); - userEvent.click(screen.getByTestId('publicEventCheck')); + await userEvent.click(screen.getByTestId('publicEventCheck')); + await userEvent.click(screen.getByTestId('publicEventCheck')); - userEvent.click(screen.getByTestId('registerableEventCheck')); - userEvent.click(screen.getByTestId('registerableEventCheck')); + await userEvent.click(screen.getByTestId('registerableEventCheck')); + await userEvent.click(screen.getByTestId('registerableEventCheck')); - userEvent.click(screen.getByTestId('recurringEventCheck')); - userEvent.click(screen.getByTestId('recurringEventCheck')); + await userEvent.click(screen.getByTestId('recurringEventCheck')); + await userEvent.click(screen.getByTestId('recurringEventCheck')); - userEvent.click(screen.getByTestId('recurringEventCheck')); - userEvent.click(screen.getByTestId('recurringEventCheck')); + await userEvent.click(screen.getByTestId('recurringEventCheck')); + await userEvent.click(screen.getByTestId('recurringEventCheck')); - userEvent.click(screen.getByTestId('createChatCheck')); - userEvent.click(screen.getByTestId('createChatCheck')); + await userEvent.click(screen.getByTestId('createChatCheck')); + await userEvent.click(screen.getByTestId('createChatCheck')); - userEvent.click(screen.getByTestId('allDayEventCheck')); + await userEvent.click(screen.getByTestId('allDayEventCheck')); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await wait(); @@ -599,23 +602,26 @@ describe('Testing Events Screen [User Portal]', () => { ); await wait(); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); const randomEventTitle = 'testEventTitle'; const randomEventDescription = 'testEventDescription'; const randomEventLocation = 'testEventLocation'; - userEvent.type(screen.getByTestId('eventTitleInput'), randomEventTitle); - userEvent.type( + await userEvent.type( + screen.getByTestId('eventTitleInput'), + randomEventTitle, + ); + await userEvent.type( screen.getByTestId('eventDescriptionInput'), randomEventDescription, ); - userEvent.type( + await userEvent.type( screen.getByTestId('eventLocationInput'), randomEventLocation, ); - userEvent.click(screen.getByTestId('createEventBtn')); + await userEvent.click(screen.getByTestId('createEventBtn')); await wait(); @@ -643,8 +649,8 @@ describe('Testing Events Screen [User Portal]', () => { // await wait(); - // userEvent.click(screen.getByTestId('modeChangeBtn')); - // userEvent.click(screen.getByTestId('modeBtn1')); + // await userEvent.click(screen.getByTestId('modeChangeBtn')); + // await userEvent.click(screen.getByTestId('modeBtn1')); await wait(); const calenderView = 'Calendar View'; @@ -670,7 +676,7 @@ describe('Testing Events Screen [User Portal]', () => { , ); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); // MM/DD/YYYY const startDate = new Date(); const endDate = new Date(); @@ -704,7 +710,7 @@ describe('Testing Events Screen [User Portal]', () => { expect(endDateDatePicker).toHaveValue(endDateDayjs.format('MM/DD/YYYY')); }); - userEvent.click(screen.getByTestId('allDayEventCheck')); + await userEvent.click(screen.getByTestId('allDayEventCheck')); expect(endTime).not.toBeNull(); const endTimePicker = screen.getByLabelText('End Time'); @@ -742,7 +748,7 @@ describe('Testing Events Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('createEventModalBtn')); + await userEvent.click(screen.getByTestId('createEventModalBtn')); const endDateDatePicker = screen.getByLabelText('End Date'); const startDateDatePicker = screen.getByLabelText('Start Date'); @@ -754,7 +760,7 @@ describe('Testing Events Screen [User Portal]', () => { target: { value: null }, }); - userEvent.click(screen.getByTestId('allDayEventCheck')); + await userEvent.click(screen.getByTestId('allDayEventCheck')); const endTimePicker = screen.getByLabelText('End Time'); const startTimePicker = screen.getByLabelText('Start Time'); diff --git a/src/screens/UserPortal/Organizations/Organizations.spec.tsx b/src/screens/UserPortal/Organizations/Organizations.spec.tsx index 0aafba3b55..ad6fcc0b4c 100644 --- a/src/screens/UserPortal/Organizations/Organizations.spec.tsx +++ b/src/screens/UserPortal/Organizations/Organizations.spec.tsx @@ -380,13 +380,13 @@ describe('Testing Organizations Screen [User Portal]', () => { await wait(); const searchBtn = screen.getByTestId('searchBtn'); - userEvent.type(screen.getByTestId('searchInput'), '2{enter}'); + await userEvent.type(screen.getByTestId('searchInput'), '2{enter}'); await wait(); expect(screen.queryByText('anyOrganization2')).toBeInTheDocument(); - userEvent.clear(screen.getByTestId('searchInput')); - userEvent.click(searchBtn); + await userEvent.clear(screen.getByTestId('searchInput')); + await userEvent.click(searchBtn); await wait(); }); @@ -409,9 +409,9 @@ describe('Testing Organizations Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('modeChangeBtn')); + await userEvent.click(screen.getByTestId('modeChangeBtn')); await wait(); - userEvent.click(screen.getByTestId('modeBtn1')); + await userEvent.click(screen.getByTestId('modeBtn1')); await wait(); expect(screen.queryAllByText('joinedOrganization')).not.toBe([]); @@ -436,9 +436,9 @@ describe('Testing Organizations Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('modeChangeBtn')); + await userEvent.click(screen.getByTestId('modeChangeBtn')); await wait(); - userEvent.click(screen.getByTestId('modeBtn2')); + await userEvent.click(screen.getByTestId('modeBtn2')); await wait(); expect(screen.queryAllByText('createdOrganization')).not.toBe([]); @@ -483,9 +483,9 @@ describe('Testing Organizations Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('modeChangeBtn')); + await userEvent.click(screen.getByTestId('modeChangeBtn')); await wait(); - userEvent.click(screen.getByTestId('modeBtn2')); + await userEvent.click(screen.getByTestId('modeBtn2')); await wait(); expect(screen.queryAllByText('createdOrganization')).not.toBe([]); @@ -565,7 +565,7 @@ describe('Testing Organizations Screen [User Portal]', () => { ); await wait(); const dropdown = screen.getByTestId('table-pagination'); - userEvent.click(dropdown); + await userEvent.click(dropdown); expect(screen.queryByText('-1')).not.toBeInTheDocument(); expect(screen.getByText('5')).toBeInTheDocument(); expect(screen.getByText('10')).toBeInTheDocument(); diff --git a/src/screens/UserPortal/Organizations/Organizations.tsx b/src/screens/UserPortal/Organizations/Organizations.tsx index 0ac148c730..4af939096b 100644 --- a/src/screens/UserPortal/Organizations/Organizations.tsx +++ b/src/screens/UserPortal/Organizations/Organizations.tsx @@ -140,6 +140,7 @@ export default function organizations(): JSX.Element { * @param _event - The event triggering the page change. * @param newPage - The new page number. */ + const handleChangePage = ( _event: React.MouseEvent | null, newPage: number, @@ -152,6 +153,7 @@ export default function organizations(): JSX.Element { * * @param event - The event triggering the change. */ + const handleChangeRowsPerPage = ( event: React.ChangeEvent, ): void => { diff --git a/src/screens/UserPortal/People/People.spec.tsx b/src/screens/UserPortal/People/People.spec.tsx index 801a07ba40..a0cbc84277 100644 --- a/src/screens/UserPortal/People/People.spec.tsx +++ b/src/screens/UserPortal/People/People.spec.tsx @@ -252,7 +252,7 @@ describe('Testing People Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('searchInput'), 'j{enter}'); + await userEvent.type(screen.getByTestId('searchInput'), 'j{enter}'); await wait(); expect(screen.queryByText('John Cena')).toBeInTheDocument(); @@ -274,11 +274,11 @@ describe('Testing People Screen [User Portal]', () => { await wait(); const searchBtn = screen.getByTestId('searchBtn'); - userEvent.type(screen.getByTestId('searchInput'), ''); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId('searchInput'), ''); + await userEvent.click(searchBtn); await wait(); - userEvent.type(screen.getByTestId('searchInput'), 'j'); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId('searchInput'), 'j'); + await userEvent.click(searchBtn); await wait(); expect(screen.queryByText('John Cena')).toBeInTheDocument(); @@ -300,9 +300,9 @@ describe('Testing People Screen [User Portal]', () => { await wait(); - userEvent.click(screen.getByTestId('modeChangeBtn')); + await userEvent.click(screen.getByTestId('modeChangeBtn')); await wait(); - userEvent.click(screen.getByTestId('modeBtn1')); + await userEvent.click(screen.getByTestId('modeBtn1')); await wait(); expect(screen.queryByText('Noble Admin')).toBeInTheDocument(); diff --git a/src/screens/UserPortal/Pledges/Pledge.spec.tsx b/src/screens/UserPortal/Pledges/Pledge.spec.tsx index a41d95687b..3ff0fcd10a 100644 --- a/src/screens/UserPortal/Pledges/Pledge.spec.tsx +++ b/src/screens/UserPortal/Pledges/Pledge.spec.tsx @@ -150,11 +150,11 @@ describe('Testing User Pledge Screen', () => { const searchPledger = await screen.findByTestId('searchPledges'); expect(searchPledger).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('amount_ASC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('amount_ASC')); + await userEvent.click(screen.getByTestId('amount_ASC')); await waitFor(() => { expect(screen.getByText('John Doe')).toBeInTheDocument(); @@ -172,11 +172,11 @@ describe('Testing User Pledge Screen', () => { const searchPledger = await screen.findByTestId('searchPledges'); expect(searchPledger).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('amount_DESC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('amount_DESC')); + await userEvent.click(screen.getByTestId('amount_DESC')); await waitFor(() => { expect(screen.getByText('John Doe')).toBeInTheDocument(); @@ -194,11 +194,11 @@ describe('Testing User Pledge Screen', () => { const searchPledger = await screen.findByTestId('searchPledges'); expect(searchPledger).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('endDate_ASC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('endDate_ASC')); + await userEvent.click(screen.getByTestId('endDate_ASC')); await waitFor(() => { expect(screen.getByText('John Doe')).toBeInTheDocument(); @@ -216,11 +216,11 @@ describe('Testing User Pledge Screen', () => { const searchPledger = await screen.findByTestId('searchPledges'); expect(searchPledger).toBeInTheDocument(); - userEvent.click(screen.getByTestId('filter')); + await userEvent.click(screen.getByTestId('filter')); await waitFor(() => { expect(screen.getByTestId('endDate_DESC')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('endDate_DESC')); + await userEvent.click(screen.getByTestId('endDate_DESC')); await waitFor(() => { expect(screen.getByText('John Doe')).toBeInTheDocument(); @@ -239,12 +239,12 @@ describe('Testing User Pledge Screen', () => { expect(screen.getByTestId('searchPledges')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('searchByDrpdwn')); + await userEvent.click(screen.getByTestId('searchByDrpdwn')); await waitFor(() => { expect(screen.getByTestId('pledgers')).toBeInTheDocument(); }); - userEvent.click(screen.getByTestId('pledgers')); + await userEvent.click(screen.getByTestId('pledgers')); const searchPledger = screen.getByTestId('searchPledges'); fireEvent.change(searchPledger, { @@ -296,7 +296,7 @@ describe('Testing User Pledge Screen', () => { }); const moreContainer = await screen.findAllByTestId('moreContainer'); - userEvent.click(moreContainer[0]); + await userEvent.click(moreContainer[0]); await waitFor(() => { expect(screen.getByTestId('extra1')).toBeInTheDocument(); @@ -307,7 +307,7 @@ describe('Testing User Pledge Screen', () => { expect(image).toHaveAttribute('src', 'image-url3'); }); - userEvent.click(moreContainer[0]); + await userEvent.click(moreContainer[0]); await waitFor(() => { expect(screen.queryByText('Jeramy Gracia')).toBeNull(); expect(screen.queryByText('Praise Norris')).toBeNull(); @@ -319,12 +319,14 @@ describe('Testing User Pledge Screen', () => { const deletePledgeBtn = await screen.findAllByTestId('deletePledgeBtn'); await waitFor(() => expect(deletePledgeBtn[0]).toBeInTheDocument()); - userEvent.click(deletePledgeBtn[0]); + await userEvent.click(deletePledgeBtn[0]); await waitFor(() => expect(screen.getByText(translations.deletePledge)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('deletePledgeCloseBtn')); + + await userEvent.click(screen.getByTestId('deletePledgeCloseBtn')); + await waitFor(() => expect(screen.queryByTestId('deletePledgeCloseBtn')).toBeNull(), ); @@ -335,12 +337,13 @@ describe('Testing User Pledge Screen', () => { const editPledgeBtn = await screen.findAllByTestId('editPledgeBtn'); await waitFor(() => expect(editPledgeBtn[0]).toBeInTheDocument()); - userEvent.click(editPledgeBtn[0]); + await userEvent.click(editPledgeBtn[0]); await waitFor(() => expect(screen.getByText(translations.editPledge)).toBeInTheDocument(), ); - userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); + + await userEvent.click(screen.getByTestId('pledgeModalCloseBtn')); await waitFor(() => expect(screen.queryByTestId('pledgeModalCloseBtn')).toBeNull(), ); diff --git a/src/screens/UserPortal/Posts/Posts.spec.tsx b/src/screens/UserPortal/Posts/Posts.spec.tsx index 83b626ba20..7c77f69ee0 100644 --- a/src/screens/UserPortal/Posts/Posts.spec.tsx +++ b/src/screens/UserPortal/Posts/Posts.spec.tsx @@ -309,7 +309,7 @@ describe('Testing Home Screen: User Portal', () => { const startPostBtn = await screen.findByTestId('postBtn'); expect(startPostBtn).toBeInTheDocument(); - userEvent.click(startPostBtn); + await userEvent.click(startPostBtn); const startPostModal = screen.getByTestId('startPostModal'); expect(startPostModal).toBeInTheDocument(); }); @@ -318,7 +318,7 @@ describe('Testing Home Screen: User Portal', () => { renderHomeScreen(); await wait(); - userEvent.upload( + await userEvent.upload( screen.getByTestId('postImageInput'), new File(['image content'], 'image.png', { type: 'image/png' }), ); @@ -327,11 +327,11 @@ describe('Testing Home Screen: User Portal', () => { const startPostBtn = await screen.findByTestId('postBtn'); expect(startPostBtn).toBeInTheDocument(); - userEvent.click(startPostBtn); + await userEvent.click(startPostBtn); const startPostModal = screen.getByTestId('startPostModal'); expect(startPostModal).toBeInTheDocument(); - userEvent.type(screen.getByTestId('postInput'), 'some content'); + await userEvent.type(screen.getByTestId('postInput'), 'some content'); expect(screen.getByTestId('postInput')).toHaveValue('some content'); await screen.findByAltText('Post Image Preview'); @@ -340,7 +340,7 @@ describe('Testing Home Screen: User Portal', () => { const closeButton = within(startPostModal).getByRole('button', { name: /close/i, }); - userEvent.click(closeButton); + await userEvent.click(closeButton); const closedModalText = screen.queryByText(/somethingOnYourMind/i); expect(closedModalText).not.toBeInTheDocument(); @@ -371,9 +371,9 @@ describe('Testing Home Screen: User Portal', () => { renderHomeScreen(); expect(screen.queryAllByTestId('dropdown')).not.toBeNull(); const dropdowns = await screen.findAllByTestId('dropdown'); - userEvent.click(dropdowns[1]); + await userEvent.click(dropdowns[1]); const deleteButton = await screen.findByTestId('deletePost'); - userEvent.click(deleteButton); + await userEvent.click(deleteButton); }); }); diff --git a/src/screens/UserPortal/Settings/Settings.spec.tsx b/src/screens/UserPortal/Settings/Settings.spec.tsx index f24c59d50a..0d6224619e 100644 --- a/src/screens/UserPortal/Settings/Settings.spec.tsx +++ b/src/screens/UserPortal/Settings/Settings.spec.tsx @@ -254,25 +254,31 @@ describe('Testing Settings Screen [User Portal]', () => { await wait(); - userEvent.type(screen.getByTestId('inputFirstName'), 'Noble'); + await userEvent.type(screen.getByTestId('inputFirstName'), 'Noble'); await wait(); - userEvent.type(screen.getByTestId('inputLastName'), 'Mittal'); + await userEvent.type(screen.getByTestId('inputLastName'), 'Mittal'); await wait(); - userEvent.selectOptions(screen.getByTestId('inputGender'), 'Male'); + await userEvent.selectOptions(screen.getByTestId('inputGender'), 'Male'); await wait(); - userEvent.type(screen.getByTestId('inputPhoneNumber'), '1234567890'); + await userEvent.type(screen.getByTestId('inputPhoneNumber'), '1234567890'); await wait(); - userEvent.selectOptions(screen.getByTestId('inputGrade'), 'Grade-1'); + await userEvent.selectOptions(screen.getByTestId('inputGrade'), 'Grade-1'); await wait(); - userEvent.selectOptions(screen.getByTestId('inputEmpStatus'), 'Unemployed'); + await userEvent.selectOptions( + screen.getByTestId('inputEmpStatus'), + 'Unemployed', + ); await wait(); - userEvent.selectOptions(screen.getByTestId('inputMaritalStatus'), 'Single'); + await userEvent.selectOptions( + screen.getByTestId('inputMaritalStatus'), + 'Single', + ); await wait(); - userEvent.type(screen.getByTestId('inputAddress'), 'random'); + await userEvent.type(screen.getByTestId('inputAddress'), 'random'); await wait(); - userEvent.type(screen.getByTestId('inputState'), 'random'); + await userEvent.type(screen.getByTestId('inputState'), 'random'); await wait(); - userEvent.selectOptions(screen.getByTestId('inputCountry'), 'IN'); + await userEvent.selectOptions(screen.getByTestId('inputCountry'), 'IN'); await wait(); expect(screen.getByTestId('resetChangesBtn')).toBeInTheDocument(); await wait(); @@ -283,13 +289,13 @@ describe('Testing Settings Screen [User Portal]', () => { await wait(); const fileInp = screen.getByTestId('fileInput'); fileInp.style.display = 'block'; - userEvent.click(screen.getByTestId('uploadImageBtn')); + await userEvent.click(screen.getByTestId('uploadImageBtn')); await wait(); const imageFile = new File(['(⌐□_□)'], 'profile-image.jpg', { type: 'image/jpeg', }); const files = [imageFile]; - userEvent.upload(fileInp, files); + await userEvent.upload(fileInp, files); await wait(); expect(screen.getByTestId('profile-picture')).toBeInTheDocument(); }); @@ -310,9 +316,9 @@ describe('Testing Settings Screen [User Portal]', () => { }); await wait(); - userEvent.type(screen.getByTestId('inputAddress'), 'random'); + await userEvent.type(screen.getByTestId('inputAddress'), 'random'); await wait(); - userEvent.click(screen.getByTestId('resetChangesBtn')); + await userEvent.click(screen.getByTestId('resetChangesBtn')); await wait(); expect(screen.getByTestId('inputFirstName')).toHaveValue('John'); expect(screen.getByTestId('inputLastName')).toHaveValue('Doe'); @@ -343,9 +349,9 @@ describe('Testing Settings Screen [User Portal]', () => { }); await wait(); - userEvent.type(screen.getByTestId('inputAddress'), 'random'); + await userEvent.type(screen.getByTestId('inputAddress'), 'random'); await wait(); - userEvent.click(screen.getByTestId('resetChangesBtn')); + await userEvent.click(screen.getByTestId('resetChangesBtn')); await wait(); expect(screen.getByTestId('inputFirstName')).toHaveValue(''); expect(screen.getByTestId('inputLastName')).toHaveValue(''); diff --git a/src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx b/src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx index dea26c5fe1..7664be85eb 100644 --- a/src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx +++ b/src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx @@ -179,13 +179,13 @@ describe('Testing Actions Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expectVitestToBeInTheDocument(searchToggle); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByAssignee = await screen.findByTestId('assignee'); expectVitestToBeInTheDocument(searchByAssignee); - userEvent.click(searchByAssignee); + await userEvent.click(searchByAssignee); - userEvent.type(searchInput, '1'); + await userEvent.type(searchInput, '1'); }); await debounceWait(); @@ -203,13 +203,13 @@ describe('Testing Actions Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expectVitestToBeInTheDocument(searchToggle); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByCategory = await screen.findByTestId('category'); expectVitestToBeInTheDocument(searchByCategory); - userEvent.click(searchByCategory); + await userEvent.click(searchByCategory); - userEvent.type(searchInput, '1'); + await userEvent.type(searchInput, '1'); }); await debounceWait(); @@ -240,25 +240,25 @@ describe('Testing Actions Screen', () => { renderActions(link1); const checkbox = await screen.findAllByTestId('statusCheckbox'); - userEvent.click(checkbox[0]); + await userEvent.click(checkbox[0]); await waitFor(async () => { const element = await screen.findByText(t.actionItemStatus); // Resolve the promise expectVitestToBeInTheDocument(element); // Now assert the resolved element }); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); it('Open and close ItemViewModal', async () => { renderActions(link1); const viewItemBtn = await screen.findAllByTestId('viewItemBtn'); - userEvent.click(viewItemBtn[0]); + await userEvent.click(viewItemBtn[0]); await waitFor(() => { expectVitestToBeInTheDocument(screen.getByText(t.actionItemDetails)); }); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); }); diff --git a/src/screens/UserPortal/Volunteer/Groups/GroupModal.spec.tsx b/src/screens/UserPortal/Volunteer/Groups/GroupModal.spec.tsx index 2bfed36882..87beb4624c 100644 --- a/src/screens/UserPortal/Volunteer/Groups/GroupModal.spec.tsx +++ b/src/screens/UserPortal/Volunteer/Groups/GroupModal.spec.tsx @@ -145,7 +145,7 @@ describe('Testing GroupModal', () => { const requestsBtn = screen.getByText(t.requests); expect(requestsBtn).toBeInTheDocument(); - userEvent.click(requestsBtn); + await userEvent.click(requestsBtn); const userName = await screen.findAllByTestId('userName'); expect(userName).toHaveLength(2); @@ -154,7 +154,7 @@ describe('Testing GroupModal', () => { const acceptBtn = screen.getAllByTestId('acceptBtn'); expect(acceptBtn).toHaveLength(2); - userEvent.click(acceptBtn[0]); + await userEvent.click(acceptBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.requestAccepted); }); @@ -166,7 +166,7 @@ describe('Testing GroupModal', () => { const requestsBtn = screen.getByText(t.requests); expect(requestsBtn).toBeInTheDocument(); - userEvent.click(requestsBtn); + await userEvent.click(requestsBtn); const userName = await screen.findAllByTestId('userName'); expect(userName).toHaveLength(2); @@ -175,7 +175,7 @@ describe('Testing GroupModal', () => { const rejectBtn = screen.getAllByTestId('rejectBtn'); expect(rejectBtn).toHaveLength(2); - userEvent.click(rejectBtn[0]); + await userEvent.click(rejectBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.requestRejected); }); @@ -187,11 +187,11 @@ describe('Testing GroupModal', () => { const requestsBtn = screen.getByText(t.requests); expect(requestsBtn).toBeInTheDocument(); - userEvent.click(requestsBtn); + await userEvent.click(requestsBtn); const detailsBtn = await screen.findByText(t.details); expect(detailsBtn).toBeInTheDocument(); - userEvent.click(detailsBtn); + await userEvent.click(detailsBtn); }); it('GroupModal -> Details -> Update', async () => { @@ -215,7 +215,7 @@ describe('Testing GroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.volunteerGroupUpdated); @@ -245,7 +245,7 @@ describe('Testing GroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); @@ -258,7 +258,7 @@ describe('Testing GroupModal', () => { const requestsBtn = screen.getByText(t.requests); expect(requestsBtn).toBeInTheDocument(); - userEvent.click(requestsBtn); + await userEvent.click(requestsBtn); const userName = await screen.findAllByTestId('userName'); expect(userName).toHaveLength(2); @@ -267,7 +267,7 @@ describe('Testing GroupModal', () => { const acceptBtn = screen.getAllByTestId('acceptBtn'); expect(acceptBtn).toHaveLength(2); - userEvent.click(acceptBtn[0]); + await userEvent.click(acceptBtn[0]); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); }); @@ -285,8 +285,8 @@ describe('Testing GroupModal', () => { expect(vrInput).toHaveValue(''); }); - userEvent.clear(vrInput); - userEvent.type(vrInput, '1{backspace}'); + await userEvent.clear(vrInput); + await userEvent.type(vrInput, '1{backspace}'); await waitFor(() => { expect(vrInput).toHaveValue(''); @@ -309,7 +309,7 @@ describe('Testing GroupModal', () => { const submitBtn = screen.getByTestId('submitBtn'); expect(submitBtn).toBeInTheDocument(); - userEvent.click(submitBtn); + await userEvent.click(submitBtn); await waitFor(() => { expect(toast.success).toHaveBeenCalled(); diff --git a/src/screens/UserPortal/Volunteer/Groups/Groups.spec.tsx b/src/screens/UserPortal/Volunteer/Groups/Groups.spec.tsx index b9bf6c29c0..715d365648 100644 --- a/src/screens/UserPortal/Volunteer/Groups/Groups.spec.tsx +++ b/src/screens/UserPortal/Volunteer/Groups/Groups.spec.tsx @@ -188,13 +188,13 @@ describe('Testing Groups Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expect(searchToggle).toBeInTheDocument(); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByGroup = await screen.findByTestId('group'); expect(searchByGroup).toBeInTheDocument(); - userEvent.click(searchByGroup); + await userEvent.click(searchByGroup); - userEvent.type(searchInput, '1'); + await userEvent.type(searchInput, '1'); await debounceWait(); const groupName = await screen.findAllByTestId('groupName'); @@ -211,14 +211,14 @@ describe('Testing Groups Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expect(searchToggle).toBeInTheDocument(); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByLeader = await screen.findByTestId('leader'); expect(searchByLeader).toBeInTheDocument(); - userEvent.click(searchByLeader); + await userEvent.click(searchByLeader); // Search by name on press of ENTER - userEvent.type(searchInput, 'Bruce'); + await userEvent.type(searchInput, 'Bruce'); await debounceWait(); const groupName = await screen.findAllByTestId('groupName'); @@ -255,10 +255,12 @@ describe('Testing Groups Screen', () => { renderGroups(link1); const viewGroupBtn = await screen.findAllByTestId('viewGroupBtn'); - userEvent.click(viewGroupBtn[0]); + await userEvent.click(viewGroupBtn[0]); expect(await screen.findByText(t.groupDetails)).toBeInTheDocument(); - userEvent.click(await screen.findByTestId('volunteerViewModalCloseBtn')); + await userEvent.click( + await screen.findByTestId('volunteerViewModalCloseBtn'), + ); }); /** @@ -268,9 +270,9 @@ describe('Testing Groups Screen', () => { renderGroups(link1); const editGroupBtn = await screen.findAllByTestId('editGroupBtn'); - userEvent.click(editGroupBtn[0]); + await userEvent.click(editGroupBtn[0]); expect(await screen.findByText(t.manageGroup)).toBeInTheDocument(); - userEvent.click(await screen.findByTestId('modalCloseBtn')); + await userEvent.click(await screen.findByTestId('modalCloseBtn')); }); }); diff --git a/src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx b/src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx index 2c8d0835ca..69bf4f3d73 100644 --- a/src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx +++ b/src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx @@ -227,7 +227,7 @@ describe('Testing Invvitations Screen', () => { expect(searchInput).toBeInTheDocument(); // Search by name on press of ENTER - userEvent.type(searchInput, '1'); + await userEvent.type(searchInput, '1'); await debounceWait(); await waitFor(() => { @@ -265,7 +265,7 @@ describe('Testing Invvitations Screen', () => { expect(acceptBtn).toHaveLength(2); // Accept Request - userEvent.click(acceptBtn[0]); + await userEvent.click(acceptBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.invitationAccepted); @@ -281,7 +281,7 @@ describe('Testing Invvitations Screen', () => { expect(rejectBtn).toHaveLength(2); // Reject Request - userEvent.click(rejectBtn[0]); + await userEvent.click(rejectBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.invitationRejected); @@ -297,7 +297,7 @@ describe('Testing Invvitations Screen', () => { expect(acceptBtn).toHaveLength(2); // Accept Request - userEvent.click(acceptBtn[0]); + await userEvent.click(acceptBtn[0]); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx b/src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx index f636d8d8d4..6de2a05c46 100644 --- a/src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx +++ b/src/screens/UserPortal/Volunteer/UpcomingEvents/UpcomingEvents.spec.tsx @@ -145,13 +145,13 @@ describe('Testing Upcoming Events Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expect(searchToggle).toBeInTheDocument(); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByTitle = await screen.findByTestId('title'); expect(searchByTitle).toBeInTheDocument(); - userEvent.click(searchByTitle); + await userEvent.click(searchByTitle); - userEvent.type(searchInput, '1'); + await userEvent.type(searchInput, '1'); await debounceWait(); const eventTitle = await screen.findAllByTestId('eventTitle'); @@ -165,14 +165,14 @@ describe('Testing Upcoming Events Screen', () => { const searchToggle = await screen.findByTestId('searchByToggle'); expect(searchToggle).toBeInTheDocument(); - userEvent.click(searchToggle); + await userEvent.click(searchToggle); const searchByLocation = await screen.findByTestId('location'); expect(searchByLocation).toBeInTheDocument(); - userEvent.click(searchByLocation); + await userEvent.click(searchByLocation); // Search by name on press of ENTER - userEvent.type(searchInput, 'M'); + await userEvent.type(searchInput, 'M'); await debounceWait(); const eventTitle = await screen.findAllByTestId('eventTitle'); @@ -200,7 +200,7 @@ describe('Testing Upcoming Events Screen', () => { renderUpcomingEvents(link1); const volunteerBtn = await screen.findAllByTestId('volunteerBtn'); - userEvent.click(volunteerBtn[0]); + await userEvent.click(volunteerBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.volunteerSuccess); @@ -212,11 +212,11 @@ describe('Testing Upcoming Events Screen', () => { const eventTitle = await screen.findAllByTestId('eventTitle'); expect(eventTitle[0]).toHaveTextContent('Event 1'); - userEvent.click(eventTitle[0]); + await userEvent.click(eventTitle[0]); const joinGroupBtn = await screen.findAllByTestId('joinBtn'); expect(joinGroupBtn).toHaveLength(3); - userEvent.click(joinGroupBtn[0]); + await userEvent.click(joinGroupBtn[0]); await waitFor(() => { expect(toast.success).toHaveBeenCalledWith(t.volunteerSuccess); @@ -227,7 +227,7 @@ describe('Testing Upcoming Events Screen', () => { renderUpcomingEvents(link4); const volunteerBtn = await screen.findAllByTestId('volunteerBtn'); - userEvent.click(volunteerBtn[0]); + await userEvent.click(volunteerBtn[0]); await waitFor(() => { expect(toast.error).toHaveBeenCalled(); diff --git a/src/screens/UserPortal/Volunteer/VolunteerManagement.spec.tsx b/src/screens/UserPortal/Volunteer/VolunteerManagement.spec.tsx index 6fb9c218f9..2e6b99a960 100644 --- a/src/screens/UserPortal/Volunteer/VolunteerManagement.spec.tsx +++ b/src/screens/UserPortal/Volunteer/VolunteerManagement.spec.tsx @@ -103,7 +103,7 @@ describe('Volunteer Management', () => { renderVolunteerManagement(); const backButton = await screen.findByTestId('backBtn'); - userEvent.click(backButton); + await userEvent.click(backButton); await waitFor(() => { const orgHome = screen.getByTestId('orgHome'); expect(orgHome).toBeInTheDocument(); @@ -114,19 +114,19 @@ describe('Volunteer Management', () => { renderVolunteerManagement(); const invitationsBtn = screen.getByTestId('invitationsBtn'); - userEvent.click(invitationsBtn); + await userEvent.click(invitationsBtn); const invitationsTab = screen.getByTestId('invitationsTab'); expect(invitationsTab).toBeInTheDocument(); const actionsBtn = screen.getByTestId('actionsBtn'); - userEvent.click(actionsBtn); + await userEvent.click(actionsBtn); const actionsTab = screen.getByTestId('actionsTab'); expect(actionsTab).toBeInTheDocument(); const groupsBtn = screen.getByTestId('groupsBtn'); - userEvent.click(groupsBtn); + await userEvent.click(groupsBtn); const groupsTab = screen.getByTestId('groupsTab'); expect(groupsTab).toBeInTheDocument(); @@ -137,7 +137,7 @@ describe('Volunteer Management', () => { const upcomingEventsBtn = screen.getByTestId('upcomingEventsBtn'); const invitationsBtn = screen.getByTestId('invitationsBtn'); // Click the invitations tab - userEvent.click(invitationsBtn); + await userEvent.click(invitationsBtn); await waitFor(() => { expect(invitationsBtn).toHaveClass('btn-success'); expect(upcomingEventsBtn).not.toHaveClass('btn-success'); @@ -147,7 +147,7 @@ describe('Volunteer Management', () => { renderVolunteerManagement(); const actionsBtn = screen.getByTestId('actionsBtn'); - userEvent.click(actionsBtn); + await userEvent.click(actionsBtn); const actionsTab = screen.getByTestId('actionsTab'); expect(actionsTab).toBeInTheDocument(); }); diff --git a/src/screens/Users/Users.spec.tsx b/src/screens/Users/Users.spec.tsx index 6d2349de97..7f9698f22e 100644 --- a/src/screens/Users/Users.spec.tsx +++ b/src/screens/Users/Users.spec.tsx @@ -142,26 +142,26 @@ describe('Testing Users screen', () => { await wait(); const searchBtn = screen.getByTestId('searchButton'); const search1 = 'John'; - userEvent.type(screen.getByTestId(/searchByName/i), search1); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId(/searchByName/i), search1); + await userEvent.click(searchBtn); await wait(); expect(screen.queryByText(/not found/i)).not.toBeInTheDocument(); const search2 = 'Pete{backspace}{backspace}{backspace}{backspace}'; - userEvent.type(screen.getByTestId(/searchByName/i), search2); + await userEvent.type(screen.getByTestId(/searchByName/i), search2); const search3 = 'John{backspace}{backspace}{backspace}{backspace}Sam{backspace}{backspace}{backspace}'; - userEvent.type(screen.getByTestId(/searchByName/i), search3); + await userEvent.type(screen.getByTestId(/searchByName/i), search3); const search4 = 'Sam{backspace}{backspace}P{backspace}'; - userEvent.type(screen.getByTestId(/searchByName/i), search4); + await userEvent.type(screen.getByTestId(/searchByName/i), search4); const search5 = 'Xe'; - userEvent.type(screen.getByTestId(/searchByName/i), search5); - userEvent.clear(screen.getByTestId(/searchByName/i)); - userEvent.type(screen.getByTestId(/searchByName/i), ''); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId(/searchByName/i), search5); + await userEvent.clear(screen.getByTestId(/searchByName/i)); + await userEvent.type(screen.getByTestId(/searchByName/i), ''); + await userEvent.click(searchBtn); await wait(); }); @@ -186,10 +186,13 @@ describe('Testing Users screen', () => { await act(async () => { // Clear the search input - userEvent.clear(searchInput); + await userEvent.clear(searchInput); // Search for a name that doesn't exist - userEvent.type(screen.getByTestId(/searchByName/i), 'NonexistentName'); - userEvent.click(searchBtn); + await userEvent.type( + screen.getByTestId(/searchByName/i), + 'NonexistentName', + ); + await userEvent.click(searchBtn); }); expect(screen.queryByText(/No User Found/i)).toBeInTheDocument(); @@ -507,10 +510,10 @@ describe('Testing Users screen', () => { const searchInput = screen.getByTestId('searchByName'); await act(async () => { - userEvent.type(searchInput, 'John'); + await userEvent.type(searchInput, 'John'); }); await act(async () => { - userEvent.type(searchInput, '{enter}'); + await userEvent.type(searchInput, '{enter}'); }); }); @@ -661,8 +664,8 @@ describe('Testing Users screen', () => { await wait(); const searchBtn = screen.getByTestId('searchButton'); const search1 = ''; - userEvent.type(screen.getByTestId(/searchByName/i), search1); - userEvent.click(searchBtn); + await userEvent.type(screen.getByTestId(/searchByName/i), search1); + await userEvent.click(searchBtn); await wait(); expect(screen.queryByText(/Jane Doe/i)).toBeInTheDocument(); expect(screen.queryByText(/John Doe/i)).toBeInTheDocument(); diff --git a/src/setupTests.ts b/src/setupTests.ts index 19c34e040a..0c0ba8e37c 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -7,7 +7,13 @@ global.fetch = jest.fn(); import { format } from 'util'; -global.console.error = function (...args): void { +global.console.error = (...args): void => { + const [firstArg] = args; + if (typeof firstArg === 'string' && firstArg.includes('act(...)')) { + // Suppress React act warnings which commonly occur with async operations + // These warnings are expected when testing async interactions with @testing-library/user-event + return; + } throw new Error(format(...args)); }; diff --git a/tsconfig.json b/tsconfig.json index 7e0274edb2..e5c9f98cdb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "types": ["vite/client", "vite-plugin-svgr/client", "node"], "baseUrl": "src", - "target": "es5", + "target": "ES2015", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true,