diff --git a/src/backend/InvenTree/plugin/staticfiles.py b/src/backend/InvenTree/plugin/staticfiles.py index aa852ae227..f46d245643 100644 --- a/src/backend/InvenTree/plugin/staticfiles.py +++ b/src/backend/InvenTree/plugin/staticfiles.py @@ -145,7 +145,13 @@ def _copy_plugin_static_files(slug: str): continue relative_path = item.relative_to(source_path).as_posix() - target = staging_path / relative_path + target = staging_path.joinpath(relative_path) + try: + target.relative_to(staging_path, walk_up=False) + except ValueError: + raise ValueError( + f"Target path '{target}' is not within staging path '{staging_path}'" + ) target.parent.mkdir(parents=True, exist_ok=True) target.write_bytes(item.read_bytes()) diff --git a/src/frontend/src/components/editors/TemplateEditor/TemplateEditor.tsx b/src/frontend/src/components/editors/TemplateEditor/TemplateEditor.tsx index 8ca6a462c9..ff4d518e1b 100644 --- a/src/frontend/src/components/editors/TemplateEditor/TemplateEditor.tsx +++ b/src/frontend/src/components/editors/TemplateEditor/TemplateEditor.tsx @@ -96,7 +96,7 @@ export type UnsavedChangesRef = React.MutableRefObject< // Compare template code, ignoring differences in line endings function codeDiffers(a: string, b: string): boolean { - return a.replace(/\r\n/g, '\n') !== b.replace(/\r\n/g, '\n'); + return a.replaceAll('\r\n', '\n') !== b.replaceAll('\r\n', '\n'); } /** diff --git a/src/frontend/src/pages/Auth/MFASetup.tsx b/src/frontend/src/pages/Auth/MFASetup.tsx index c55c67a043..de654636e3 100644 --- a/src/frontend/src/pages/Auth/MFASetup.tsx +++ b/src/frontend/src/pages/Auth/MFASetup.tsx @@ -23,7 +23,7 @@ export default function MFASetup() { const fetchSecret = useCallback(() => { setUnverifiedEmail(false); - getTotpSecret(setTotpQr, () => setUnverifiedEmail(true)); + getTotpSecret(setTotpQr, () => setUnverifiedEmail(true)).catch(); }, []); useEffect(() => { @@ -32,7 +32,9 @@ export default function MFASetup() { const sendVerification = useCallback(() => { setSending(true); - resendEmailVerification().finally(() => setSending(false)); + resendEmailVerification() + .finally(() => setSending(false)) + .catch(); }, []); if (unverifiedEmail) { diff --git a/src/frontend/src/pages/Index/Scan.tsx b/src/frontend/src/pages/Index/Scan.tsx index 46023bccb7..b0cdd2b408 100644 --- a/src/frontend/src/pages/Index/Scan.tsx +++ b/src/frontend/src/pages/Index/Scan.tsx @@ -175,20 +175,29 @@ export default function Scan() { missing: error?.response?.status == 404 })) ) - ).then((results) => { - historyHandlers.apply((item) => { - const result: any = results.find((r) => r.id == item.id); + ) + .then((results) => { + historyHandlers.apply((item) => { + const result: any = results.find((r) => r.id == item.id); - if (result?.instance) { - return { ...item, instance: result.instance }; - } else if (result?.missing) { - return { ...item, instance: undefined }; - } + if (result?.instance) { + return { ...item, instance: result.instance }; + } else if (result?.missing) { + return { ...item, instance: undefined }; + } - // Retain existing data if the item could not be reloaded - return item; + // Retain existing data if the item could not be reloaded + return item; + }); + }) + .catch((error) => { + showApiErrorMessage({ + error: error, + message: t`Failed to refresh selected items`, + title: t`Refresh Error`, + field: 'error' + }); }); - }); }, [fetchInstanceData, selectedItems]); // Scan history may be stale, so reload instance data when the selection changes diff --git a/src/frontend/src/tables/settings/UserTable.tsx b/src/frontend/src/tables/settings/UserTable.tsx index 7f40a5056c..1d9ae85df8 100644 --- a/src/frontend/src/tables/settings/UserTable.tsx +++ b/src/frontend/src/tables/settings/UserTable.tsx @@ -333,8 +333,8 @@ export function UserTable({ icon: , title: t`Lock user`, color: 'blue', - onClick: () => { - setUserActiveState(record.pk, false); + onClick: async () => { + await setUserActiveState(record.pk, false); table.refreshTable(); }, hidden: !record.is_active @@ -343,8 +343,8 @@ export function UserTable({ icon: , title: t`Unlock user`, color: 'blue', - onClick: () => { - setUserActiveState(record.pk, true); + onClick: async () => { + await setUserActiveState(record.pk, true); table.refreshTable(); }, hidden: record.is_active diff --git a/src/frontend/tests/pages/pui_detail_tables.spec.ts b/src/frontend/tests/pages/pui_detail_tables.spec.ts index 45bdd6ea43..7bf2649ae0 100644 --- a/src/frontend/tests/pages/pui_detail_tables.spec.ts +++ b/src/frontend/tests/pages/pui_detail_tables.spec.ts @@ -77,6 +77,9 @@ test('BOM - Optional Columns', async ({ browser }) => { for (const column of columns) { await page.locator('table thead th', { hasText: column }).first().waitFor(); } + await expect( + page.locator('table thead th', { hasText: columns[0] }) + ).toBeVisible(); // Disable them again await page.getByLabel('table-select-columns').click(); diff --git a/src/frontend/tests/pages/pui_parametric.spec.ts b/src/frontend/tests/pages/pui_parametric.spec.ts index 6d047339ea..778c15e69e 100644 --- a/src/frontend/tests/pages/pui_parametric.spec.ts +++ b/src/frontend/tests/pages/pui_parametric.spec.ts @@ -109,7 +109,9 @@ test('Parametric - Filters and Editing', async ({ browser }) => { // Edit an existing parameter value await clickParameterCell(page, 'Resistance'); await page.getByRole('button', { name: 'Submit' }).waitFor(); - await page.getByRole('button', { name: 'Cancel' }).click(); + const button = page.getByRole('button', { name: 'Cancel' }); + await test.expect(button).toBeVisible(); + await button.click(); // Add a parameter value which does not yet exist (find an empty cell) if (await clickEmptyParameterCell(page, ['Power', 'Tolerance', 'Package'])) { diff --git a/src/frontend/tests/pages/pui_part.spec.ts b/src/frontend/tests/pages/pui_part.spec.ts index b8b6fe07ab..99f0a20437 100644 --- a/src/frontend/tests/pages/pui_part.spec.ts +++ b/src/frontend/tests/pages/pui_part.spec.ts @@ -578,14 +578,17 @@ test('Parts - Locking', async ({ browser }) => { .waitFor(); await loadTab(page, 'Parameters'); - await page - .getByRole('button', { name: 'action-menu-add-parameters' }) - .click(); - await page - .getByRole('menuitem', { - name: 'action-menu-add-parameters-create-parameter' - }) - .click(); + await expect(async () => { + await page.keyboard.press('Escape'); + await page + .getByRole('button', { name: 'action-menu-add-parameters' }) + .click({ timeout: 3000 }); + await page + .getByRole('menuitem', { + name: 'action-menu-add-parameters-create-parameter' + }) + .click({ timeout: 3000 }); + }).toPass({ timeout: 20000 }); // Navigate to a known assembly which *is* locked await navigate(page, 'part/100/bom'); diff --git a/src/frontend/tests/pui_plugins.spec.ts b/src/frontend/tests/pui_plugins.spec.ts index 77c2f7f03e..3e39d1e084 100644 --- a/src/frontend/tests/pui_plugins.spec.ts +++ b/src/frontend/tests/pui_plugins.spec.ts @@ -304,13 +304,25 @@ test('Plugins - Creator', async ({ browser }) => { }); // Allow time for installation of plugin static files, etc - await page.waitForTimeout(2500); + await expect + .poll( + async () => + ( + await page.request.get('/static/plugins/my-custom-plugin/Panel.js') + ).status(), + { timeout: 2500 } + ) + .toBe(200); - await navigate(page, 'part/106/details/'); - await loadTab(page, 'My Custom Plugin'); + await expect(async () => { + await navigate(page, 'part/106/details/'); + await loadTab(page, 'My Custom Plugin'); - // Check for correctly translated code - await page.getByText('Translated text, provided by custom code!').waitFor(); + // Check for correctly translated code + await page + .getByText('Translated text, provided by custom code!') + .waitFor({ timeout: 2500 }); + }).toPass({ timeout: 60000 }); // Check for incrementing counter value for (let i = 0; i < 5; i++) {