mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-02 10:18:42 +00:00
Remember last used label template and printer plugin per model type (#12146)
* Remember last used label template and printer plugin per model type * Added playwright test for printing preference persistence and format code * Used waitFor for react-select assertions for test case fixing and persist plugin key correctly * Updated the problem resolution code and the tests * Fixed printing test assertion to avoid word boundary failure with concatenated text
This commit is contained in:
@@ -65,7 +65,42 @@ test('Printing - Label Printing', async ({ browser }) => {
|
||||
await page.getByRole('button', { name: 'Print', exact: true }).isEnabled();
|
||||
await page.getByRole('button', { name: 'Print', exact: true }).click();
|
||||
|
||||
await page.getByText('Process completed successfully').first().waitFor();
|
||||
const successMessage = page
|
||||
.getByText('Process completed successfully')
|
||||
.first();
|
||||
await successMessage.waitFor();
|
||||
await successMessage.waitFor({ state: 'hidden' });
|
||||
|
||||
// Re-open print dialog to verify persistence (issue #12129)
|
||||
await page
|
||||
.getByLabel('Stock Items')
|
||||
.getByLabel('action-menu-printing-actions')
|
||||
.click();
|
||||
await page.getByLabel('action-menu-printing-actions-print-labels').click();
|
||||
|
||||
const labelDialog = page.getByRole('dialog', { name: 'Print Label' });
|
||||
|
||||
// Wait for the dialog to fully load
|
||||
await labelDialog.getByLabel('related-field-template').waitFor();
|
||||
await labelDialog.getByLabel('related-field-plugin').waitFor();
|
||||
|
||||
// Verify the last-used template is preselected
|
||||
await expect(labelDialog).toContainText('InvenTree Stock Item Label');
|
||||
|
||||
// Verify the last-used plugin is preselected
|
||||
await expect(labelDialog).toContainText('InvenTreeLabel');
|
||||
|
||||
// Submit again without re-selecting template or plugin
|
||||
const printResponse = page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/api/label/print/') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.ok()
|
||||
);
|
||||
await labelDialog.getByRole('button', { name: 'Print', exact: true }).click();
|
||||
|
||||
await printResponse;
|
||||
|
||||
await page.context().close();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user