mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
* Refactor login state management - Previously relied only on presence of cookie - Cookie may not actually be *valid* - Inspect actual login state by looking at userState values - Ensures better sequencing of global state API requests - Login state is now correctly preseed across browsers * Ignore errors for user/me/ API endpoint in playwright test * Do not request notifications unless logged in * Prevent duplicate licenses * Update src/frontend/src/views/DesktopAppView.tsx Co-authored-by: Matthias Mair <code@mjmair.com> * Simplify checkLoginState * Fix bug in return types * Update playwright tests * linting * Remove error msg * Use token auth for API calls - Will (hopefully) allow us to bypass csrfmiddle request handling? * Refetch token if not available * Use cache for DISPLAY_FULL_NAMES setting * Update src/frontend/tests/baseFixtures.ts Co-authored-by: Matthias Mair <code@mjmair.com> * PUI test updates * Tweak doLogout function * Revert change to baseFixtures.ts * Cleanup * Fix highlighted property * Test cleanup --------- Co-authored-by: Matthias Mair <code@mjmair.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { expect, test } from './baseFixtures.js';
|
|
import { baseUrl, loginUrl, user } from './defaults.js';
|
|
import { doLogin, doQuickLogin } from './login.js';
|
|
|
|
test('PUI - Basic Login Test', async ({ page }) => {
|
|
await doLogin(page);
|
|
|
|
// Check that the username is provided
|
|
await page.getByText(user.username);
|
|
|
|
await expect(page).toHaveTitle(RegExp('^InvenTree'));
|
|
|
|
// Go to the dashboard
|
|
await page.goto(baseUrl);
|
|
await page.waitForURL('**/platform');
|
|
|
|
await page
|
|
.getByRole('heading', { name: `Welcome to your Dashboard, ${user.name}` })
|
|
.click();
|
|
|
|
// Check that the username is provided
|
|
await page.getByText(user.username);
|
|
|
|
await expect(page).toHaveTitle(RegExp('^InvenTree'));
|
|
|
|
// Go to the dashboard
|
|
await page.goto(baseUrl);
|
|
await page.waitForURL('**/platform');
|
|
|
|
// Logout (via menu)
|
|
await page.getByRole('button', { name: 'Ally Access' }).click();
|
|
await page.getByRole('menuitem', { name: 'Logout' }).click();
|
|
|
|
await page.waitForURL('**/platform/login');
|
|
await page.getByLabel('username');
|
|
});
|
|
|
|
test('PUI - Quick Login Test', async ({ page }) => {
|
|
await doQuickLogin(page);
|
|
|
|
// Check that the username is provided
|
|
await page.getByText(user.username);
|
|
|
|
await expect(page).toHaveTitle(RegExp('^InvenTree'));
|
|
|
|
// Go to the dashboard
|
|
await page.goto(baseUrl);
|
|
await page.waitForURL('**/platform');
|
|
|
|
await page
|
|
.getByRole('heading', { name: `Welcome to your Dashboard, ${user.name}` })
|
|
.click();
|
|
|
|
// Logout (via URL)
|
|
await page.goto(`${baseUrl}/logout/`);
|
|
await page.waitForURL('**/platform/login');
|
|
});
|