(frontend) update document

We can now update a pad from a modal.
This commit is contained in:
Anthony LC
2024-05-23 17:01:33 +02:00
committed by Anthony LC
parent ef2f4d3250
commit 2813b2ca27
6 changed files with 200 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ export const createPad = async (
padName: string,
browserName: string,
length: number,
isPublic: boolean = false,
) => {
const panel = page.getByLabel('Pads panel').first();
const buttonCreate = page.getByRole('button', { name: 'Create the pad' });
@@ -37,6 +38,11 @@ export const createPad = async (
for (let i = 0; i < randomPads.length; i++) {
await panel.getByRole('button', { name: 'Add a pad' }).click();
await page.getByText('Pad name').fill(randomPads[i]);
if (isPublic) {
await page.getByText('Is it public ?').click();
}
await expect(buttonCreate).toBeEnabled();
await buttonCreate.click();
await expect(panel.locator('li').getByText(randomPads[i])).toBeVisible();

View File

@@ -47,4 +47,59 @@ test.describe('Pad Tools', () => {
expect(pdfText).toContain('La directrice'); // This is the template text
expect(pdfText).toContain('Hello World'); // This is the pad text
});
test('it updates the pad', async ({ page, browserName }) => {
const [randomPad] = await createPad(
page,
'pad-update',
browserName,
1,
true,
);
await expect(page.locator('h2').getByText(randomPad)).toBeVisible();
await page.getByLabel('Open the document options').click();
await page
.getByRole('button', {
name: 'Update document',
})
.click();
await expect(
page.locator('h2').getByText(`Update document "${randomPad}"`),
).toBeVisible();
await expect(
page.getByRole('checkbox', { name: 'Is it public ?' }),
).toBeChecked();
await page.getByText('Pad name').fill(`${randomPad}-updated`);
await page.getByText('Is it public ?').click();
await page
.getByRole('button', {
name: 'Validate the modification',
})
.click();
await expect(
page.getByText('The document has been updated.'),
).toBeVisible();
const panel = page.getByLabel('Pads panel').first();
await expect(
panel.locator('li').getByText(`${randomPad}-updated`),
).toBeVisible();
await page.getByLabel('Open the document options').click();
await page
.getByRole('button', {
name: 'Update document',
})
.click();
await expect(
page.getByRole('checkbox', { name: 'Is it public ?' }),
).not.toBeChecked();
});
});