Fix for RenderInstance (#12058)

* Fix for RenderInstance

- Do not call useNavigate within RenderInstance
- This breaks any plugins which try to use RenderInstance
- Pass navigate func through to <RenderInstance />

* Add playwright test for hover in forms

* Add translated plugin test

* Improve playwright tests

* Further unit test fixes

* Update docstring
This commit is contained in:
Oliver
2026-06-01 21:44:02 +10:00
committed by GitHub
parent f912ba501d
commit 7f86384a03
11 changed files with 155 additions and 19 deletions
+18 -2
View File
@@ -168,9 +168,14 @@ test('Stock - Filters', async ({ browser }) => {
// Filter by custom status code
await clearTableFilters(page);
await setTableChoiceFilter(page, 'Status', 'Incoming goods inspection');
await page.getByText('1 - 8 / 8').waitFor();
await page.getByRole('cell', { name: '1551AGY' }).first().waitFor();
await page.getByPlaceholder('Search').clear();
await page.getByPlaceholder('Search').fill('blue');
await page.getByRole('cell', { name: 'widget.blue' }).first().waitFor();
await page.getByPlaceholder('Search').clear();
await page.getByPlaceholder('Search').fill('002.01');
await page.getByRole('cell', { name: '002.01-PCBA' }).first().waitFor();
await clearTableFilters(page);
@@ -324,10 +329,20 @@ test('Stock - Stock Actions', async ({ browser }) => {
await page.getByRole('option', { name: status }).click();
};
// Duplicate the stock item first - prevent impacting other tests
await page
.getByRole('button', { name: 'action-menu-stock-item-actions' })
.click();
await page
.getByRole('menuitem', { name: 'action-menu-stock-item-actions-duplicate' })
.click();
await page.getByRole('button', { name: 'Submit' }).click();
await page.waitForLoadState('networkidle');
// Check for required values
await page.getByText('Status', { exact: true }).waitFor();
await page.getByText('Custom Status', { exact: true }).waitFor();
await page.getByText('Attention needed').waitFor();
await page.getByText('Attention needed').first().waitFor();
await page
.getByLabel('Stock Details')
.getByText('Incoming goods inspection')
@@ -705,6 +720,7 @@ test('Transfer Order - Allocate and Transfer', async ({ browser }) => {
await page.getByRole('button', { name: 'Issue Order' }).click();
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('Order issued').waitFor();
await page.getByText('Issued', { exact: true }).first().waitFor();
await loadTab(page, 'Line Items');
+35
View File
@@ -1,9 +1,44 @@
/** Unit tests for form validation, rendering, etc */
import { expect, test } from 'playwright/test';
import { createApi } from './api';
import { stevenuser } from './defaults';
import { navigate } from './helpers';
import { doCachedLogin } from './login';
// Test hover form action in related fields
test('Forms - Hover', async ({ browser }) => {
const page = await doCachedLogin(browser, {
user: stevenuser,
url: 'purchasing/index/purchaseorders'
});
// Patch user settings to ensure we can see "extra model info" on hover
const api = await createApi({
username: stevenuser.username,
password: stevenuser.testcred
});
const response = await api.patch('settings/user/SHOW_EXTRA_MODEL_INFO/', {
data: {
value: 'true'
}
});
expect(response.status()).toBe(200);
await page
.getByRole('button', { name: 'action-button-add-purchase-' })
.click();
await page.getByLabel('related-field-supplier').fill('mou');
await page.waitForLoadState('networkidle');
await page.waitForTimeout(250);
await page.getByRole('option', { name: 'Mouser Electronics' }).hover();
// Check for hover info
await page.getByText('Company[ID: 2]').waitFor();
await page.getByRole('link', { name: 'View details' }).waitFor();
});
test('Forms - Stock Item Validation', async ({ browser }) => {
const page = await doCachedLogin(browser, {
user: stevenuser,
+57
View File
@@ -253,3 +253,60 @@ test('Plugins - Locate Item', async ({ browser }) => {
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('Item location requested').waitFor();
});
/**
* Perform a full run through of validating a UI plugin:
*
* - Activate the plugin
* - Check that a custom panel is added
* - Check that expected translated text is added
* - Check that expected UI elements can be operated
*
* Note: This tests assumes that:
*
* - The inventree-plugin-creator tool has been installed
* - The default plugin has been created, build and installed
*/
test('Plugins - Creator', async ({ browser }) => {
const page = await doCachedLogin(browser, {
user: adminuser
});
// Ensure that the SampleIntegration plugin is enabled
await setPluginState({
plugin: 'my-custom-plugin',
state: true
});
// Allow time for installation of plugin static files, etc
await page.waitForTimeout(2500);
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 incrementing counter value
for (let i = 0; i < 5; i++) {
await page.getByText(`Counter: ${i}`).waitFor();
await page.getByRole('button', { name: 'Increment Counter' }).click();
}
// Edit part form
await page.getByRole('button', { name: 'Edit Part' }).click();
await page
.getByText('This is a custom form launched from within a plugin!')
.waitFor();
await page
.getByRole('textbox', { name: 'text-field-name' })
.fill('New part name');
await page.getByRole('button', { name: 'Cancel' }).click();
// View a custom table
await page.getByRole('button', { name: 'Custom Table Example' }).click();
await page.getByRole('textbox', { name: 'table-search-input' }).fill('red');
await page.waitForLoadState('networkidle');
await page.getByRole('cell', { name: 'Red Square Table' }).first().waitFor();
});
// Ensure that the sample full run plugin is enabled