🤡(app-desk) remove mock endpoint teams accesses

The endpoint teams/accesses is ready.
We remove the mock and the related libraries
and use the real endpoint.
This commit is contained in:
Anthony LC
2024-03-04 16:10:40 +01:00
committed by Anthony LC
parent e16f51ca20
commit b010a7b5a7
5 changed files with 11 additions and 62 deletions

View File

@@ -15,7 +15,6 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@faker-js/faker": "8.4.1",
"@openfun/cunningham-react": "2.4.0",
"@tanstack/react-query": "5.24.8",
"i18next": "23.10.0",

View File

@@ -1,24 +0,0 @@
import { faker } from '@faker-js/faker';
import { Access, Role } from '../types';
function createRandomAccess(): Access {
return {
id: faker.string.uuid(),
user: {
id: faker.string.uuid(),
email: faker.internet.email(),
name: faker.person.fullName(),
},
role: faker.helpers.enumValue(Role),
};
}
export const dummyDataAPITeamAccesses = (count: number, pageSize: number) => {
return {
count,
next: null,
previous: null,
results: faker.helpers.multiple(createRandomAccess, { count: pageSize }),
};
};

View File

@@ -2,9 +2,6 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query';
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
import { PAGE_SIZE } from '../conf';
import { dummyDataAPITeamAccesses } from './data/teams';
import { Access } from './types';
export type TeamAccessesAPIParams = {
@@ -18,15 +15,6 @@ export const getTeamAccesses = async ({
page,
teamId,
}: TeamAccessesAPIParams): Promise<AccessesResponse> => {
/**
* TODO: Remove this block when the API endpoint is ready
*/
return await new Promise((resolve) => {
setTimeout(() => {
resolve(dummyDataAPITeamAccesses(100, PAGE_SIZE));
}, 500);
});
const response = await fetchAPI(`teams/${teamId}/accesses/?page=${page}`);
if (!response.ok) {

View File

@@ -41,7 +41,10 @@ test.describe('Team', () => {
).toBeVisible();
});
test('checks the datagrid members', async ({ page, browserName }) => {
test('checks the admin members is displayed correctly', async ({
page,
browserName,
}) => {
await createTeam(page, 'team-admin', browserName, 1);
const table = page.getByLabel('List members card').getByRole('table');
@@ -51,24 +54,12 @@ test.describe('Team', () => {
await expect(thead.getByText(/Emails/i)).toBeVisible();
await expect(thead.getByText(/Roles/i)).toBeVisible();
const rows = table.getByRole('row');
expect(await rows.count()).toBe(21);
await expect(
rows.nth(1).getByRole('cell').nth(0).getByLabel('Member icon'),
).toBeVisible();
const textCellName = await rows
.nth(1)
.getByRole('cell')
.nth(1)
.textContent();
expect(textCellName).toEqual(expect.any(String));
await expect(rows.nth(1).getByRole('cell').nth(2)).toContainText('@');
expect(
['owner', 'member', 'admin'].includes(
(await rows.nth(1).getByRole('cell').nth(3).textContent()) as string,
),
).toBeTruthy();
const cells = table.getByRole('row').nth(1).getByRole('cell');
await expect(cells.nth(0).getByLabel('Member icon')).toBeVisible();
await expect(cells.nth(1)).toHaveText(
new RegExp(`E2E ${browserName}`, 'i'),
);
await expect(cells.nth(2)).toHaveText(`user@${browserName}.e2e`);
await expect(cells.nth(3)).toHaveText('owner');
});
});

View File

@@ -1318,11 +1318,6 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==
"@faker-js/faker@8.4.1":
version "8.4.1"
resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-8.4.1.tgz#5d5e8aee8fce48f5e189bf730ebd1f758f491451"
integrity sha512-XQ3cU+Q8Uqmrbf2e0cIC/QN43sTBSC8KF12u29Mb47tWrt2hAgBXSgpZMj4Ao8Uk0iJcU99QsOCaIL8934obCg==
"@fontsource-variable/roboto-flex@5.0.8":
version "5.0.8"
resolved "https://registry.yarnpkg.com/@fontsource-variable/roboto-flex/-/roboto-flex-5.0.8.tgz#d6685dbcdb9ba939717f995dfeb77cd22f7d82a3"