✏️(frontend) change all occurences of pad to doc

The initial doc was named pad in reference to
the "NotePad de l'Etat", but we renamed it
doc to clearly dissociate the 2 sites.
Doc is also a small reference of google doc.
This commit is contained in:
Anthony LC
2024-06-25 14:49:53 +02:00
committed by Anthony LC
parent 5b3c91f6dd
commit 5454da5c70
102 changed files with 563 additions and 561 deletions

View File

@@ -26,9 +26,9 @@ export const randomName = (name: string, browserName: string, length: number) =>
return `${browserName}-${Math.floor(Math.random() * 10000)}-${index}-${name}`;
});
export const createPad = async (
export const createDoc = async (
page: Page,
padName: string,
docName: string,
browserName: string,
length: number,
isPublic: boolean = false,
@@ -38,11 +38,11 @@ export const createPad = async (
name: 'Create the document',
});
const randomPads = randomName(padName, browserName, length);
const randomDocs = randomName(docName, browserName, length);
for (let i = 0; i < randomPads.length; i++) {
for (let i = 0; i < randomDocs.length; i++) {
await panel.getByRole('button', { name: 'Add a document' }).click();
await page.getByText('Document name').fill(randomPads[i]);
await page.getByText('Document name').fill(randomDocs[i]);
if (isPublic) {
await page.getByText('Is it public ?').click();
@@ -50,10 +50,10 @@ export const createPad = async (
await expect(buttonCreate).toBeEnabled();
await buttonCreate.click();
await expect(panel.locator('li').getByText(randomPads[i])).toBeVisible();
await expect(panel.locator('li').getByText(randomDocs[i])).toBeVisible();
}
return randomPads;
return randomDocs;
};
export const createTemplate = async (

View File

@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { createPad, randomName } from './common';
import { createDoc, randomName } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
@@ -12,7 +12,7 @@ test.describe('Document add users', () => {
(response) =>
response.url().includes('/users/?q=user') && response.status() === 200,
);
await createPad(page, 'select-multi-users', browserName, 1);
await createDoc(page, 'select-multi-users', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Add members' }).click();
@@ -73,7 +73,7 @@ test.describe('Document add users', () => {
response.url().includes('/users/?q=user') && response.status() === 200,
);
await createPad(page, 'user-invitation', browserName, 1);
await createDoc(page, 'user-invitation', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Add members' }).click();
@@ -125,7 +125,7 @@ test.describe('Document add users', () => {
response.url().includes('/users/?q=user') && response.status() === 200,
);
await createPad(page, 'user-twice', browserName, 1);
await createDoc(page, 'user-twice', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Add members' }).click();
@@ -165,7 +165,7 @@ test.describe('Document add users', () => {
page,
browserName,
}) => {
await createPad(page, 'invitation-twice', browserName, 1);
await createDoc(page, 'invitation-twice', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Add members' }).click();

View File

@@ -4,8 +4,8 @@ test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test.describe('Pad Create', () => {
test('checks all the create pad elements are visible', async ({ page }) => {
test.describe('Doc Create', () => {
test('checks all the create doc elements are visible', async ({ page }) => {
const buttonCreateHomepage = page.getByRole('button', {
name: 'Create a new document',
});
@@ -58,7 +58,7 @@ test.describe('Pad Create', () => {
await expect(buttonCreateHomepage).toBeVisible();
});
test('checks the routing on new pad created', async ({
test('checks the routing on new doc created', async ({
page,
browserName,
}) => {
@@ -66,21 +66,21 @@ test.describe('Pad Create', () => {
await panel.getByRole('button', { name: 'Add a document' }).click();
const padName = `My routing pad ${browserName}-${Math.floor(Math.random() * 1000)}`;
await page.getByText('Document name').fill(padName);
const docName = `My routing doc ${browserName}-${Math.floor(Math.random() * 1000)}`;
await page.getByText('Document name').fill(docName);
await page.getByRole('button', { name: 'Create the document' }).click();
const elPad = page.locator('h2').getByText(padName);
await expect(elPad).toBeVisible();
const elDoc = page.locator('h2').getByText(docName);
await expect(elDoc).toBeVisible();
await panel.getByRole('button', { name: 'Add a document' }).click();
await expect(elPad).toBeHidden();
await expect(elDoc).toBeHidden();
await panel.locator('li').getByText(padName).click();
await expect(elPad).toBeVisible();
await panel.locator('li').getByText(docName).click();
await expect(elDoc).toBeVisible();
});
test('checks alias pads url with homepage', async ({ page }) => {
test('checks alias docs url with homepage', async ({ page }) => {
await expect(page).toHaveURL('/');
const buttonCreateHomepage = page.getByRole('button', {
@@ -98,7 +98,7 @@ test.describe('Pad Create', () => {
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(300);
await page.goto('/docs/some-unknown-pad');
await page.goto('/docs/some-unknown-doc');
await expect(
page.getByText(
'It seems that the page you are looking for does not exist or cannot be displayed correctly.',
@@ -108,8 +108,8 @@ test.describe('Pad Create', () => {
});
});
test('checks that the pad is public', async ({ page, browserName }) => {
const responsePromisePad = page.waitForResponse(
test('checks that the doc is public', async ({ page, browserName }) => {
const responsePromiseDoc = page.waitForResponse(
(response) =>
response.url().includes('/documents/') && response.status() === 201,
);
@@ -118,13 +118,13 @@ test.describe('Pad Create', () => {
await panel.getByRole('button', { name: 'Add a document' }).click();
const padName = `My routing pad ${browserName}-${Math.floor(Math.random() * 1000)}`;
await page.getByText('Document name').fill(padName);
const docName = `My routing doc ${browserName}-${Math.floor(Math.random() * 1000)}`;
await page.getByText('Document name').fill(docName);
await page.getByText('Is it public ?').click();
await page.getByRole('button', { name: 'Create the document' }).click();
const responsePad = await responsePromisePad;
const is_public = (await responsePad.json()).is_public;
const responseDoc = await responsePromiseDoc;
const is_public = (await responseDoc.json()).is_public;
expect(is_public).toBeTruthy();
});
});

View File

@@ -1,26 +1,26 @@
import { expect, test } from '@playwright/test';
import { createPad } from './common';
import { createDoc } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test.describe('Pad Editor', () => {
test('checks the Pad Editor interact correctly', async ({
test.describe('Doc Editor', () => {
test('checks the Doc Editor interact correctly', async ({
page,
browserName,
}) => {
const randomPad = await createPad(page, 'pad-editor', browserName, 1);
const randomDoc = await createDoc(page, 'doc-editor', browserName, 1);
await expect(page.locator('h2').getByText(randomPad[0])).toBeVisible();
await expect(page.locator('h2').getByText(randomDoc[0])).toBeVisible();
await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
await expect(page.getByText('Hello World')).toBeVisible();
});
test('checks the Pad is connected to the webrtc server', async ({
test('checks the Doc is connected to the webrtc server', async ({
page,
browserName,
}) => {
@@ -28,8 +28,8 @@ test.describe('Pad Editor', () => {
return webSocket.url().includes('ws://localhost:4444/');
});
const randomPad = await createPad(page, 'pad-editor', browserName, 1);
await expect(page.locator('h2').getByText(randomPad[0])).toBeVisible();
const randomDoc = await createDoc(page, 'doc-editor', browserName, 1);
await expect(page.locator('h2').getByText(randomDoc[0])).toBeVisible();
const webSocket = await webSocketPromise;
expect(webSocket.url()).toContain('ws://localhost:4444/');
@@ -52,9 +52,9 @@ test.describe('Pad Editor', () => {
page,
browserName,
}) => {
const randomPad = await createPad(page, 'pad-markdown', browserName, 1);
const randomDoc = await createDoc(page, 'doc-markdown', browserName, 1);
await expect(page.locator('h2').getByText(randomPad[0])).toBeVisible();
await expect(page.locator('h2').getByText(randomDoc[0])).toBeVisible();
await page.locator('.ProseMirror.bn-editor').click();
await page
@@ -74,57 +74,57 @@ test.describe('Pad Editor', () => {
).toHaveAttribute('href', 'http://test-markdown.html');
});
test('it renders correctly when we switch from one pad to another', async ({
test('it renders correctly when we switch from one doc to another', async ({
page,
browserName,
}) => {
const [firstPad, secondPad] = await createPad(
const [firstDoc, secondDoc] = await createDoc(
page,
'pad-multiple',
'doc-multiple',
browserName,
2,
);
const panel = page.getByLabel('Documents panel').first();
// Check the first pad
await panel.getByText(firstPad).click();
await expect(page.locator('h2').getByText(firstPad)).toBeVisible();
// Check the first doc
await panel.getByText(firstDoc).click();
await expect(page.locator('h2').getByText(firstDoc)).toBeVisible();
await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World Pad 1');
await expect(page.getByText('Hello World Pad 1')).toBeVisible();
await page.locator('.ProseMirror.bn-editor').fill('Hello World Doc 1');
await expect(page.getByText('Hello World Doc 1')).toBeVisible();
// Check the second pad
await panel.getByText(secondPad).click();
await expect(page.locator('h2').getByText(secondPad)).toBeVisible();
await expect(page.getByText('Hello World Pad 1')).toBeHidden();
// Check the second doc
await panel.getByText(secondDoc).click();
await expect(page.locator('h2').getByText(secondDoc)).toBeVisible();
await expect(page.getByText('Hello World Doc 1')).toBeHidden();
await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World Pad 2');
await expect(page.getByText('Hello World Pad 2')).toBeVisible();
await page.locator('.ProseMirror.bn-editor').fill('Hello World Doc 2');
await expect(page.getByText('Hello World Doc 2')).toBeVisible();
// Check the first pad again
await panel.getByText(firstPad).click();
await expect(page.locator('h2').getByText(firstPad)).toBeVisible();
await expect(page.getByText('Hello World Pad 2')).toBeHidden();
await expect(page.getByText('Hello World Pad 1')).toBeVisible();
// Check the first doc again
await panel.getByText(firstDoc).click();
await expect(page.locator('h2').getByText(firstDoc)).toBeVisible();
await expect(page.getByText('Hello World Doc 2')).toBeHidden();
await expect(page.getByText('Hello World Doc 1')).toBeVisible();
});
test('it saves the doc when we change pages', async ({
page,
browserName,
}) => {
const [pad] = await createPad(page, 'pad-save-page', browserName, 1);
const [doc] = await createDoc(page, 'doc-save-page', browserName, 1);
const panel = page.getByLabel('Documents panel').first();
// Check the first pad
await panel.getByText(pad).click();
await expect(page.locator('h2').getByText(pad)).toBeVisible();
// Check the first doc
await panel.getByText(doc).click();
await expect(page.locator('h2').getByText(doc)).toBeVisible();
await page.locator('.ProseMirror.bn-editor').click();
await page
.locator('.ProseMirror.bn-editor')
.fill('Hello World Pad persisted 1');
await expect(page.getByText('Hello World Pad persisted 1')).toBeVisible();
.fill('Hello World Doc persisted 1');
await expect(page.getByText('Hello World Doc persisted 1')).toBeVisible();
await panel
.getByRole('button', {
@@ -142,33 +142,33 @@ test.describe('Pad Editor', () => {
await page.goto('/');
await panel.getByText(pad).click();
await panel.getByText(doc).click();
await expect(page.getByText('Hello World Pad persisted 1')).toBeVisible();
await expect(page.getByText('Hello World Doc persisted 1')).toBeVisible();
});
test('it saves the doc when we quit pages', async ({ page, browserName }) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(browserName === 'webkit', 'This test is very flaky with webkit');
const [pad] = await createPad(page, 'pad-save-quit', browserName, 1);
const [doc] = await createDoc(page, 'doc-save-quit', browserName, 1);
const panel = page.getByLabel('Documents panel').first();
// Check the first pad
await panel.getByText(pad).click();
await expect(page.locator('h2').getByText(pad)).toBeVisible();
// Check the first doc
await panel.getByText(doc).click();
await expect(page.locator('h2').getByText(doc)).toBeVisible();
await page.locator('.ProseMirror.bn-editor').click();
await page
.locator('.ProseMirror.bn-editor')
.fill('Hello World Pad persisted 2');
await expect(page.getByText('Hello World Pad persisted 2')).toBeVisible();
.fill('Hello World Doc persisted 2');
await expect(page.getByText('Hello World Doc persisted 2')).toBeVisible();
await page.goto('/');
await panel.getByText(pad).click();
await panel.getByText(doc).click();
await expect(page.getByText('Hello World Pad persisted 2')).toBeVisible();
await expect(page.getByText('Hello World Doc persisted 2')).toBeVisible();
});
test('it cannot edit if viewer', async ({ page, browserName }) => {
@@ -202,7 +202,7 @@ test.describe('Pad Editor', () => {
}
});
await createPad(page, 'pad-right-edit', browserName, 1);
await createDoc(page, 'doc-right-edit', browserName, 1);
await expect(
page.getByText(

View File

@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { addNewMember, createPad } from './common';
import { addNewMember, createDoc } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
@@ -11,7 +11,7 @@ test.describe('Members Delete', () => {
page,
browserName,
}) => {
await createPad(page, 'member-delete-1', browserName, 1);
await createDoc(page, 'member-delete-1', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Manage members' }).click();
@@ -37,7 +37,7 @@ test.describe('Members Delete', () => {
page,
browserName,
}) => {
await createPad(page, 'member-delete-2', browserName, 1);
await createDoc(page, 'member-delete-2', browserName, 1);
await addNewMember(page, 0, 'Owner');
@@ -64,7 +64,7 @@ test.describe('Members Delete', () => {
});
test('it cannot delete owner member', async ({ page, browserName }) => {
await createPad(page, 'member-delete-3', browserName, 1);
await createDoc(page, 'member-delete-3', browserName, 1);
const username = await addNewMember(page, 0, 'Owner');
@@ -88,7 +88,7 @@ test.describe('Members Delete', () => {
});
test('it deletes admin member', async ({ page, browserName }) => {
await createPad(page, 'member-delete-4', browserName, 1);
await createDoc(page, 'member-delete-4', browserName, 1);
const username = await addNewMember(page, 0, 'Admin');
@@ -116,7 +116,7 @@ test.describe('Members Delete', () => {
page,
browserName,
}) => {
await createPad(page, 'member-delete-5', browserName, 1);
await createDoc(page, 'member-delete-5', browserName, 1);
const username = await addNewMember(page, 0, 'Owner');
@@ -146,7 +146,7 @@ test.describe('Members Delete', () => {
});
test('it deletes admin member when admin', async ({ page, browserName }) => {
await createPad(page, 'member-delete-6', browserName, 1);
await createDoc(page, 'member-delete-6', browserName, 1);
// To not be the only owner
await addNewMember(page, 0, 'Owner');

View File

@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { createPad } from './common';
import { createDoc } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
@@ -8,7 +8,7 @@ test.beforeEach(async ({ page }) => {
test.describe('Document grid members', () => {
test('it display the grid', async ({ page, browserName }) => {
await createPad(page, 'grid-display', browserName, 1);
await createDoc(page, 'grid-display', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Manage members' }).click();
@@ -91,7 +91,7 @@ test.describe('Document grid members', () => {
},
);
await createPad(page, 'grid-no-member', browserName, 1);
await createDoc(page, 'grid-no-member', browserName, 1);
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Manage members' }).click();

View File

@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
import { waitForElementCount } from '../helpers';
import { createPad } from './common';
import { createDoc } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
@@ -146,16 +146,16 @@ test.describe('Documents Panel', () => {
test('checks the hover and selected state', async ({ page, browserName }) => {
const panel = page.getByLabel('Documents panel').first();
await createPad(page, 'pad-hover', browserName, 2);
await createDoc(page, 'doc-hover', browserName, 2);
const selectedPad = panel.locator('li').nth(0);
await expect(selectedPad).toHaveCSS(
const selectedDoc = panel.locator('li').nth(0);
await expect(selectedDoc).toHaveCSS(
'background-color',
'rgb(202, 202, 251)',
);
const hoverPad = panel.locator('li').nth(1);
await hoverPad.hover();
await expect(hoverPad).toHaveCSS('background-color', 'rgb(227, 227, 253)');
const hoverDoc = panel.locator('li').nth(1);
await hoverDoc.hover();
await expect(hoverDoc).toHaveCSS('background-color', 'rgb(227, 227, 253)');
});
});

View File

@@ -2,24 +2,24 @@ import { expect, test } from '@playwright/test';
import cs from 'convert-stream';
import pdf from 'pdf-parse';
import { createPad } from './common';
import { createDoc } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test.describe('Pad Tools', () => {
test('it converts the pad to pdf with a template integrated', async ({
test.describe('Doc Tools', () => {
test('it converts the doc to pdf with a template integrated', async ({
page,
browserName,
}) => {
const [randomPad] = await createPad(page, 'pad-editor', browserName, 1);
const [randomDoc] = await createDoc(page, 'doc-editor', browserName, 1);
const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomPad}.pdf`);
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});
await expect(page.locator('h2').getByText(randomPad)).toBeVisible();
await expect(page.locator('h2').getByText(randomDoc)).toBeVisible();
await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
@@ -38,19 +38,19 @@ test.describe('Pad Tools', () => {
.click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomPad}.pdf`);
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
const pdfBuffer = await cs.toBuffer(await download.createReadStream());
const pdfText = (await pdf(pdfBuffer)).text;
expect(pdfText).toContain('Hello World'); // This is the pad text
expect(pdfText).toContain('Hello World'); // This is the doc text
});
test('it converts the blocknote json in correct html for the pdf', async ({
page,
browserName,
}) => {
const [randomPad] = await createPad(page, 'pad-editor', browserName, 1);
const [randomDoc] = await createDoc(page, 'doc-editor', browserName, 1);
let body = '';
await page.route('**/templates/*/generate-document/', async (route) => {
@@ -60,7 +60,7 @@ test.describe('Pad Tools', () => {
await route.continue();
});
await expect(page.locator('h2').getByText(randomPad)).toBeVisible();
await expect(page.locator('h2').getByText(randomDoc)).toBeVisible();
await page.locator('.bn-block-outer').last().fill('Hello World');
await page.locator('.bn-block-outer').last().click();
@@ -85,15 +85,15 @@ test.describe('Pad Tools', () => {
expect(body).toContain('<br/><br/>');
});
test('it updates the pad', async ({ page, browserName }) => {
const [randomPad] = await createPad(
test('it updates the doc', async ({ page, browserName }) => {
const [randomDoc] = await createDoc(
page,
'pad-update',
'doc-update',
browserName,
1,
true,
);
await expect(page.locator('h2').getByText(randomPad)).toBeVisible();
await expect(page.locator('h2').getByText(randomDoc)).toBeVisible();
await page.getByLabel('Open the document options').click();
await page
@@ -103,14 +103,14 @@ test.describe('Pad Tools', () => {
.click();
await expect(
page.locator('h2').getByText(`Update document "${randomPad}"`),
page.locator('h2').getByText(`Update document "${randomDoc}"`),
).toBeVisible();
await expect(
page.getByRole('checkbox', { name: 'Is it public ?' }),
).toBeChecked();
await page.getByText('Document name').fill(`${randomPad}-updated`);
await page.getByText('Document name').fill(`${randomDoc}-updated`);
await page.getByText('Is it public ?').click();
await page
@@ -125,7 +125,7 @@ test.describe('Pad Tools', () => {
const panel = page.getByLabel('Documents panel').first();
await expect(
panel.locator('li').getByText(`${randomPad}-updated`),
panel.locator('li').getByText(`${randomDoc}-updated`),
).toBeVisible();
await page.getByLabel('Open the document options').click();
@@ -140,9 +140,9 @@ test.describe('Pad Tools', () => {
).not.toBeChecked();
});
test('it deletes the pad', async ({ page, browserName }) => {
const [randomPad] = await createPad(page, 'pad-delete', browserName, 1);
await expect(page.locator('h2').getByText(randomPad)).toBeVisible();
test('it deletes the doc', async ({ page, browserName }) => {
const [randomDoc] = await createDoc(page, 'doc-delete', browserName, 1);
await expect(page.locator('h2').getByText(randomDoc)).toBeVisible();
await page.getByLabel('Open the document options').click();
await page
@@ -152,7 +152,7 @@ test.describe('Pad Tools', () => {
.click();
await expect(
page.locator('h2').getByText(`Deleting the document "${randomPad}"`),
page.locator('h2').getByText(`Deleting the document "${randomDoc}"`),
).toBeVisible();
await page
@@ -170,7 +170,7 @@ test.describe('Pad Tools', () => {
).toBeVisible();
const panel = page.getByLabel('Documents panel').first();
await expect(panel.locator('li').getByText(randomPad)).toBeHidden();
await expect(panel.locator('li').getByText(randomDoc)).toBeHidden();
});
test('it checks the options available if administrator', async ({
@@ -207,7 +207,7 @@ test.describe('Pad Tools', () => {
}
});
await createPad(page, 'pad-tools-right-admin', browserName, 1);
await createDoc(page, 'doc-tools-right-admin', browserName, 1);
await expect(page.locator('h2').getByText('Mocked document')).toBeVisible();
@@ -261,7 +261,7 @@ test.describe('Pad Tools', () => {
}
});
await createPad(page, 'pad-tools-right-editor', browserName, 1);
await createDoc(page, 'doc-tools-right-editor', browserName, 1);
await expect(page.locator('h2').getByText('Mocked document')).toBeVisible();
@@ -315,7 +315,7 @@ test.describe('Pad Tools', () => {
}
});
await createPad(page, 'pad-tools-right-reader', browserName, 1);
await createDoc(page, 'doc-tools-right-reader', browserName, 1);
await expect(page.locator('h2').getByText('Mocked document')).toBeVisible();