2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-25 16:17:58 +00:00
Files
InvenTree/src/frontend/tests/pages/pui_company.spec.ts
Oliver 3910cc5a50 Supplier Part Updates (#11303)
* Add "primary" field to SupplierPart model

* Remove "default_supplier" field from the Part model

* Ensure only one SupplierPart can be "primary" for a given Part

* Update references to "default_supplier"

* Add 'primary' field to the SupplierPart API serializer

* update SupplierPart table

* Use bulk-update operations

* Bug fix for data migration

* Allow ordering by 'primary' field

* Tweak import message

* Edit 'primary' field in UI

* Fix checks in save() methods

* Better table updates

* Update CHANGELOG

* Bump API version

* Fix unit test

* Add unit test for API

* Playwright tests
2026-02-20 18:25:26 +11:00

89 lines
2.9 KiB
TypeScript

import { test } from '../baseFixtures.js';
import {
clearTableFilters,
clickOnParamFilter,
loadTab,
navigate,
setTableChoiceFilter,
showParametricView
} from '../helpers.js';
import { doCachedLogin } from '../login.js';
test('Company', async ({ browser }) => {
const page = await doCachedLogin(browser);
await navigate(page, 'company/1/details');
await page.getByLabel('Details').getByText('DigiKey Electronics').waitFor();
await page.getByRole('cell', { name: 'https://www.digikey.com/' }).waitFor();
await loadTab(page, 'Supplied Parts');
await page
.getByRole('cell', { name: 'RR05P100KDTR-ND', exact: true })
.waitFor();
await loadTab(page, 'Purchase Orders');
await page.getByRole('cell', { name: 'Molex connectors' }).first().waitFor();
await loadTab(page, 'Stock Items');
await page
.getByRole('cell', { name: 'Blue plastic enclosure' })
.first()
.waitFor();
await loadTab(page, 'Contacts');
await page.getByRole('cell', { name: 'jimmy.mcleod@digikey.com' }).waitFor();
await loadTab(page, 'Addresses');
await page.getByRole('cell', { name: 'Carla Tunnel' }).waitFor();
await loadTab(page, 'Attachments');
await loadTab(page, 'Notes');
// Let's edit the company details
await page.getByLabel('action-menu-company-actions').click();
await page.getByLabel('action-menu-company-actions-edit').click();
await page.getByLabel('text-field-name', { exact: true }).fill('');
await page
.getByLabel('text-field-website', { exact: true })
.fill('invalid-website');
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('This field may not be blank.').waitFor();
await page.getByText('Enter a valid URL.').waitFor();
await page.getByRole('button', { name: 'Cancel' }).click();
});
test('Company - Parameters', async ({ browser }) => {
const page = await doCachedLogin(browser, {
username: 'steven',
password: 'wizardstaff',
url: 'purchasing/index/suppliers'
});
// Show parametric view
await showParametricView(page);
// Filter by "payment terms" parameter value
await clickOnParamFilter(page, 'Payment Terms');
await page.getByRole('option', { name: 'NET-30' }).click();
await page.getByRole('cell', { name: 'Arrow Electronics' }).waitFor();
await page.getByRole('cell', { name: 'PCB assembly house' }).waitFor();
});
test('Company - Supplier Parts', async ({ browser }) => {
const page = await doCachedLogin(browser, {
username: 'steven',
password: 'wizardstaff',
url: 'purchasing/index/suppliers'
});
await loadTab(page, 'Supplier Parts');
await clearTableFilters(page);
await page.getByText('- 25 / 777').waitFor();
await setTableChoiceFilter(page, 'Primary', 'Yes');
await page.getByText('- 25 / 318').waitFor();
await clearTableFilters(page);
await setTableChoiceFilter(page, 'Primary', 'No');
await page.getByText('- 25 / 459').waitFor();
});