diff --git a/src/frontend/apps/e2e/__tests__/app-impress/common.ts b/src/frontend/apps/e2e/__tests__/app-impress/common.ts index 0aea93c5..e82d17be 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/common.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/common.ts @@ -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(); diff --git a/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts index be17b20c..1fc32645 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts @@ -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(); + }); }); diff --git a/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx b/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx index 41bc6204..1c5bf1b8 100644 --- a/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx +++ b/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import { Box, DropButton, IconOptions, Text } from '@/components'; import { Pad } from '@/features/pads/pad'; +import { ModalUpdatePad } from '@/features/pads/pads-create'; import { TemplatesOrdering, useTemplates } from '../api/useTemplates'; @@ -18,6 +19,7 @@ export const PadToolBox = ({ pad }: PadToolBoxProps) => { const { data: templates } = useTemplates({ ordering: TemplatesOrdering.BY_CREATED_ON_DESC, }); + const [isModalUpdateOpen, setIsModalUpdateOpen] = useState(false); const [isModalPDFOpen, setIsModalPDFOpen] = useState(false); const [isDropOpen, setIsDropOpen] = useState(false); @@ -44,13 +46,23 @@ export const PadToolBox = ({ pad }: PadToolBoxProps) => { button={ } onOpenChange={(isOpen) => setIsDropOpen(isOpen)} isOpen={isDropOpen} > + + } + onClose={() => onClose()} + rightActions={ + + } + size={ModalSize.MEDIUM} + title={ + + + + {t('Update document "{{documentTitle}}"', { + documentTitle: pad.title, + })} + + + } + > + + + {t('Enter the new name of the selected document.')} + + + + + setPadPublic(!padPublic)} + /> + + + + ); +}; diff --git a/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts b/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts index 0fd79adc..22282015 100644 --- a/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts +++ b/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts @@ -1 +1,2 @@ export * from './CardCreatePad'; +export * from './ModalUpdatePad';