fix(content-releases): fix flaky FE unit tests (#19927)

* fix(content-releases): fix flaky unit tests

* fix(content-releases): change Permission mock

* fix(content-releases): change CheckPermissions mock for all the CR unit tests
This commit is contained in:
Simone 2024-03-27 09:21:40 +01:00 committed by GitHub
parent 3c5ba453a2
commit a4bd82ce45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import { ReactNode } from 'react';
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
import { screen, within } from '@testing-library/react';
import { render, server, waitFor } from '@tests/utils';
@ -7,8 +9,7 @@ import { CMReleasesContainer } from '../CMReleasesContainer';
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),
// eslint-disable-next-line
CheckPermissions: ({ children }: { children: JSX.Element }) => <div>{children}</div>,
CheckPermissions: jest.fn(({ children }: { children: ReactNode }) => children),
useCMEditViewDataManager: jest.fn().mockReturnValue({
isCreatingEntry: false,
hasDraftAndPublish: true,

View File

@ -1,3 +1,5 @@
import { ReactNode } from 'react';
import { useRBAC } from '@strapi/helper-plugin';
import { within } from '@testing-library/react';
import { render, server, screen } from '@tests/utils';
@ -9,8 +11,7 @@ import { mockReleaseDetailsPageData } from './mockReleaseDetailsPageData';
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),
// eslint-disable-next-line
CheckPermissions: ({ children }: { children: JSX.Element }) => <div>{children}</div>,
CheckPermissions: jest.fn(({ children }: { children: ReactNode }) => children),
useRBAC: jest.fn(() => ({
isLoading: false,
allowedActions: { canUpdate: true, canDelete: true },

View File

@ -1,3 +1,5 @@
import { ReactNode } from 'react';
import { within } from '@testing-library/react';
import { render, server, screen } from '@tests/utils';
import { rest } from 'msw';
@ -8,8 +10,7 @@ import { mockReleasesPageData } from './mockReleasesPageData';
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),
// eslint-disable-next-line
CheckPermissions: ({ children }: { children: JSX.Element }) => <div>{children}</div>,
CheckPermissions: jest.fn(({ children }: { children: ReactNode }) => children),
}));
jest.mock('@strapi/admin/strapi-admin', () => ({