mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-24 00:36:39 +00:00
Small fixes (#13333)
* add missing catch * use replaceAll instead * add explicit expects to fix juint result reporting * fix path traversal * try make this more stable * use a loop to make this more stable against autoclosing menus * plugins are somewhat unpredictable so adding some slck
This commit is contained in:
1 parent
7933454b89
commit
6c5cb2910a
9 files changed
+70
-33
No files matched your search
@@ -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())
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -333,8 +333,8 @@ export function UserTable({
|
||||
icon: <IconLock />,
|
||||
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: <IconLockOpen />,
|
||||
title: t`Unlock user`,
|
||||
color: 'blue',
|
||||
onClick: () => {
|
||||
setUserActiveState(record.pk, true);
|
||||
onClick: async () => {
|
||||
await setUserActiveState(record.pk, true);
|
||||
table.refreshTable();
|
||||
},
|
||||
hidden: record.is_active
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'])) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
Reference in new issue
Block a user