From 5f54aef79a3d58539ebff65510db2e35783f67f6 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 24 Apr 2024 01:59:03 +0200 Subject: [PATCH] [PUI] Test modals (#7113) * add spotlight * [PUI] Quick commands pallet Fixes #5888 * add testing for new commands * add text input testing * only test backend if code changed * add trans files * fix testing text * always push coverage * add nav state to manage navigation state * add navigation action and test * make test faster * fix typo * use texts instead * fix tests for linux * use var to determine action key * Revert "use texts instead" This reverts commit 77711895569a42426a422d679496661c0ee9d25b. * add wait for input * split out keyboard based tests * split ou test * add upload * revert assert change * adjust reporting settings * ignore error code * fix reporter config * add full info suit (+tests) * make tests more accurate * license modal fixes * unify icons * add custom actions registering with removal on page refresh * only upload report data if the tests failed * Revert "add trans files" This reverts commit 28d96e058febba96979afd3054e04cd207bffba5. * adjust url that iw waited for * try an await and body locator for keypresses * test registering addition actions * extend testing for actions * add doclink and test * merge tests * add modals test * use quick login * reduce diff * fix test * open packages too * expand to frontend * rnsure keys are unique * ensure no errors in console * add QR code modal too --- .../src/components/buttons/ScanButton.tsx | 1 + .../src/components/modals/LicenseModal.tsx | 5 +- src/frontend/tests/modals.spec.ts | 74 +++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/frontend/tests/modals.spec.ts diff --git a/src/frontend/src/components/buttons/ScanButton.tsx b/src/frontend/src/components/buttons/ScanButton.tsx index c3fe6d14b5..83dd990aaf 100644 --- a/src/frontend/src/components/buttons/ScanButton.tsx +++ b/src/frontend/src/components/buttons/ScanButton.tsx @@ -16,6 +16,7 @@ export function ScanButton() { innerProps: {} }) } + title={t`Open QR code scanner`} > diff --git a/src/frontend/src/components/modals/LicenseModal.tsx b/src/frontend/src/components/modals/LicenseModal.tsx index a790e765b5..c321d11532 100644 --- a/src/frontend/src/components/modals/LicenseModal.tsx +++ b/src/frontend/src/components/modals/LicenseModal.tsx @@ -23,7 +23,10 @@ export function LicenceView(entries: Readonly) { {entries?.length > 0 ? ( {entries?.map((entry: any, index: number) => ( - + {entry.name} diff --git a/src/frontend/tests/modals.spec.ts b/src/frontend/tests/modals.spec.ts new file mode 100644 index 0000000000..4d628eaf1f --- /dev/null +++ b/src/frontend/tests/modals.spec.ts @@ -0,0 +1,74 @@ +import { test } from './baseFixtures.js'; +import { doQuickLogin } from './login.js'; + +test('PUI - Modals as admin', async ({ page }) => { + await doQuickLogin(page, 'admin', 'inventree'); + + // Fail on console error + await page.on('console', (msg) => { + if (msg.type() === 'error') test.fail(); + }); + + // use server info + await page.getByRole('button', { name: 'Open spotlight' }).click(); + await page + .getByRole('button', { + name: 'Server Information About this Inventree instance' + }) + .click(); + await page.getByRole('cell', { name: 'Instance Name' }).waitFor(); + await page.getByRole('button', { name: 'Dismiss' }).click(); + + await page.waitForURL('**/platform/home'); + + // use license info + await page.getByRole('button', { name: 'Open spotlight' }).click(); + await page + .getByRole('button', { + name: 'License Information Licenses for dependencies of the service' + }) + .click(); + await page.getByText('License Information').first().waitFor(); + await page.getByRole('tab', { name: 'backend Packages' }).click(); + await page.getByRole('button', { name: 'Babel BSD License' }).click(); + await page.getByText('Copyright (c) 2013-2023 by').waitFor(); + + await page.getByRole('tab', { name: 'frontend Packages' }).click(); + await page.getByRole('button', { name: '@sentry/utils MIT' }).click(); + await page + .getByLabel('@sentry/utilsMIT7.109.0') + .getByText('Copyright (c) 2019 Sentry (') + .waitFor(); + + await page + .getByLabel('License Information') + .getByRole('button') + .first() + .click(); + + // use about + await page.getByRole('button', { name: 'Open spotlight' }).click(); + await page + .getByRole('button', { name: 'About InvenTree About the InvenTree org' }) + .click(); + await page.getByRole('cell', { name: 'InvenTree Version' }).click(); + + await page.goto('./platform/'); + + // qr code modal + await page.getByRole('button', { name: 'Open QR code scanner' }).click(); + await page + .locator('div') + .filter({ hasText: /^Scan QR code$/ }) + .getByRole('button') + .click(); + await page.getByRole('button', { name: 'Open QR code scanner' }).click(); + await page.getByRole('button', { name: 'Close modal' }).click(); + await page.getByRole('button', { name: 'Open QR code scanner' }).click(); + await page.waitForTimeout(500); + await page + .locator('div') + .filter({ hasText: /^Scan QR code$/ }) + .getByRole('button') + .click(); +});