diff --git a/src/frontend/src/components/forms/fields/RelatedModelField.tsx b/src/frontend/src/components/forms/fields/RelatedModelField.tsx index 43f1d3456b..0775f9ab8c 100644 --- a/src/frontend/src/components/forms/fields/RelatedModelField.tsx +++ b/src/frontend/src/components/forms/fields/RelatedModelField.tsx @@ -365,7 +365,6 @@ export function RelatedModelField({ filterOption={null} onInputChange={(value: any) => { setValue(value); - resetSearch(); }} onChange={onChange} onMenuScrollToBottom={() => setOffset(offset + limit)} diff --git a/src/frontend/tests/pages/pui_build.spec.ts b/src/frontend/tests/pages/pui_build.spec.ts index df7a400690..964a1a3732 100644 --- a/src/frontend/tests/pages/pui_build.spec.ts +++ b/src/frontend/tests/pages/pui_build.spec.ts @@ -331,6 +331,22 @@ test('Build Order - Tracked Outputs', async ({ browser }) => { url: 'manufacturing/build-order/10/incomplete-outputs' }); + const cancelBuildOutput = async (cell) => { + await clickOnRowMenu(cell); + await page.getByRole('menuitem', { name: 'Cancel' }).click(); + await page.getByRole('button', { name: 'Submit' }).click(); + await page.getByText('Build outputs have been cancelled').waitFor(); + }; + + // Ensure table has loaded + await page.getByRole('cell', { name: '# 13' }).waitFor(); + + // Check if the build output "#15" exists. If so, remove it. + const existingCell = await page.getByRole('cell', { name: '# 15' }); + if (await existingCell.isVisible()) { + await cancelBuildOutput(existingCell); + } + // Create a new build output, serial number 15 await page .getByRole('button', { name: 'action-button-add-build-output' }) @@ -362,9 +378,12 @@ test('Build Order - Tracked Outputs', async ({ browser }) => { .waitFor(); // The stock item should be pre-filled based on serial number + await page.getByRole('cell', { name: 'Thumbnail 002.01-PCBA |' }).waitFor(); await page.getByRole('button', { name: 'Submit' }).isEnabled(); await page.getByRole('button', { name: 'Submit' }).click(); + await page.getByText('Stock items allocated').waitFor(); + await allocationRow.getByText('1 / 1').waitFor(); // Close the allocation wizard @@ -375,12 +394,15 @@ test('Build Order - Tracked Outputs', async ({ browser }) => { await row.getByText('0 / 2').waitFor(); // Cancel the build output to return to the original state - await clickOnRowMenu(cell); - await page.getByRole('menuitem', { name: 'Cancel' }).click(); - await page.getByRole('button', { name: 'Submit' }).click(); - await page.getByText('Build outputs have been cancelled').waitFor(); + await cancelBuildOutput(cell); // Next, complete a new output and auto-allocate items based on serial number + // Cancel build output "#16" if it exists + const existingCell16 = await page.getByRole('cell', { name: '# 16' }); + if (await existingCell16.isVisible()) { + await cancelBuildOutput(existingCell16); + } + await page .getByRole('button', { name: 'action-button-add-build-output' }) .click(); @@ -401,10 +423,7 @@ test('Build Order - Tracked Outputs', async ({ browser }) => { await newRow.getByText('0 / 2').waitFor(); // Cancel this output too - await clickOnRowMenu(newCell); - await page.getByRole('menuitem', { name: 'Cancel' }).click(); - await page.getByRole('button', { name: 'Submit' }).click(); - await page.getByText('Build outputs have been cancelled').waitFor(); + await cancelBuildOutput(newCell); }); test('Build Order - Filters', async ({ browser }) => { diff --git a/src/frontend/tests/pages/pui_part.spec.ts b/src/frontend/tests/pages/pui_part.spec.ts index 0e365a21f9..8b347961e8 100644 --- a/src/frontend/tests/pages/pui_part.spec.ts +++ b/src/frontend/tests/pages/pui_part.spec.ts @@ -199,12 +199,15 @@ test('Parts - Details', async ({ browser }) => { await page.getByText('Can Build').waitFor(); await page.getByText('0 / 10').waitFor(); - await page.getByText('4 / 49').waitFor(); + + // Depending on the state of other tests, the "In Production" value may vary + // This could be either 4 / 49, or 5 / 49 + await page.getByText(/[4|5] \/ 49/).waitFor(); // Badges await page.getByText('Required: 10').waitFor(); await page.getByText('No Stock').waitFor(); - await page.getByText('In Production: 4').waitFor(); + await page.getByText(/In Production: [4|5]/).waitFor(); await page.getByText('Creation Date').waitFor(); await page.getByText('2022-04-29').waitFor();