Skip to content

Commit

Permalink
[PUI] Test modals (#7113)
Browse files Browse the repository at this point in the history
* 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 7771189.

* 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 28d96e0.

* 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
  • Loading branch information
matmair authored Apr 23, 2024
1 parent 37956db commit 5f54aef
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/frontend/src/components/buttons/ScanButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function ScanButton() {
innerProps: {}
})
}
title={t`Open QR code scanner`}
>
<IconQrcode />
</ActionIcon>
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/components/modals/LicenseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export function LicenceView(entries: Readonly<any[]>) {
{entries?.length > 0 ? (
<Accordion variant="contained" defaultValue="-">
{entries?.map((entry: any, index: number) => (
<Accordion.Item key={entry.name} value={`entry-${index}`}>
<Accordion.Item
key={entry.name + entry.license + entry.version}
value={`entry-${index}`}
>
<Accordion.Control>
<Group position="apart" grow>
<Text>{entry.name}</Text>
Expand Down
74 changes: 74 additions & 0 deletions src/frontend/tests/modals.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});

0 comments on commit 5f54aef

Please sign in to comment.