Updated playwright tests

This commit is contained in:
Oliver Walters 2026-07-04 15:36:12 +00:00
parent 77114caa02
commit f52e76a0cf
2 changed files with 54 additions and 12 deletions

View File

@ -404,6 +404,7 @@ export default function NotesEditor({
{!isEditing && ( {!isEditing && (
<Tooltip label={t`Edit note`}> <Tooltip label={t`Edit note`}>
<ActionIcon <ActionIcon
aria-label='edit-note'
variant='transparent' variant='transparent'
onClick={() => setIsEditing(true)} onClick={() => setIsEditing(true)}
> >
@ -417,6 +418,7 @@ export default function NotesEditor({
{isEditing && isDirty && ( {isEditing && isDirty && (
<Tooltip label={t`Save note`}> <Tooltip label={t`Save note`}>
<ActionIcon <ActionIcon
aria-label='save-note'
variant='transparent' variant='transparent'
color={'green'} color={'green'}
onClick={saveNote} onClick={saveNote}
@ -429,6 +431,7 @@ export default function NotesEditor({
{isEditing && isDirty && ( {isEditing && isDirty && (
<Tooltip label={t`Reset note content`}> <Tooltip label={t`Reset note content`}>
<ActionIcon <ActionIcon
aria-label='reset-note'
variant='transparent' variant='transparent'
onClick={reloadNote} onClick={reloadNote}
disabled={!canEdit || !isDirty} disabled={!canEdit || !isDirty}
@ -440,6 +443,7 @@ export default function NotesEditor({
{isEditing && !isDirty && ( {isEditing && !isDirty && (
<Tooltip label={t`Finish editing`}> <Tooltip label={t`Finish editing`}>
<ActionIcon <ActionIcon
aria-label='finish-editing-note'
variant='transparent' variant='transparent'
onClick={() => setIsEditing(false)} onClick={() => setIsEditing(false)}
color='green' color='green'

View File

@ -1031,23 +1031,61 @@ test('Parts - Test Results', async ({ browser }) => {
}); });
test('Parts - Notes', 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 loadTab(page, 'Notes');
await page.getByLabel('Enable Editing').waitFor();
// Use keyboard shortcut to "edit" the part // Expect to see notes rendered for this part
await page.keyboard.press('Control+E'); await page.getByRole('cell', { name: 'Red Widget' }).waitFor();
await page.getByLabel('text-field-name', { exact: true }).waitFor(); await page.getByRole('cell', { name: 'Blue Widget' }).waitFor();
await page.getByLabel('text-field-description', { exact: true }).waitFor(); await page.getByRole('cell', { name: 'Green Widget' }).waitFor();
await page.getByLabel('tree-field-category').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(); await page.getByRole('button', { name: 'Cancel' }).click();
// Enable notes editing // Enable editing for this note
await page.getByLabel('Enable Editing').click(); await page.getByRole('button', { name: 'edit-note' }).click();
await page.getByLabel('Save Notes').waitFor(); await page.getByRole('button', { name: 'Bold' }).waitFor();
await page.getByLabel('Close Editor').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 }) => { test('Parts - 404', async ({ browser }) => {