2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00

[CI] Playwright testing improvements (#8985)

* Run playwright tests in headless mode

* Add navigation helper

* Validate files

* test fix

* Remove 'headless'

* Fixes

* Fix for 'navigate' helper

* Further updates
This commit is contained in:
Oliver 2025-02-01 16:29:13 +11:00 committed by GitHub
parent 66496fb669
commit 821b311d73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 116 additions and 87 deletions

View File

@ -1,3 +1,5 @@
import { baseUrl } from './defaults';
/** /**
* Open the filter drawer for the currently visible table * Open the filter drawer for the currently visible table
* @param page - The page object * @param page - The page object
@ -62,3 +64,20 @@ export const setTableChoiceFilter = async (page, filter, value) => {
export const getRowFromCell = async (cell) => { export const getRowFromCell = async (cell) => {
return cell.locator('xpath=ancestor::tr').first(); return cell.locator('xpath=ancestor::tr').first();
}; };
/**
* Navigate to the provided page, and wait for loading to complete
* @param page
* @param url
*/
export const navigate = async (page, url: string) => {
if (!url.startsWith(baseUrl)) {
if (url.startsWith('/')) {
url = url.slice(1);
}
url = `${baseUrl}/${url}`;
}
await page.goto(url, { waitUntil: 'domcontentloaded' });
};

View File

@ -1,5 +1,6 @@
import { expect } from './baseFixtures.js'; import { expect } from './baseFixtures.js';
import { baseUrl, logoutUrl, user } from './defaults'; import { baseUrl, logoutUrl, user } from './defaults';
import { navigate } from './helpers.js';
/* /*
* Perform form based login operation from the "login" URL * Perform form based login operation from the "login" URL
@ -8,7 +9,7 @@ export const doLogin = async (page, username?: string, password?: string) => {
username = username ?? user.username; username = username ?? user.username;
password = password ?? user.password; password = password ?? user.password;
await page.goto(logoutUrl); await navigate(page, logoutUrl);
await expect(page).toHaveTitle(/^InvenTree.*$/); await expect(page).toHaveTitle(/^InvenTree.*$/);
await page.waitForURL('**/platform/login'); await page.waitForURL('**/platform/login');
await page.getByLabel('username').fill(username); await page.getByLabel('username').fill(username);
@ -31,7 +32,7 @@ export const doQuickLogin = async (
password = password ?? user.password; password = password ?? user.password;
url = url ?? baseUrl; url = url ?? baseUrl;
await page.goto(`${url}/login/?login=${username}&password=${password}`); await navigate(page, `${url}/login/?login=${username}&password=${password}`);
await page.waitForURL('**/platform/home'); await page.waitForURL('**/platform/home');
await page.getByLabel('navigation-menu').waitFor(); await page.getByLabel('navigation-menu').waitFor();
@ -43,6 +44,6 @@ export const doQuickLogin = async (
}; };
export const doLogout = async (page) => { export const doLogout = async (page) => {
await page.goto(`${baseUrl}/logout/`); await navigate(page, 'logout');
await page.waitForURL('**/platform/login'); await page.waitForURL('**/platform/login');
}; };

View File

@ -1,8 +1,8 @@
import { test } from '../baseFixtures.ts'; import { test } from '../baseFixtures.ts';
import { baseUrl } from '../defaults.ts';
import { import {
clearTableFilters, clearTableFilters,
getRowFromCell, getRowFromCell,
navigate,
setTableChoiceFilter setTableChoiceFilter
} from '../helpers.ts'; } from '../helpers.ts';
import { doQuickLogin } from '../login.ts'; import { doQuickLogin } from '../login.ts';
@ -10,7 +10,7 @@ import { doQuickLogin } from '../login.ts';
test('Build Order - Basic Tests', async ({ page }) => { test('Build Order - Basic Tests', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/`); await navigate(page, 'part/');
// Navigate to the correct build order // Navigate to the correct build order
await page.getByRole('tab', { name: 'Manufacturing', exact: true }).click(); await page.getByRole('tab', { name: 'Manufacturing', exact: true }).click();
@ -90,7 +90,7 @@ test('Build Order - Basic Tests', async ({ page }) => {
test('Build Order - Edit', async ({ page }) => { test('Build Order - Edit', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/manufacturing/build-order/22/`); await navigate(page, 'manufacturing/build-order/22/');
// Check for expected text items // Check for expected text items
await page.getByText('Building for sales order').first().waitFor(); await page.getByText('Building for sales order').first().waitFor();
@ -117,7 +117,7 @@ test('Build Order - Edit', async ({ page }) => {
test('Build Order - Build Outputs', async ({ page }) => { test('Build Order - Build Outputs', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/manufacturing/index/`); await navigate(page, 'manufacturing/index/');
await page.getByRole('tab', { name: 'Build Orders', exact: true }).click(); await page.getByRole('tab', { name: 'Build Orders', exact: true }).click();
// We have now loaded the "Build Order" table. Check for some expected texts // We have now loaded the "Build Order" table. Check for some expected texts
@ -191,7 +191,7 @@ test('Build Order - Build Outputs', async ({ page }) => {
test('Build Order - Allocation', async ({ page }) => { test('Build Order - Allocation', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/manufacturing/build-order/1/line-items`); await navigate(page, 'manufacturing/build-order/1/line-items');
// Expand the R_10K_0805 line item // Expand the R_10K_0805 line item
await page.getByText('R_10K_0805_1%').first().click(); await page.getByText('R_10K_0805_1%').first().click();
@ -291,7 +291,7 @@ test('Build Order - Allocation', async ({ page }) => {
test('Build Order - Filters', async ({ page }) => { test('Build Order - Filters', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/manufacturing/index/buildorders`); await navigate(page, 'manufacturing/index/buildorders');
await clearTableFilters(page); await clearTableFilters(page);
await page.getByText('1 - 24 / 24').waitFor(); await page.getByText('1 - 24 / 24').waitFor();

View File

@ -1,6 +1,5 @@
import { test } from '../baseFixtures'; import { test } from '../baseFixtures';
import { baseUrl } from '../defaults'; import { clearTableFilters, getRowFromCell, navigate } from '../helpers';
import { clearTableFilters, getRowFromCell } from '../helpers';
import { doQuickLogin } from '../login'; import { doQuickLogin } from '../login';
/** /**
@ -45,7 +44,7 @@ test('Parts - Tabs', async ({ page }) => {
await page.getByRole('tab', { name: 'Used In' }).click(); await page.getByRole('tab', { name: 'Used In' }).click();
await page.getByRole('tab', { name: 'Pricing' }).click(); await page.getByRole('tab', { name: 'Pricing' }).click();
await page.goto(`${baseUrl}/part/category/index/parts`); await navigate(page, 'part/category/index/parts');
await page.getByText('Blue Chair').click(); await page.getByText('Blue Chair').click();
await page.getByRole('tab', { name: 'Bill of Materials' }).click(); await page.getByRole('tab', { name: 'Bill of Materials' }).click();
await page.getByRole('tab', { name: 'Build Orders' }).click(); await page.getByRole('tab', { name: 'Build Orders' }).click();
@ -54,7 +53,7 @@ test('Parts - Tabs', async ({ page }) => {
test('Parts - Manufacturer Parts', async ({ page }) => { test('Parts - Manufacturer Parts', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/84/suppliers`); await navigate(page, 'part/84/suppliers');
await page.getByRole('tab', { name: 'Suppliers' }).click(); await page.getByRole('tab', { name: 'Suppliers' }).click();
await page.getByText('Hammond Manufacturing').click(); await page.getByText('Hammond Manufacturing').click();
@ -67,7 +66,7 @@ test('Parts - Manufacturer Parts', async ({ page }) => {
test('Parts - Supplier Parts', async ({ page }) => { test('Parts - Supplier Parts', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/15/suppliers`); await navigate(page, 'part/15/suppliers');
await page.getByRole('tab', { name: 'Suppliers' }).click(); await page.getByRole('tab', { name: 'Suppliers' }).click();
await page.getByRole('cell', { name: 'DIG-84670-SJI' }).click(); await page.getByRole('cell', { name: 'DIG-84670-SJI' }).click();
@ -81,14 +80,14 @@ test('Parts - Locking', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Navigate to a known assembly which is *not* locked // Navigate to a known assembly which is *not* locked
await page.goto(`${baseUrl}/part/104/bom`); await navigate(page, 'part/104/bom');
await page.getByRole('tab', { name: 'Bill of Materials' }).click(); await page.getByRole('tab', { name: 'Bill of Materials' }).click();
await page.getByLabel('action-button-add-bom-item').waitFor(); await page.getByLabel('action-button-add-bom-item').waitFor();
await page.getByRole('tab', { name: 'Parameters' }).click(); await page.getByRole('tab', { name: 'Parameters' }).click();
await page.getByLabel('action-button-add-parameter').waitFor(); await page.getByLabel('action-button-add-parameter').waitFor();
// Navigate to a known assembly which *is* locked // Navigate to a known assembly which *is* locked
await page.goto(`${baseUrl}/part/100/bom`); await navigate(page, 'part/100/bom');
await page.getByRole('tab', { name: 'Bill of Materials' }).click(); await page.getByRole('tab', { name: 'Bill of Materials' }).click();
await page.getByLabel('part-lock-icon').waitFor(); await page.getByLabel('part-lock-icon').waitFor();
await page.getByText('Part is Locked', { exact: true }).waitFor(); await page.getByText('Part is Locked', { exact: true }).waitFor();
@ -107,7 +106,7 @@ test('Parts - Allocations', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Let's look at the allocations for a single stock item // Let's look at the allocations for a single stock item
await page.goto(`${baseUrl}/stock/item/324/`); await navigate(page, 'stock/item/324/');
await page.getByRole('tab', { name: 'Allocations' }).click(); await page.getByRole('tab', { name: 'Allocations' }).click();
await page.getByRole('button', { name: 'Build Order Allocations' }).waitFor(); await page.getByRole('button', { name: 'Build Order Allocations' }).waitFor();
@ -115,7 +114,7 @@ test('Parts - Allocations', async ({ page }) => {
await page.getByRole('cell', { name: 'Making tables for SO 0003' }).waitFor(); await page.getByRole('cell', { name: 'Making tables for SO 0003' }).waitFor();
// Let's look at the allocations for an entire part // Let's look at the allocations for an entire part
await page.goto(`${baseUrl}/part/74/details`); await navigate(page, 'part/74/details');
// Check that the overall allocations are displayed correctly // Check that the overall allocations are displayed correctly
await page.getByText('11 / 825').waitFor(); await page.getByText('11 / 825').waitFor();
@ -174,7 +173,7 @@ test('Parts - Pricing (Nothing, BOM)', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Part with no history // Part with no history
await page.goto(`${baseUrl}/part/82/pricing`); await navigate(page, 'part/82/pricing');
await page.getByText('Small plastic enclosure, black').waitFor(); await page.getByText('Small plastic enclosure, black').waitFor();
await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByRole('tab', { name: 'Part Pricing' }).click();
@ -186,7 +185,7 @@ test('Parts - Pricing (Nothing, BOM)', async ({ page }) => {
await page.getByRole('button', { name: 'Supplier Pricing' }).isDisabled(); await page.getByRole('button', { name: 'Supplier Pricing' }).isDisabled();
// Part with history // Part with history
await page.goto(`${baseUrl}/part/108/pricing`); await navigate(page, 'part/108/pricing');
await page.getByText('A chair - with blue paint').waitFor(); await page.getByText('A chair - with blue paint').waitFor();
await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByRole('tab', { name: 'Part Pricing' }).click();
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -224,7 +223,7 @@ test('Parts - Pricing (Supplier)', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Part // Part
await page.goto(`${baseUrl}/part/55/pricing`); await navigate(page, 'part/55/pricing');
await page.getByText('Ceramic capacitor, 100nF in').waitFor(); await page.getByText('Ceramic capacitor, 100nF in').waitFor();
await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByRole('tab', { name: 'Part Pricing' }).click();
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -250,7 +249,7 @@ test('Parts - Pricing (Variant)', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Part // Part
await page.goto(`${baseUrl}/part/106/pricing`); await navigate(page, 'part/106/pricing');
await page.getByText('A chair - available in multiple colors').waitFor(); await page.getByText('A chair - available in multiple colors').waitFor();
await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByRole('tab', { name: 'Part Pricing' }).click();
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -276,7 +275,7 @@ test('Parts - Pricing (Internal)', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Part // Part
await page.goto(`${baseUrl}/part/65/pricing`); await navigate(page, 'part/65/pricing');
await page.getByText('Socket head cap screw, M2').waitFor(); await page.getByText('Socket head cap screw, M2').waitFor();
await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByRole('tab', { name: 'Part Pricing' }).click();
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -301,7 +300,7 @@ test('Parts - Pricing (Purchase)', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Part // Part
await page.goto(`${baseUrl}/part/69/pricing`); await navigate(page, 'part/69/pricing');
await page.getByText('1.25mm Pitch, PicoBlade PCB').waitFor(); await page.getByText('1.25mm Pitch, PicoBlade PCB').waitFor();
await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByRole('tab', { name: 'Part Pricing' }).click();
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -322,7 +321,7 @@ test('Parts - Pricing (Purchase)', async ({ page }) => {
test('Parts - Attachments', async ({ page }) => { test('Parts - Attachments', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/69/attachments`); await navigate(page, 'part/69/attachments');
// Submit a new external link // Submit a new external link
await page.getByLabel('action-button-add-external-').click(); await page.getByLabel('action-button-add-external-').click();
@ -344,7 +343,7 @@ test('Parts - Attachments', async ({ page }) => {
test('Parts - Parameters', async ({ page }) => { test('Parts - Parameters', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/69/parameters`); await navigate(page, 'part/69/parameters');
// Create a new template // Create a new template
await page.getByLabel('action-button-add-parameter').click(); await page.getByLabel('action-button-add-parameter').click();
@ -371,7 +370,7 @@ test('Parts - Parameters', async ({ page }) => {
test('Parts - Notes', async ({ page }) => { test('Parts - Notes', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/69/notes`); await navigate(page, 'part/69/notes');
// Enable editing // Enable editing
await page.getByLabel('Enable Editing').waitFor(); await page.getByLabel('Enable Editing').waitFor();
@ -393,7 +392,7 @@ test('Parts - Notes', async ({ page }) => {
test('Parts - 404', async ({ page }) => { test('Parts - 404', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/99999/`); await navigate(page, 'part/99999/');
await page.getByText('Page Not Found', { exact: true }).waitFor(); await page.getByText('Page Not Found', { exact: true }).waitFor();
// Clear out any console error messages // Clear out any console error messages
@ -403,7 +402,7 @@ test('Parts - 404', async ({ page }) => {
test('Parts - Revision', async ({ page }) => { test('Parts - Revision', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/part/906/details`); await navigate(page, 'part/906/details');
await page.getByText('Revision of').waitFor(); await page.getByText('Revision of').waitFor();
await page.getByText('Select Part Revision').waitFor(); await page.getByText('Select Part Revision').waitFor();

View File

@ -1,8 +1,8 @@
import { test } from '../baseFixtures.ts'; import { test } from '../baseFixtures.ts';
import { baseUrl } from '../defaults.ts';
import { import {
clearTableFilters, clearTableFilters,
clickButtonIfVisible, clickButtonIfVisible,
navigate,
openFilterDrawer, openFilterDrawer,
setTableChoiceFilter setTableChoiceFilter
} from '../helpers.ts'; } from '../helpers.ts';
@ -39,7 +39,7 @@ test('Purchase Orders - List', async ({ page }) => {
test('Purchase Orders - Barcodes', async ({ page }) => { test('Purchase Orders - Barcodes', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/purchasing/purchase-order/13/detail`); await navigate(page, 'purchasing/purchase-order/13/detail');
await page.getByRole('button', { name: 'Issue Order' }).waitFor(); await page.getByRole('button', { name: 'Issue Order' }).waitFor();
// Display QR code // Display QR code
@ -211,7 +211,7 @@ test('Purchase Orders - Order Parts', async ({ page }) => {
await page.getByRole('banner').getByRole('button').click(); await page.getByRole('banner').getByRole('button').click();
// Order from the part detail page // Order from the part detail page
await page.goto(`${baseUrl}/part/69/`); await navigate(page, 'part/69/');
await page.waitForURL('**/part/69/**'); await page.waitForURL('**/part/69/**');
await page.getByLabel('action-menu-stock-actions').click(); await page.getByLabel('action-menu-stock-actions').click();

View File

@ -1,12 +1,15 @@
import { test } from '../baseFixtures.ts'; import { test } from '../baseFixtures.ts';
import { baseUrl } from '../defaults.ts'; import {
import { clearTableFilters, setTableChoiceFilter } from '../helpers.ts'; clearTableFilters,
navigate,
setTableChoiceFilter
} from '../helpers.ts';
import { doQuickLogin } from '../login.ts'; import { doQuickLogin } from '../login.ts';
test('Sales Orders - Tabs', async ({ page }) => { test('Sales Orders - Tabs', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/sales/index/`); await navigate(page, 'sales/index/');
await page.waitForURL('**/platform/sales/**'); await page.waitForURL('**/platform/sales/**');
await page.getByRole('tab', { name: 'Sales Orders' }).click(); await page.getByRole('tab', { name: 'Sales Orders' }).click();
@ -30,6 +33,9 @@ test('Sales Orders - Tabs', async ({ page }) => {
// Sales Order Details // Sales Order Details
await page.getByRole('tab', { name: 'Sales Orders' }).click(); await page.getByRole('tab', { name: 'Sales Orders' }).click();
await clearTableFilters(page);
await page.getByRole('cell', { name: 'SO0001' }).click(); await page.getByRole('cell', { name: 'SO0001' }).click();
await page await page
.getByLabel('Order Details') .getByLabel('Order Details')
@ -57,7 +63,7 @@ test('Sales Orders - Tabs', async ({ page }) => {
test('Sales Orders - Basic Tests', async ({ page }) => { test('Sales Orders - Basic Tests', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/home`); await navigate(page, 'home');
await page.getByRole('tab', { name: 'Sales' }).click(); await page.getByRole('tab', { name: 'Sales' }).click();
await page.getByRole('tab', { name: 'Sales Orders' }).click(); await page.getByRole('tab', { name: 'Sales Orders' }).click();
@ -100,12 +106,12 @@ test('Sales Orders - Basic Tests', async ({ page }) => {
test('Sales Orders - Shipments', async ({ page }) => { test('Sales Orders - Shipments', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/home`); await navigate(page, 'home');
await page.getByRole('tab', { name: 'Sales' }).click(); await page.getByRole('tab', { name: 'Sales' }).click();
await page.getByRole('tab', { name: 'Sales Orders' }).click(); await page.getByRole('tab', { name: 'Sales Orders' }).click();
await clearTableFilters(page);
// Click through to a particular sales order // Click through to a particular sales order
await page.getByRole('tab', { name: 'Sales Orders' }).waitFor();
await page.getByRole('cell', { name: 'SO0006' }).first().click(); await page.getByRole('cell', { name: 'SO0006' }).first().click();
await page.getByRole('tab', { name: 'Shipments' }).click(); await page.getByRole('tab', { name: 'Shipments' }).click();

View File

@ -1,5 +1,5 @@
import { test } from '../baseFixtures'; import { test } from '../baseFixtures';
import { baseUrl } from '../defaults'; import { navigate } from '../helpers';
import { doQuickLogin } from '../login'; import { doQuickLogin } from '../login';
const scan = async (page, barcode) => { const scan = async (page, barcode) => {
@ -42,7 +42,7 @@ test('Scanning - Basic', async ({ page }) => {
test('Scanning - Part', async ({ page }) => { test('Scanning - Part', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"part": 1}'); await scan(page, '{"part": 1}');
@ -53,7 +53,7 @@ test('Scanning - Part', async ({ page }) => {
test('Scanning - Stockitem', async ({ page }) => { test('Scanning - Stockitem', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"stockitem": 408}'); await scan(page, '{"stockitem": 408}');
await page.getByText('1551ABK').waitFor(); await page.getByText('1551ABK').waitFor();
@ -63,7 +63,7 @@ test('Scanning - Stockitem', async ({ page }) => {
test('Scanning - StockLocation', async ({ page }) => { test('Scanning - StockLocation', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"stocklocation": 3}'); await scan(page, '{"stocklocation": 3}');
// stocklocation: 3 // stocklocation: 3
@ -76,7 +76,7 @@ test('Scanning - StockLocation', async ({ page }) => {
test('Scanning - SupplierPart', async ({ page }) => { test('Scanning - SupplierPart', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"supplierpart": 204}'); await scan(page, '{"supplierpart": 204}');
// supplierpart: 204 // supplierpart: 204
@ -87,7 +87,7 @@ test('Scanning - SupplierPart', async ({ page }) => {
test('Scanning - PurchaseOrder', async ({ page }) => { test('Scanning - PurchaseOrder', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"purchaseorder": 12}'); await scan(page, '{"purchaseorder": 12}');
// purchaseorder: 12 // purchaseorder: 12
@ -100,7 +100,7 @@ test('Scanning - PurchaseOrder', async ({ page }) => {
test('Scanning - SalesOrder', async ({ page }) => { test('Scanning - SalesOrder', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"salesorder": 6}'); await scan(page, '{"salesorder": 6}');
// salesorder: 6 // salesorder: 6
@ -111,7 +111,7 @@ test('Scanning - SalesOrder', async ({ page }) => {
test('Scanning - Build', async ({ page }) => { test('Scanning - Build', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/scan/`); await navigate(page, 'scan/');
await scan(page, '{"build": 8}'); await scan(page, '{"build": 8}');
// build: 8 // build: 8

View File

@ -1,8 +1,8 @@
import { test } from '../baseFixtures.js'; import { test } from '../baseFixtures.js';
import { baseUrl } from '../defaults.js';
import { import {
clearTableFilters, clearTableFilters,
clickButtonIfVisible, clickButtonIfVisible,
navigate,
openFilterDrawer, openFilterDrawer,
setTableChoiceFilter setTableChoiceFilter
} from '../helpers.js'; } from '../helpers.js';
@ -11,7 +11,7 @@ import { doQuickLogin } from '../login.js';
test('Stock - Basic Tests', async ({ page }) => { test('Stock - Basic Tests', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/stock/location/index/`); await navigate(page, 'stock/location/index/');
await page.waitForURL('**/platform/stock/location/**'); await page.waitForURL('**/platform/stock/location/**');
await page.getByRole('tab', { name: 'Location Details' }).click(); await page.getByRole('tab', { name: 'Location Details' }).click();
@ -29,7 +29,7 @@ test('Stock - Basic Tests', async ({ page }) => {
await page.getByRole('tab', { name: 'Stock Items' }).click(); await page.getByRole('tab', { name: 'Stock Items' }).click();
await page.getByRole('tab', { name: 'Location Details' }).click(); await page.getByRole('tab', { name: 'Location Details' }).click();
await page.goto(`${baseUrl}/stock/item/1194/details`); await navigate(page, 'stock/item/1194/details');
await page.getByText('D.123 | Doohickey').waitFor(); await page.getByText('D.123 | Doohickey').waitFor();
await page.getByText('Batch Code: BX-123-2024-2-7').waitFor(); await page.getByText('Batch Code: BX-123-2024-2-7').waitFor();
await page.getByRole('tab', { name: 'Stock Tracking' }).click(); await page.getByRole('tab', { name: 'Stock Tracking' }).click();
@ -41,7 +41,7 @@ test('Stock - Basic Tests', async ({ page }) => {
test('Stock - Location Tree', async ({ page }) => { test('Stock - Location Tree', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/stock/location/index/`); await navigate(page, 'stock/location/index/');
await page.waitForURL('**/platform/stock/location/**'); await page.waitForURL('**/platform/stock/location/**');
await page.getByRole('tab', { name: 'Location Details' }).click(); await page.getByRole('tab', { name: 'Location Details' }).click();
@ -58,7 +58,7 @@ test('Stock - Location Tree', async ({ page }) => {
test('Stock - Filters', async ({ page }) => { test('Stock - Filters', async ({ page }) => {
await doQuickLogin(page, 'steven', 'wizardstaff'); await doQuickLogin(page, 'steven', 'wizardstaff');
await page.goto(`${baseUrl}/stock/location/index/`); await navigate(page, 'stock/location/index/');
await page.getByRole('tab', { name: 'Stock Items' }).click(); await page.getByRole('tab', { name: 'Stock Items' }).click();
await openFilterDrawer(page); await openFilterDrawer(page);
@ -169,7 +169,7 @@ test('Stock - Serial Numbers', async ({ page }) => {
test('Stock - Stock Actions', async ({ page }) => { test('Stock - Stock Actions', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/stock/item/1225/details`); await navigate(page, 'stock/item/1225/details');
// Helper function to launch a stock action // Helper function to launch a stock action
const launchStockAction = async (action: string) => { const launchStockAction = async (action: string) => {
@ -223,7 +223,7 @@ test('Stock - Stock Actions', async ({ page }) => {
await page.getByText('Incoming goods inspection').first().waitFor(); await page.getByText('Incoming goods inspection').first().waitFor();
// Find an item which has been sent to a customer // Find an item which has been sent to a customer
await page.goto(`${baseUrl}/stock/item/1014/details`); await navigate(page, 'stock/item/1014/details');
await page.getByText('Batch Code: 2022-11-12').waitFor(); await page.getByText('Batch Code: 2022-11-12').waitFor();
await page.getByText('Unavailable').waitFor(); await page.getByText('Unavailable').waitFor();
await page.getByLabel('action-menu-stock-operations').click(); await page.getByLabel('action-menu-stock-operations').click();
@ -234,7 +234,7 @@ test('Stock - Tracking', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Navigate to the "stock item" page // Navigate to the "stock item" page
await page.goto(`${baseUrl}/stock/item/176/details/`); await navigate(page, 'stock/item/176/details/');
await page.getByRole('link', { name: 'Widget Assembly # 2' }).waitFor(); await page.getByRole('link', { name: 'Widget Assembly # 2' }).waitFor();
// Navigate to the "stock tracking" tab // Navigate to the "stock tracking" tab

View File

@ -1,12 +1,11 @@
/** Unit tests for form validation, rendering, etc */ /** Unit tests for form validation, rendering, etc */
import test from 'playwright/test'; import test from 'playwright/test';
import { navigate } from './helpers';
import { baseUrl } from './defaults';
import { doQuickLogin } from './login'; import { doQuickLogin } from './login';
test('Forms - Stock Item Validation', async ({ page }) => { test('Forms - Stock Item Validation', async ({ page }) => {
await doQuickLogin(page, 'steven', 'wizardstaff'); await doQuickLogin(page, 'steven', 'wizardstaff');
await page.goto(`${baseUrl}/stock/location/index/stock-items`); await navigate(page, 'stock/location/index/stock-items');
await page.waitForURL('**/platform/stock/location/**'); await page.waitForURL('**/platform/stock/location/**');
// Create new stock item form // Create new stock item form
@ -77,7 +76,7 @@ test('Forms - Stock Item Validation', async ({ page }) => {
test('Forms - Supplier Validation', async ({ page, request }) => { test('Forms - Supplier Validation', async ({ page, request }) => {
await doQuickLogin(page, 'steven', 'wizardstaff'); await doQuickLogin(page, 'steven', 'wizardstaff');
await page.goto(`${baseUrl}/purchasing/index/suppliers`); await navigate(page, 'purchasing/index/suppliers');
await page.waitForURL('**/purchasing/index/**'); await page.waitForURL('**/purchasing/index/**');
await page.getByLabel('action-button-add-company').click(); await page.getByLabel('action-button-add-company').click();
@ -113,7 +112,7 @@ test('Forms - Supplier Validation', async ({ page, request }) => {
.waitFor(); .waitFor();
// Now, try to create another new supplier with the same name // Now, try to create another new supplier with the same name
await page.goto(`${baseUrl}/purchasing/index/suppliers`); await navigate(page, 'purchasing/index/suppliers');
await page.waitForURL('**/purchasing/index/**'); await page.waitForURL('**/purchasing/index/**');
await page.getByLabel('action-button-add-company').click(); await page.getByLabel('action-button-add-company').click();
await page.getByLabel('text-field-name').fill(supplierName); await page.getByLabel('text-field-name').fill(supplierName);

View File

@ -1,11 +1,11 @@
import { test } from './baseFixtures.js'; import { test } from './baseFixtures.js';
import { baseUrl } from './defaults.js'; import { navigate } from './helpers.js';
import { doQuickLogin } from './login.js'; import { doQuickLogin } from './login.js';
test('Company', async ({ page }) => { test('Company', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/company/1/details`); await navigate(page, 'company/1/details');
await page.getByLabel('Details').getByText('DigiKey Electronics').waitFor(); await page.getByLabel('Details').getByText('DigiKey Electronics').waitFor();
await page.getByRole('cell', { name: 'https://www.digikey.com/' }).waitFor(); await page.getByRole('cell', { name: 'https://www.digikey.com/' }).waitFor();
await page.getByRole('tab', { name: 'Supplied Parts' }).click(); await page.getByRole('tab', { name: 'Supplied Parts' }).click();
@ -44,7 +44,7 @@ test('Company', async ({ page }) => {
*/ */
test('Admin Button', async ({ page }) => { test('Admin Button', async ({ page }) => {
await doQuickLogin(page, 'admin', 'inventree'); await doQuickLogin(page, 'admin', 'inventree');
await page.goto(`${baseUrl}/company/1/details`); await navigate(page, 'company/1/details');
// Click on the admin button // Click on the admin button
await page.getByLabel(/action-button-open-in-admin/).click(); await page.getByLabel(/action-button-open-in-admin/).click();

View File

@ -1,5 +1,6 @@
import { expect, test } from './baseFixtures.js'; import { expect, test } from './baseFixtures.js';
import { baseUrl, logoutUrl, user } from './defaults.js'; import { logoutUrl, user } from './defaults.js';
import { navigate } from './helpers.js';
import { doLogin, doQuickLogin } from './login.js'; import { doLogin, doQuickLogin } from './login.js';
test('Login - Basic Test', async ({ page }) => { test('Login - Basic Test', async ({ page }) => {
@ -25,13 +26,13 @@ test('Login - Quick Test', async ({ page }) => {
await expect(page).toHaveTitle(/^InvenTree/); await expect(page).toHaveTitle(/^InvenTree/);
// Go to the dashboard // Go to the dashboard
await page.goto(baseUrl); await navigate(page, '');
await page.waitForURL('**/platform'); await page.waitForURL('**/platform');
await page.getByText('InvenTree Demo Server - ').waitFor(); await page.getByText('InvenTree Demo Server - ').waitFor();
// Logout (via URL) // Logout (via URL)
await page.goto(`${baseUrl}/logout/`); await navigate(page, 'logout');
await page.waitForURL('**/platform/login'); await page.waitForURL('**/platform/login');
await page.getByLabel('username'); await page.getByLabel('username');
}); });
@ -48,7 +49,7 @@ test('Login - Failures', async ({ page }) => {
}; };
// Navigate to the 'login' page // Navigate to the 'login' page
await page.goto(logoutUrl); await navigate(page, logoutUrl);
await expect(page).toHaveTitle(/^InvenTree.*$/); await expect(page).toHaveTitle(/^InvenTree.*$/);
await page.waitForURL('**/platform/login'); await page.waitForURL('**/platform/login');
@ -81,7 +82,7 @@ test('Login - Change Password', async ({ page }) => {
await doQuickLogin(page, 'noaccess', 'youshallnotpass'); await doQuickLogin(page, 'noaccess', 'youshallnotpass');
// Navigate to the 'change password' page // Navigate to the 'change password' page
await page.goto(`${baseUrl}/settings/user/account`); await navigate(page, 'settings/user/account');
await page.getByLabel('action-menu-user-actions').click(); await page.getByLabel('action-menu-user-actions').click();
await page.getByLabel('action-menu-user-actions-change-password').click(); await page.getByLabel('action-menu-user-actions-change-password').click();

View File

@ -1,6 +1,6 @@
import test from 'playwright/test'; import test from 'playwright/test';
import { baseUrl } from './defaults.js'; import { navigate } from './helpers.js';
import { doQuickLogin } from './login.js'; import { doQuickLogin } from './login.js';
import { setPluginState, setSettingState } from './settings.js'; import { setPluginState, setSettingState } from './settings.js';
@ -26,7 +26,7 @@ test('Plugins - Panels', async ({ page, request }) => {
await page.waitForTimeout(500); await page.waitForTimeout(500);
// Navigate to the "part" page // Navigate to the "part" page
await page.goto(`${baseUrl}/part/69/`); await navigate(page, 'part/69/');
// Ensure basic part tab is available // Ensure basic part tab is available
await page.getByRole('tab', { name: 'Part Details' }).waitFor(); await page.getByRole('tab', { name: 'Part Details' }).waitFor();
@ -75,7 +75,7 @@ test('Plugins - Custom Admin', async ({ page, request }) => {
}); });
// Navigate to the "admin" page // Navigate to the "admin" page
await page.goto(`${baseUrl}/settings/admin/plugin/`); await navigate(page, 'settings/admin/plugin/');
// Open the plugin drawer, and ensure that the custom admin elements are visible // Open the plugin drawer, and ensure that the custom admin elements are visible
await page.getByText('SampleUI').click(); await page.getByText('SampleUI').click();
@ -108,7 +108,7 @@ test('Plugins - Locate Item', async ({ page, request }) => {
await page.waitForTimeout(500); await page.waitForTimeout(500);
// Navigate to the "stock item" page // Navigate to the "stock item" page
await page.goto(`${baseUrl}/stock/item/287/`); await navigate(page, 'stock/item/287/');
// "Locate" this item // "Locate" this item
await page.getByLabel('action-button-locate-item').click(); await page.getByLabel('action-button-locate-item').click();

View File

@ -1,5 +1,5 @@
import { expect, test } from './baseFixtures.js'; import { expect, test } from './baseFixtures.js';
import { baseUrl } from './defaults.js'; import { navigate } from './helpers.js';
import { doQuickLogin } from './login.js'; import { doQuickLogin } from './login.js';
import { setPluginState } from './settings.js'; import { setPluginState } from './settings.js';
@ -11,7 +11,7 @@ import { setPluginState } from './settings.js';
test('Label Printing', async ({ page }) => { test('Label Printing', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/stock/location/index/`); await navigate(page, 'stock/location/index/');
await page.waitForURL('**/platform/stock/location/**'); await page.waitForURL('**/platform/stock/location/**');
await page.getByRole('tab', { name: 'Stock Items' }).click(); await page.getByRole('tab', { name: 'Stock Items' }).click();
@ -55,7 +55,7 @@ test('Label Printing', async ({ page }) => {
test('Report Printing', async ({ page }) => { test('Report Printing', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
await page.goto(`${baseUrl}/stock/location/index/`); await navigate(page, 'stock/location/index/');
await page.waitForURL('**/platform/stock/location/**'); await page.waitForURL('**/platform/stock/location/**');
// Navigate to a specific PurchaseOrder // Navigate to a specific PurchaseOrder

View File

@ -1,5 +1,6 @@
import { expect, test } from './baseFixtures.js'; import { expect, test } from './baseFixtures.js';
import { apiUrl, baseUrl } from './defaults.js'; import { apiUrl } from './defaults.js';
import { navigate } from './helpers.js';
import { doQuickLogin } from './login.js'; import { doQuickLogin } from './login.js';
import { setSettingState } from './settings.js'; import { setSettingState } from './settings.js';
@ -165,7 +166,7 @@ test('Settings - Admin - Unauthorized', async ({ page }) => {
// Try to access "admin" page with a non-staff user // Try to access "admin" page with a non-staff user
await doQuickLogin(page, 'allaccess', 'nolimits'); await doQuickLogin(page, 'allaccess', 'nolimits');
await page.goto(`${baseUrl}/settings/admin/`); await navigate(page, 'settings/admin/');
await page.waitForURL('**/settings/admin/**'); await page.waitForURL('**/settings/admin/**');
// Should get a permission denied message // Should get a permission denied message
@ -175,14 +176,14 @@ test('Settings - Admin - Unauthorized', async ({ page }) => {
.waitFor(); .waitFor();
// Try to access user settings page (should be accessible) // Try to access user settings page (should be accessible)
await page.goto(`${baseUrl}/settings/user/`); await navigate(page, 'settings/user/');
await page.waitForURL('**/settings/user/**'); await page.waitForURL('**/settings/user/**');
await page.getByRole('tab', { name: 'Display Options' }).click(); await page.getByRole('tab', { name: 'Display Options' }).click();
await page.getByRole('tab', { name: 'Account' }).click(); await page.getByRole('tab', { name: 'Account' }).click();
// Try to access global settings page // Try to access global settings page
await page.goto(`${baseUrl}/settings/system/`); await navigate(page, 'settings/system/');
await page.waitForURL('**/settings/system/**'); await page.waitForURL('**/settings/system/**');
await page.getByText('Permission Denied').waitFor(); await page.getByText('Permission Denied').waitFor();

View File

@ -1,13 +1,16 @@
import { test } from './baseFixtures.js'; import { test } from './baseFixtures.js';
import { baseUrl } from './defaults.js'; import {
import { clearTableFilters, setTableChoiceFilter } from './helpers.js'; clearTableFilters,
navigate,
setTableChoiceFilter
} from './helpers.js';
import { doQuickLogin } from './login.js'; import { doQuickLogin } from './login.js';
test('Tables - Filters', async ({ page }) => { test('Tables - Filters', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Head to the "build order list" page // Head to the "build order list" page
await page.goto(`${baseUrl}/manufacturing/index/`); await navigate(page, 'manufacturing/index/');
await clearTableFilters(page); await clearTableFilters(page);
@ -18,14 +21,14 @@ test('Tables - Filters', async ({ page }) => {
await clearTableFilters(page); await clearTableFilters(page);
// Head to the "part list" page // Head to the "part list" page
await page.goto(`${baseUrl}/part/category/index/parts/`); await navigate(page, 'part/category/index/parts/');
await setTableChoiceFilter(page, 'Assembly', 'Yes'); await setTableChoiceFilter(page, 'Assembly', 'Yes');
await clearTableFilters(page); await clearTableFilters(page);
// Head to the "purchase order list" page // Head to the "purchase order list" page
await page.goto(`${baseUrl}/purchasing/index/purchaseorders/`); await navigate(page, 'purchasing/index/purchaseorders/');
await clearTableFilters(page); await clearTableFilters(page);
@ -42,7 +45,7 @@ test('Tables - Columns', async ({ page }) => {
await doQuickLogin(page); await doQuickLogin(page);
// Go to the "stock list" page // Go to the "stock list" page
await page.goto(`${baseUrl}/stock/location/index/stock-items`); await navigate(page, 'stock/location/index/stock-items');
// Open column selector // Open column selector
await page.getByLabel('table-select-columns').click(); await page.getByLabel('table-select-columns').click();
@ -52,7 +55,7 @@ test('Tables - Columns', async ({ page }) => {
await page.getByRole('menuitem', { name: 'Stocktake' }).click(); await page.getByRole('menuitem', { name: 'Stocktake' }).click();
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
await page.goto(`${baseUrl}/sales/index/salesorders`); await navigate(page, '/sales/index/salesorders');
// Open column selector // Open column selector
await page.getByLabel('table-select-columns').click(); await page.getByLabel('table-select-columns').click();

View File

@ -1,5 +1,5 @@
import { test } from '../baseFixtures'; import { test } from '../baseFixtures';
import { baseUrl } from '../defaults'; import { navigate } from '../helpers';
import { doQuickLogin } from '../login'; import { doQuickLogin } from '../login';
test('PUI - Admin - Parameter', async ({ page }) => { test('PUI - Admin - Parameter', async ({ page }) => {
@ -75,7 +75,7 @@ test('PUI - Admin - Parameter', async ({ page }) => {
await page.getByRole('cell', { name: 'my custom parameter' }).click(); await page.getByRole('cell', { name: 'my custom parameter' }).click();
// Fill parameter // Fill parameter
await page.goto(`${baseUrl}/part/104/parameters/`); await navigate(page, 'part/104/parameters/');
await page.getByLabel('Parameters').getByText('Parameters').waitFor(); await page.getByLabel('Parameters').getByText('Parameters').waitFor();
await page.waitForLoadState('networkidle'); await page.waitForLoadState('networkidle');
await page.getByLabel('action-button-add-parameter').waitFor(); await page.getByLabel('action-button-add-parameter').waitFor();