1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-09 15:55:23 +02:00

feat(ci): replace jest with vitest [EE-6504] (#10997)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run

This commit is contained in:
Chaim Lev-Ari 2024-01-23 08:42:52 +02:00 committed by GitHub
parent 4a19871fcc
commit 69c06bc756
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 1137 additions and 1680 deletions

View file

@ -51,7 +51,7 @@ async function renderComponent(
const queries = renderWithQueryClient(
<UserContext.Provider value={{ user }}>
<EnvironmentList onClickBrowse={jest.fn()} onRefresh={jest.fn()} />
<EnvironmentList onClickBrowse={vi.fn()} onRefresh={vi.fn()} />
</UserContext.Provider>
);

View file

@ -48,7 +48,7 @@ test.each([
async (ownership) => {
const values = buildFormData(ownership);
const { findByRole } = await renderComponent(values, jest.fn(), {
const { findByRole } = await renderComponent(values, vi.fn(), {
isAdmin: true,
});
@ -76,7 +76,7 @@ test.each([
async (ownership) => {
const values = buildFormData(ownership);
const { findByRole } = await renderComponent(values, jest.fn(), {
const { findByRole } = await renderComponent(values, vi.fn(), {
teams: [],
isAdmin: false,
});
@ -99,7 +99,7 @@ test.each([
async (ownership) => {
const values = buildFormData(ownership);
const { findByRole } = await renderComponent(values, jest.fn(), {
const { findByRole } = await renderComponent(values, vi.fn(), {
teams: createMockTeams(1),
isAdmin: false,
});
@ -124,7 +124,7 @@ test('when ownership is public, ownership selector should be hidden', async () =
test('when hideTitle is true, title should be hidden', async () => {
const values = buildFormData();
const { queryByRole } = await renderComponent(values, jest.fn(), {
const { queryByRole } = await renderComponent(values, vi.fn(), {
hideTitle: true,
});
@ -136,7 +136,7 @@ test('when isAdmin and admin ownership is selected, no extra options are visible
const { findByRole, queryByLabelText } = await renderComponent(
values,
jest.fn(),
vi.fn(),
{
isAdmin: true,
}
@ -162,7 +162,7 @@ test('when isAdmin and restricted ownership is selected, show team and users sel
const { findByRole, findByLabelText } = await renderComponent(
values,
jest.fn(),
vi.fn(),
{
isAdmin: true,
}
@ -200,7 +200,7 @@ test('when user is not an admin, there are more then 1 team and ownership is res
const { findByRole, findByLabelText } = await renderComponent(
values,
jest.fn()
vi.fn()
);
const ownershipSelector = await findByRole('radiogroup');
@ -231,7 +231,7 @@ test('when user is not an admin, there is 1 team and ownership is restricted, te
const { findByRole, findByLabelText } = await renderComponent(
values,
jest.fn(),
vi.fn(),
{
teams: createMockTeams(1),
isAdmin: false,
@ -266,7 +266,7 @@ test('when user is not an admin, and ownership is restricted, user selector not
const { findByRole, findByLabelText } = await renderComponent(
values,
jest.fn(),
vi.fn(),
{
isAdmin: false,
}
@ -300,7 +300,7 @@ interface AdditionalProps {
async function renderComponent(
values: AccessControlFormData,
onChange = jest.fn(),
onChange = vi.fn(),
{ isAdmin = false, hideTitle = false, teams, users }: AdditionalProps = {}
) {
const user = new UserViewModel({ Username: 'user', Role: isAdmin ? 1 : 2 });

View file

@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`when ownership is restricted and no teams or users, should be invalid 1`] = `"You must specify at least one team or user."`;
exports[`when ownership is restricted and no teams or users, should be invalid 1`] = `[ValidationError: You must specify at least one team or user.]`;
exports[`when ownership is restricted and no teams or users, should be invalid 2`] = `"You must specify at least one team."`;
exports[`when ownership is restricted and no teams or users, should be invalid 2`] = `[ValidationError: You must specify at least one team.]`;

View file

@ -7,8 +7,8 @@ import type { License } from './types';
describe('getLicenses', () => {
it('on success should return the server body', async () => {
const catchFn = jest.fn();
const thenFn = jest.fn();
const catchFn = vi.fn();
const thenFn = vi.fn();
const data: License[] = [];
server.use(http.get('/api/licenses', () => HttpResponse.json(data)));
@ -22,8 +22,8 @@ describe('getLicenses', () => {
});
it('on failure should return the server message', async () => {
const catchFn = jest.fn();
const thenFn = jest.fn();
const catchFn = vi.fn();
const thenFn = vi.fn();
const message = 'message';
const details = 'details';