2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

add tests

This commit is contained in:
wolflu05
2024-09-18 13:13:07 +02:00
parent 4fb94615d4
commit 498c7ea73c
5 changed files with 191 additions and 105 deletions

View File

@ -1,4 +1,4 @@
import { test } from './baseFixtures.js';
import { expect, test } from './baseFixtures.js';
import { baseUrl } from './defaults.js';
import { doQuickLogin } from './login.js';
@ -104,5 +104,33 @@ test('PUI - Report Editing', async ({ page }) => {
await page.getByText('The preview has been updated').waitFor();
// Test plugin provided editors
await page.getByRole('tab', { name: 'Sample Template Editor' }).click();
const textarea = page.locator('#sample-template-editor-textarea');
const textareaValue = await textarea.inputValue();
expect(textareaValue).toContain(
`<img class='qr' alt="{% trans 'QR Code' %}" src='{% qrcode qr_data %}'>`
);
textarea.fill(textareaValue + '\nHello world');
// Switch back and forth to see if the changed contents get correctly passed between the hooks
await page.getByRole('tab', { name: 'Code', exact: true }).click();
await page.getByRole('tab', { name: 'Sample Template Editor' }).click();
const newTextareaValue = await page
.locator('#sample-template-editor-textarea')
.inputValue();
expect(newTextareaValue).toMatch(/\nHello world$/);
// Test plugin provided previews
await page.getByRole('tab', { name: 'Sample Template Preview' }).click();
await page.getByRole('heading', { name: 'Hello world' }).waitFor();
const consoleLogPromise = page.waitForEvent('console');
await page
.getByLabel('split-button-preview-options', { exact: true })
.click();
const msg = (await consoleLogPromise).args();
expect(await msg[0].jsonValue()).toBe('updatePreview');
expect((await msg[1].jsonValue())[0]).toBe(newTextareaValue);
await page.context().close();
});