2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-27 11:06:44 +00:00
Oliver 662a0b275e
[UI] Web Prefix (#9334)
* [UI] Change default web prefix

- Adjust default from "platform" to "web"
- Much more standard prefix

* Cleanup

* Fixes for playwright tests

* Fix unit tests

* Refactor base_url into getBaseUrl
2025-03-20 00:12:52 +11:00

50 lines
1.5 KiB
TypeScript

import { expect } from './baseFixtures.js';
import { baseUrl, logoutUrl, user } from './defaults';
import { navigate } from './helpers.js';
/*
* Perform form based login operation from the "login" URL
*/
export const doLogin = async (page, username?: string, password?: string) => {
username = username ?? user.username;
password = password ?? user.password;
await navigate(page, logoutUrl);
await expect(page).toHaveTitle(/^InvenTree.*$/);
await page.waitForURL('**/web/login');
await page.getByLabel('username').fill(username);
await page.getByLabel('password').fill(password);
await page.getByRole('button', { name: 'Log in' }).click();
await page.waitForURL('**/web/home');
await page.waitForTimeout(250);
};
/*
* Perform a quick login based on passing URL parameters
*/
export const doQuickLogin = async (
page,
username?: string,
password?: string,
url?: string
) => {
username = username ?? user.username;
password = password ?? user.password;
url = url ?? baseUrl;
await navigate(page, `${url}/login?login=${username}&password=${password}`);
await page.waitForURL('**/web/home');
await page.getByLabel('navigation-menu').waitFor({ timeout: 5000 });
await page.getByText(/InvenTree Demo Server -/).waitFor();
// Wait for the dashboard to load
await page.getByText('No widgets selected').waitFor();
await page.waitForTimeout(250);
};
export const doLogout = async (page) => {
await navigate(page, 'logout');
await page.waitForURL('**/web/login');
};