2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Use postgres for playwright testing (#9104)

* Use postgres for playwright testing

- Should reduce issues with parallel tests

* Fix deps

* Harden playwright tests
This commit is contained in:
Oliver 2025-02-19 20:33:54 +11:00 committed by GitHub
parent 7e7f745c89
commit e492774808
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 10 deletions

View File

@ -553,9 +553,28 @@ jobs:
timeout-minutes: 60 timeout-minutes: 60
needs: ["pre-commit", "paths-filter"] needs: ["pre-commit", "paths-filter"]
if: needs.paths-filter.outputs.frontend == 'true' || needs.paths-filter.outputs.force == 'true' if: needs.paths-filter.outputs.frontend == 'true' || needs.paths-filter.outputs.force == 'true'
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: inventree
POSTGRES_USER: inventree_user
POSTGRES_PASSWORD: inventree_password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U testuser"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env: env:
INVENTREE_DB_ENGINE: sqlite3 INVENTREE_DB_ENGINE: postgresql
INVENTREE_DB_NAME: /home/runner/work/InvenTree/db.sqlite3 INVENTREE_DB_NAME: inventree
INVENTREE_DB_HOST: "127.0.0.1"
INVENTREE_DB_PORT: 5432
INVENTREE_DB_USER: inventree_user
INVENTREE_DB_PASSWORD: inventree_password
INVENTREE_DEBUG: true INVENTREE_DEBUG: true
INVENTREE_PLUGINS_ENABLED: false INVENTREE_PLUGINS_ENABLED: false
VITE_COVERAGE: true VITE_COVERAGE: true
@ -570,6 +589,8 @@ jobs:
npm: true npm: true
install: true install: true
update: true update: true
apt-dependency: postgresql-client libpq-dev
pip-dependency: psycopg2
- name: Set up test data - name: Set up test data
run: invoke dev.setup-test -iv run: invoke dev.setup-test -iv
- name: Rebuild thumbnails - name: Rebuild thumbnails

View File

@ -28,7 +28,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */ /* Run your local dev server before starting the tests */
webServer: [ webServer: [
{ {
command: 'yarn run dev', command: 'yarn run dev --host',
url: 'http://localhost:5173', url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,
stdout: 'pipe', stdout: 'pipe',

View File

@ -1,6 +1,6 @@
import { expect, test } from './baseFixtures.js'; import { expect, test } from './baseFixtures.js';
import { apiUrl } from './defaults.js'; import { apiUrl } from './defaults.js';
import { navigate } from './helpers.js'; import { getRowFromCell, navigate } from './helpers.js';
import { doQuickLogin } from './login.js'; import { doQuickLogin } from './login.js';
import { setSettingState } from './settings.js'; import { setSettingState } from './settings.js';
@ -91,8 +91,12 @@ test('Settings - Admin', async ({ page }) => {
// Adjust some "location type" items // Adjust some "location type" items
await page.getByRole('tab', { name: 'Location Types' }).click(); await page.getByRole('tab', { name: 'Location Types' }).click();
// Edit first item // Edit first item ('Room')
await page.getByLabel('row-action-menu-0').click(); const roomCell = await page.getByRole('cell', { name: 'Room', exact: true });
const roomRow = await getRowFromCell(roomCell);
await roomRow.getByLabel(/row-action-menu-/i).click();
await page.getByRole('menuitem', { name: 'Edit' }).click(); await page.getByRole('menuitem', { name: 'Edit' }).click();
await expect(page.getByLabel('text-field-name')).toHaveValue('Room'); await expect(page.getByLabel('text-field-name')).toHaveValue('Room');
@ -100,14 +104,22 @@ test('Settings - Admin', async ({ page }) => {
const oldDescription = await page const oldDescription = await page
.getByLabel('text-field-description') .getByLabel('text-field-description')
.inputValue(); .inputValue();
const newDescription = `${oldDescription} (edited)`; const newDescription = `${oldDescription} (edited)`;
await page.getByLabel('text-field-description').fill(newDescription); await page.getByLabel('text-field-description').fill(newDescription);
await page.waitForTimeout(500); await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Submit' }).click(); await page.getByRole('button', { name: 'Submit' }).click();
// Edit second item // Edit second item - 'Box (Large)'
await page.getByLabel('row-action-menu-1').click(); const boxCell = await page.getByRole('cell', {
name: 'Box (Large)',
exact: true
});
const boxRow = await getRowFromCell(boxCell);
await boxRow.getByLabel(/row-action-menu-/i).click();
await page.getByRole('menuitem', { name: 'Edit' }).click(); await page.getByRole('menuitem', { name: 'Edit' }).click();
await expect(page.getByLabel('text-field-name')).toHaveValue('Box (Large)'); await expect(page.getByLabel('text-field-name')).toHaveValue('Box (Large)');
await expect(page.getByLabel('text-field-description')).toHaveValue( await expect(page.getByLabel('text-field-description')).toHaveValue(
@ -116,11 +128,13 @@ test('Settings - Admin', async ({ page }) => {
await page.getByRole('button', { name: 'Cancel' }).click(); await page.getByRole('button', { name: 'Cancel' }).click();
// Edit first item again (revert values) // Edit first item again (revert values)
await page.getByLabel('row-action-menu-0').click(); await roomRow.getByLabel(/row-action-menu-/i).click();
await page.getByRole('menuitem', { name: 'Edit' }).click(); await page.getByRole('menuitem', { name: 'Edit' }).click();
await page.getByLabel('text-field-name').fill('Room'); await page.getByLabel('text-field-name').fill('Room');
await page.waitForTimeout(500); await page.waitForTimeout(500);
await page.getByLabel('text-field-description').fill(oldDescription); await page
.getByLabel('text-field-description')
.fill(newDescription.replaceAll(' (edited)', ''));
await page.waitForTimeout(500); await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Submit' }).click(); await page.getByRole('button', { name: 'Submit' }).click();
}); });