2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-03 13:58:47 +00:00
InvenTree/src/frontend/tests/cui.spec.ts
Oliver 0ba7f7ece5
[PUI] Session authentication (#6970)
* Adjust backend cookie settings

* Allow CORS requests to /accounts/

* Refactor frontend code

- Remove API token functions
- Simplify cookie approach
- Add isLoggedIn method

* Adjust REST_AUTH settings

* Cleanup auth functions in auth.tsx

* Adjust CSRF_COOKIE_SAMESITE value

* Fix login request

* Prevent session auth on login view

- Existing (invalid) session token causes 403

* Refactor ApiImage

- Point to the right host
- Simplify code
- Now we use session cookies, so it *Just Works*

* Fix download for attachment table

- Now works with remote host

* Cleanup settings.py

* Refactor login / logout notifications

* Update API version

* Update src/frontend/src/components/items/AttachmentLink.tsx

Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com>

* fix assert url

* Remove comment

* Add explicit page to logout user

* Change tests to first logout

* Prune dead code

* Adjust tests

* Cleanup

* Direct to login view

* Trying something

* Update CUI test

* Fix basic tests

* Refactoring

* Fix basic checks

* Fix for PUI command tests

* More test updates

* Add speciifc test for quick login

* More cleanup of playwright tests

* Add some missing icons

* Fix typo

* Ignore coverage report for playwright test

* Remove coveralls upload task

---------

Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com>
Co-authored-by: Matthias Mair <code@mjmair.com>
2024-04-17 21:35:20 +10:00

32 lines
1.2 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { classicUrl, user } from './defaults';
test('CUI - Index', async ({ page }) => {
await page.goto(`${classicUrl}/api/`);
await page.goto(`${classicUrl}/index/`, { timeout: 10000 });
console.log('Page title:', await page.title());
await expect(page).toHaveTitle(RegExp('^InvenTree.*Sign In$'));
await expect(page.getByRole('heading', { name: 'Sign In' })).toBeVisible();
await page.getByLabel('username').fill(user.username);
await page.getByLabel('password').fill(user.password);
await page.click('button', { text: 'Sign In' });
await page.waitForURL('**/index/');
await page.waitForLoadState('networkidle');
await expect(page).toHaveTitle('InvenTree Demo Server | Index');
await expect(page.getByRole('button', { name: user.username })).toBeVisible();
await expect(
page.getByRole('link', { name: 'Parts', exact: true })
).toBeVisible();
await expect(
page.getByRole('link', { name: 'Stock', exact: true })
).toBeVisible();
await expect(
page.getByRole('link', { name: 'Build', exact: true })
).toBeVisible();
await expect(page.getByRole('button', { name: 'Buy' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Sell' })).toBeVisible();
});