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',
|
browserName === 'webkit',
|
||||||
'navigator.clipboard is not working with webkit and playwright',
|
'navigator.clipboard is not working with webkit and playwright',
|
||||||
);
|
);
|
||||||
await mockedDocument(page, {
|
const uuid = await mockedDocument(page, {
|
||||||
abilities: {
|
abilities: {
|
||||||
destroy: false, // Means owner
|
destroy: false, // Means owner
|
||||||
link_configuration: true,
|
link_configuration: true,
|
||||||
@@ -534,9 +534,7 @@ test.describe('Doc Header', () => {
|
|||||||
const clipboardContent = await handle.jsonValue();
|
const clipboardContent = await handle.jsonValue();
|
||||||
|
|
||||||
const origin = await page.evaluate(() => window.location.origin);
|
const origin = await page.evaluate(() => window.location.origin);
|
||||||
expect(clipboardContent.trim()).toMatch(
|
expect(clipboardContent.trim()).toMatch(`${origin}/docs/${uuid}/`);
|
||||||
`${origin}/docs/mocked-document-id/`,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('it pins a document', async ({ page, browserName }) => {
|
test('it pins a document', async ({ page, browserName }) => {
|
||||||
|
|||||||
@@ -137,13 +137,10 @@ export const createDoc = async (
|
|||||||
})
|
})
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
await page.waitForURL('**/docs/**', {
|
|
||||||
timeout: 10000,
|
|
||||||
waitUntil: 'networkidle',
|
|
||||||
});
|
|
||||||
|
|
||||||
const input = page.getByLabel('Document title');
|
const input = page.getByLabel('Document title');
|
||||||
await expect(input).toBeVisible();
|
await expect(input).toBeVisible({
|
||||||
|
timeout: 10000,
|
||||||
|
});
|
||||||
await expect(input).toHaveText('');
|
await expect(input).toHaveText('');
|
||||||
|
|
||||||
await input.fill(randomDocs[i]);
|
await input.fill(randomDocs[i]);
|
||||||
@@ -251,6 +248,7 @@ export const waitForResponseCreateDoc = (page: Page) => {
|
|||||||
|
|
||||||
export const mockedDocument = async (page: Page, data: object) => {
|
export const mockedDocument = async (page: Page, data: object) => {
|
||||||
// document/[ID]/ or document/[ID]/tree/ routes
|
// document/[ID]/ or document/[ID]/tree/ routes
|
||||||
|
const uuid = crypto.randomUUID();
|
||||||
await page.route(/.*\/documents\/[^/]+\/(?:$|tree\/.*)/, async (route) => {
|
await page.route(/.*\/documents\/[^/]+\/(?:$|tree\/.*)/, async (route) => {
|
||||||
const request = route.request();
|
const request = route.request();
|
||||||
if (request.method().includes('GET') && !request.url().includes('page=')) {
|
if (request.method().includes('GET') && !request.url().includes('page=')) {
|
||||||
@@ -259,7 +257,7 @@ export const mockedDocument = async (page: Page, data: object) => {
|
|||||||
};
|
};
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
id: 'mocked-document-id',
|
id: uuid,
|
||||||
title: 'Mocked document',
|
title: 'Mocked document',
|
||||||
path: '000000',
|
path: '000000',
|
||||||
abilities: {
|
abilities: {
|
||||||
@@ -304,6 +302,8 @@ export const mockedDocument = async (page: Page, data: object) => {
|
|||||||
await route.continue();
|
await route.continue();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mockedListDocs = async (page: Page, data: object[] = []) => {
|
export const mockedListDocs = async (page: Page, data: object[] = []) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user