mirror of
https://github.com/suitenumerique/docs.git
synced 2026-08-17 21:25:43 +02:00
✅(e2e) fix uuid not formatted correctly in mocked document
We added a guard on the uuid format in our frontend requests, this guard broke some of our e2e tests because the mocked document id was not a valid uuid.
This commit is contained in:
@@ -501,7 +501,7 @@ test.describe('Doc Header', () => {
|
||||
browserName === 'webkit',
|
||||
'navigator.clipboard is not working with webkit and playwright',
|
||||
);
|
||||
await mockedDocument(page, {
|
||||
const uuid = await mockedDocument(page, {
|
||||
abilities: {
|
||||
destroy: false, // Means owner
|
||||
link_configuration: true,
|
||||
@@ -534,9 +534,7 @@ test.describe('Doc Header', () => {
|
||||
const clipboardContent = await handle.jsonValue();
|
||||
|
||||
const origin = await page.evaluate(() => window.location.origin);
|
||||
expect(clipboardContent.trim()).toMatch(
|
||||
`${origin}/docs/mocked-document-id/`,
|
||||
);
|
||||
expect(clipboardContent.trim()).toMatch(`${origin}/docs/${uuid}/`);
|
||||
});
|
||||
|
||||
test('it pins a document', async ({ page, browserName }) => {
|
||||
|
||||
@@ -137,13 +137,10 @@ export const createDoc = async (
|
||||
})
|
||||
.click();
|
||||
|
||||
await page.waitForURL('**/docs/**', {
|
||||
timeout: 10000,
|
||||
waitUntil: 'networkidle',
|
||||
});
|
||||
|
||||
const input = page.getByLabel('Document title');
|
||||
await expect(input).toBeVisible();
|
||||
await expect(input).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
await expect(input).toHaveText('');
|
||||
|
||||
await input.fill(randomDocs[i]);
|
||||
@@ -251,6 +248,7 @@ export const waitForResponseCreateDoc = (page: Page) => {
|
||||
|
||||
export const mockedDocument = async (page: Page, data: object) => {
|
||||
// document/[ID]/ or document/[ID]/tree/ routes
|
||||
const uuid = crypto.randomUUID();
|
||||
await page.route(/.*\/documents\/[^/]+\/(?:$|tree\/.*)/, async (route) => {
|
||||
const request = route.request();
|
||||
if (request.method().includes('GET') && !request.url().includes('page=')) {
|
||||
@@ -259,7 +257,7 @@ export const mockedDocument = async (page: Page, data: object) => {
|
||||
};
|
||||
await route.fulfill({
|
||||
json: {
|
||||
id: 'mocked-document-id',
|
||||
id: uuid,
|
||||
title: 'Mocked document',
|
||||
path: '000000',
|
||||
abilities: {
|
||||
@@ -304,6 +302,8 @@ export const mockedDocument = async (page: Page, data: object) => {
|
||||
await route.continue();
|
||||
}
|
||||
});
|
||||
|
||||
return uuid;
|
||||
};
|
||||
|
||||
export const mockedListDocs = async (page: Page, data: object[] = []) => {
|
||||
|
||||
Reference in New Issue
Block a user