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:
Sanidhya
2026-06-13 13:30:42 +10:00
committed by GitHub
parent d8ae8723ff
commit 3bce9c0a15
3 changed files with 85 additions and 5 deletions
+36 -1
View File
@@ -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();
});