mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-15 15:58:48 +00:00
Selection lists updates (#11705)
* Add search capability to selection list entry endpoint * Use API lookup for selection entries * Add renderer func * Allow API filtering * Fetch selectionentry data related to the selected data item * remove now unneeded entry * add missing modelinfo * fix ref * add api bump * Provide optional single fetch function to API forms - Useful if we need to perform a custom API call for initial data * django-admin support for SelectionList * Docstring improvements * Apply 'active' filter * Tweak api version entry * Playwright tests * Tweak docs wording * Fix incorrect docstring * Adjust playwright tests --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
@@ -667,7 +667,37 @@ test('Parts - Parameters by Category', async ({ browser }) => {
|
||||
});
|
||||
|
||||
test('Parts - Parameters', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, { url: 'part/69/parameters' });
|
||||
const page = await doCachedLogin(browser, { url: 'part/915/parameters' });
|
||||
|
||||
// Edit parameter defined with a SelectionListEntry
|
||||
const animalCell = await page.getByRole('cell', {
|
||||
name: 'Animal',
|
||||
exact: true
|
||||
});
|
||||
await clickOnRowMenu(animalCell);
|
||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||
|
||||
// Check the data field, which should be populated with the options defined in the "Animal" parameter template
|
||||
// If both values are present, we know that the correct SelectionListEntry has been loaded
|
||||
await page
|
||||
.getByText('Data *Parameter')
|
||||
.getByText(/Armadillo/i)
|
||||
.waitFor();
|
||||
await page
|
||||
.getByText('Data *Parameter')
|
||||
.getByText(/A mammal known for/i)
|
||||
.waitFor();
|
||||
|
||||
// Check for other values
|
||||
await page
|
||||
.getByRole('combobox', { name: 'related-field-data' })
|
||||
.fill('horse');
|
||||
await page.getByText('The offspring of a male donkey').waitFor();
|
||||
await page.getByText('A small marine fish with a head').waitFor();
|
||||
await page.getByText('Zebra').click();
|
||||
|
||||
// Close the edit dialog
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
// check that "is polarized" parameter is not already present - if it is, delete it before proceeding with the rest of the test
|
||||
await page
|
||||
|
||||
@@ -82,6 +82,52 @@ test('Purchasing - Index', async ({ browser }) => {
|
||||
.waitFor();
|
||||
});
|
||||
|
||||
test('Purchasing - Parameters', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'purchasing/purchase-order/11/parameters'
|
||||
});
|
||||
|
||||
// Create a new parameter against this purchase order
|
||||
// We will use a "SelectionList" to choose the value here
|
||||
await page
|
||||
.getByRole('button', { name: 'action-menu-add-parameters' })
|
||||
.click();
|
||||
await page
|
||||
.getByRole('menuitem', {
|
||||
name: 'action-menu-add-parameters-create-parameter'
|
||||
})
|
||||
.click();
|
||||
|
||||
// Select the template
|
||||
await page
|
||||
.getByRole('combobox', { name: 'related-field-template' })
|
||||
.fill('animal');
|
||||
await page.getByRole('option', { name: 'Animal Select an animal' }).click();
|
||||
|
||||
// Select an animal
|
||||
await page.getByRole('combobox', { name: 'related-field-data' }).fill('cat');
|
||||
await page.getByRole('option', { name: 'Caracal' }).click();
|
||||
|
||||
// Add a note and submit the form
|
||||
await page
|
||||
.getByRole('textbox', { name: 'text-field-note' })
|
||||
.fill('The caracal is an interesting beast');
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Let's edit this parameter to ensure the "edit" form works as expected
|
||||
await clickOnRowMenu(await page.getByRole('cell', { name: 'Caracal' }));
|
||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||
|
||||
await page.getByRole('combobox', { name: 'related-field-data' }).fill('ox');
|
||||
await page.getByRole('option', { name: 'Fennec Fox' }).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Finally, delete the parameter
|
||||
await clickOnRowMenu(await page.getByRole('cell', { name: 'Fennec Fox' }));
|
||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||
await page.getByRole('button', { name: 'Delete', exact: true }).click();
|
||||
});
|
||||
|
||||
test('Purchasing - Manufacturer Parts', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'purchasing/index/manufacturer-parts'
|
||||
|
||||
@@ -402,12 +402,12 @@ test('Settings - Admin - Parameter', async ({ browser }) => {
|
||||
|
||||
await loadTab(page, 'Parameters', true);
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Clean old template data if exists
|
||||
await page
|
||||
.getByRole('cell', { name: 'my custom parameter' })
|
||||
.getByRole('cell', { name: 'my custom parameter', exact: true })
|
||||
.waitFor({ timeout: 500 })
|
||||
.then(async (cell) => {
|
||||
await page
|
||||
@@ -420,11 +420,14 @@ test('Settings - Admin - Parameter', async ({ browser }) => {
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
await page.getByRole('button', { name: 'Selection Lists' }).click();
|
||||
// Allow time for the table to load
|
||||
await page.waitForTimeout(1000);
|
||||
await page.getByRole('button', { name: 'Selection Lists' }).click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Check for expected entry
|
||||
await page.getByRole('cell', { name: 'Animals', exact: true }).waitFor();
|
||||
await page.getByText('Various animals and descriptions thereof').waitFor();
|
||||
|
||||
// Clean old list data if exists
|
||||
await page
|
||||
.getByRole('cell', { name: 'some list' })
|
||||
@@ -445,6 +448,19 @@ test('Settings - Admin - Parameter', async ({ browser }) => {
|
||||
await page.getByLabel('action-button-add-selection-').click();
|
||||
await page.getByLabel('text-field-name').fill('some list');
|
||||
await page.getByLabel('text-field-description').fill('Listdescription');
|
||||
|
||||
// Add an entry to the selection list
|
||||
await page.getByRole('button', { name: 'action-button-add-new-row' }).click();
|
||||
await page.getByRole('textbox', { name: 'text-field-value' }).fill('HW');
|
||||
await page
|
||||
.getByRole('textbox', { name: 'text-field-label' })
|
||||
.fill('Hardwood');
|
||||
await page
|
||||
.getByRole('row', { name: 'boolean-field-active action-' })
|
||||
.getByLabel('text-field-description')
|
||||
.fill('Hardwood materials');
|
||||
await page.getByRole('cell', { name: 'boolean-field-active' }).click();
|
||||
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByRole('cell', { name: 'some list' }).waitFor();
|
||||
|
||||
@@ -494,9 +510,18 @@ test('Settings - Admin - Parameter', async ({ browser }) => {
|
||||
.filter({ hasText: /^Search\.\.\.$/ })
|
||||
.locator('input')
|
||||
.fill('my custom parameter');
|
||||
|
||||
await page.getByRole('option', { name: 'my custom parameter' }).click();
|
||||
await page.getByLabel('choice-field-data').fill('2');
|
||||
|
||||
// Finally, select value from the SelectionList data
|
||||
await page.getByRole('combobox', { name: 'related-field-data' }).fill('wood');
|
||||
await page
|
||||
.getByRole('option', { name: 'Hardwood Hardwood materials' })
|
||||
.click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Check for the expected value
|
||||
await page.getByRole('cell', { name: 'HW', exact: true }).waitFor();
|
||||
});
|
||||
|
||||
test('Settings - Admin - Unauthorized', async ({ browser }) => {
|
||||
|
||||
Reference in New Issue
Block a user