Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed:#2072 Upgraded package @testing-library/user-event from 12.8.3 to 14.5.2 #3122

Open
wants to merge 2 commits into
base: develop-postgres
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,441 changes: 189 additions & 1,252 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -152,7 +152,7 @@
"jest": "^27.4.5",
"jest-localstorage-mock": "^2.4.19",
"jest-location-mock": "^2.0.0",
"jest-preview": "^0.3.1",
"jest-preview": "^0.2.3",
Comment on lines 154 to +155
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why downgraded this ?

"lint-staged": "^15.3.0",
"postcss-modules": "^6.0.1",
"sass": "^1.80.7",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddOn/core/AddOnEntry/AddOnEntry.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { store } from 'state/store';
import { BACKEND_URL } from 'Constant/constant';
import i18nForTest from 'utils/i18nForTest';
import { I18nextProvider } from 'react-i18next';
import userEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';
import { MockedProvider, wait } from '@apollo/react-testing';
import { StaticMockLink } from 'utils/StaticMockLink';
import { ADD_ON_ENTRY_MOCK } from './AddOnEntryMocks';
Expand Down
45 changes: 30 additions & 15 deletions src/components/AddOn/core/AddOnRegister/AddOnRegister.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { act } from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';
import { MockedProvider } from '@apollo/react-testing';
import { ADD_PLUGIN_MUTATION } from 'GraphQl/Mutations/mutations';
import AddOnRegister from './AddOnRegister';
Expand Down Expand Up @@ -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',
);
Expand All @@ -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');
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BACKEND_URL } from 'Constant/constant';
import i18nForTest from 'utils/i18nForTest';
import { I18nextProvider } from 'react-i18next';
import { ORGANIZATIONS_LIST, PLUGIN_GET } from 'GraphQl/Queries/Queries';
import userEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';
import useLocalStorage from 'utils/useLocalstorage';
import { MockedProvider } from '@apollo/react-testing';
import { vi, describe, test, expect } from 'vitest';
Expand Down Expand Up @@ -259,10 +259,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 () => {
Expand All @@ -283,7 +283,7 @@ describe('Testing AddOnStore Component', () => {
);

await wait();
userEvent.click(screen.getByText('Available'));
await userEvent.click(screen.getByText('Available'));

await wait();
let searchText = '';
Expand Down
20 changes: 10 additions & 10 deletions src/components/AddPeopleToTag/AddPeopleToTag.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'jest-location-mock';
import { I18nextProvider } from 'react-i18next';

import { store } from 'state/store';
import userEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';
import { StaticMockLink } from 'utils/StaticMockLink';
import { toast } from 'react-toastify';
import { InMemoryCache, type ApolloLink } from '@apollo/client';
Expand Down Expand Up @@ -154,24 +154,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]);
});

test('searchs for tags where the firstName matches the provided firstName search input', async () => {
Expand Down Expand Up @@ -277,7 +277,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);
Expand All @@ -293,19 +293,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(
Expand Down
24 changes: 15 additions & 9 deletions src/components/Advertisements/Advertisements.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { MockedProvider } from '@apollo/client/testing';
import { fireEvent, render, screen } from '@testing-library/react';

import type { DocumentNode, NormalizedCacheObject } from '@apollo/client';
import userEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';
import { BACKEND_URL } from 'Constant/constant';

import { ADD_ADVERTISEMENT_MUTATION } from '../../GraphQl/Mutations/mutations';
Expand Down Expand Up @@ -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',
);
Expand All @@ -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();
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import i18n from 'utils/i18nForTest';
import { toast } from 'react-toastify';
import { ADD_ADVERTISEMENT_MUTATION } from 'GraphQl/Mutations/mutations';
import { StaticMockLink } from 'utils/StaticMockLink';
import userEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';
import useLocalStorage from 'utils/useLocalstorage';
import { ORGANIZATION_ADVERTISEMENT_LIST } from 'GraphQl/Queries/Queries';
import { vi } from 'vitest';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Loading
Loading