From f52e76a0cfef8995e1e865092a8f13b2b83a8ab6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 4 Jul 2026 15:36:12 +0000 Subject: [PATCH] Updated playwright tests --- .../src/components/editors/NotesEditor.tsx | 4 ++ src/frontend/tests/pages/pui_part.spec.ts | 62 +++++++++++++++---- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/frontend/src/components/editors/NotesEditor.tsx b/src/frontend/src/components/editors/NotesEditor.tsx index 79cf2982ab..1e8bf5d4d1 100644 --- a/src/frontend/src/components/editors/NotesEditor.tsx +++ b/src/frontend/src/components/editors/NotesEditor.tsx @@ -404,6 +404,7 @@ export default function NotesEditor({ {!isEditing && ( setIsEditing(true)} > @@ -417,6 +418,7 @@ export default function NotesEditor({ {isEditing && isDirty && ( setIsEditing(false)} color='green' diff --git a/src/frontend/tests/pages/pui_part.spec.ts b/src/frontend/tests/pages/pui_part.spec.ts index f4c035c9e1..24a0881861 100644 --- a/src/frontend/tests/pages/pui_part.spec.ts +++ b/src/frontend/tests/pages/pui_part.spec.ts @@ -1031,23 +1031,61 @@ test('Parts - Test Results', async ({ browser }) => { }); test('Parts - Notes', async ({ browser }) => { - const page = await doCachedLogin(browser, { url: 'part/69/notes' }); + const page = await doCachedLogin(browser, { url: 'part/71/details' }); - // Enable editing - await page.getByLabel('Enable Editing').waitFor(); + await loadTab(page, 'Notes'); - // Use keyboard shortcut to "edit" the part - await page.keyboard.press('Control+E'); - await page.getByLabel('text-field-name', { exact: true }).waitFor(); - await page.getByLabel('text-field-description', { exact: true }).waitFor(); - await page.getByLabel('tree-field-category').waitFor(); + // Expect to see notes rendered for this part + await page.getByRole('cell', { name: 'Red Widget' }).waitFor(); + await page.getByRole('cell', { name: 'Blue Widget' }).waitFor(); + await page.getByRole('cell', { name: 'Green Widget' }).waitFor(); + await page + .getByRole('link', { name: 'Read more in the documentation' }) + .waitFor(); + + // Let's try to create a new note, but cancel before submitting + await page.getByRole('button', { name: 'Add Note' }).click(); + await page.getByLabel('related-field-template').fill('instructions'); + await page + .getByRole('option', { name: 'Manufacturing Instructions' }) + .click(); + await page.getByText('Manufacturing Instructions').waitFor(); + await page.getByText('Manufacturing notes specific to this part').waitFor(); await page.getByRole('button', { name: 'Cancel' }).click(); - // Enable notes editing - await page.getByLabel('Enable Editing').click(); + // Enable editing for this note + await page.getByRole('button', { name: 'edit-note' }).click(); - await page.getByLabel('Save Notes').waitFor(); - await page.getByLabel('Close Editor').waitFor(); + await page.getByRole('button', { name: 'Bold' }).waitFor(); + await page.getByRole('button', { name: 'Italic' }).waitFor(); + await page.getByRole('button', { name: 'Underline' }).waitFor(); + await page.getByRole('button', { name: 'Heading 1' }).waitFor(); + await page.getByRole('button', { name: 'Heading 2' }).waitFor(); + await page.getByRole('button', { name: 'Heading 3' }).waitFor(); + + await page.getByRole('button', { name: 'finish-editing-note' }).click(); + + // Duplicate this part - should show options for copying notes + await page.getByRole('button', { name: 'action-menu-part-actions' }).click(); + await page + .getByRole('menuitem', { name: 'action-menu-part-actions-duplicate' }) + .click(); + await page + .getByRole('switch', { name: 'boolean-field-duplicate.copy_notes' }) + .waitFor(); + + // Generate random IPN for copying + const ipn = `IPN-${Math.floor(Math.random() * 100000)}`; + await page.getByRole('textbox', { name: 'text-field-IPN' }).fill(ipn); + await page.getByRole('button', { name: 'Submit' }).click(); + await page.waitForLoadState('networkidle'); + await page.getByText(`Part: ${ipn}`).waitFor(); + + // Check that the notes have been duplicated to this new part + await loadTab(page, 'Notes'); + await page + .getByRole('heading', { name: 'On Widgets (And Variants Thereof)' }) + .waitFor(); }); test('Parts - 404', async ({ browser }) => {