mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-15 15:58:48 +00:00
Added keep open boolean field to Stock Location modal form (#11074)
* Added keep open boolean field to Stock Location modal form * Rewrite keep form open field feature to avoid calling methods in form field definitions * Rewrite keep form open feature as common form property * Removed unused artefact from previous implementation * keepOpenOption removed as default option for all create forms. Instead it's enabled on selected forms. * keepOpenOption field speed improvement - using useRef instead of useState - keepOpenSwitch moved to own component * Added keep form open feature to changelog * Updated documentation: keep form open feature added to concepts/user_interface docs * Added test case for "keep form open" feature * Changed switch selector in keep form open feature test --------- Co-authored-by: spm <jan.krajdl@cecolo.com> Co-authored-by: Oliver <oliver.henry.walters@gmail.com> Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/** Unit tests for form validation, rendering, etc */
|
||||
import test from 'playwright/test';
|
||||
import { expect, test } from 'playwright/test';
|
||||
import { stevenuser } from './defaults';
|
||||
import { navigate } from './helpers';
|
||||
import { doCachedLogin } from './login';
|
||||
@@ -134,3 +134,37 @@ test('Forms - Supplier Validation', async ({ browser }) => {
|
||||
await page.getByText('Form Error').waitFor();
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
});
|
||||
|
||||
test('Forms - Keep form open option', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
user: stevenuser,
|
||||
url: 'stock/location/index/sublocations'
|
||||
});
|
||||
await page.waitForURL('**/stock/location/index/**');
|
||||
|
||||
await page.getByLabel('action-button-add-stock-location').click();
|
||||
|
||||
// Generate unique location name
|
||||
const locationName = `New Sublocation ${new Date().getTime()}`;
|
||||
|
||||
await page.getByLabel('text-field-name', { exact: true }).fill(locationName);
|
||||
|
||||
// Check keep form open switch and submit
|
||||
await page.getByRole('switch', { name: 'Keep form open' }).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Location should be created, form should remain opened
|
||||
await page.getByText('Item Created').waitFor();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Create another location and uncheck this option
|
||||
await page
|
||||
.getByLabel('text-field-name', { exact: true })
|
||||
.fill(`Another ${locationName}`);
|
||||
await page.getByRole('switch', { name: 'Keep form open' }).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Location should be created, and the form (modal) should disappear
|
||||
await page.getByText('Item Created').waitFor();
|
||||
await expect(page.getByRole('dialog')).toBeHidden();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user