import { Page, expect } from '@playwright/test'; import { EXPUi } from '../exp/ui'; import { NAV, TASK, FIELD, BUTTON } from './labels'; /** Page actions for the MOCK SCM pack (same locator policy as the other packs). Every label comes from ./labels.ts. */ export class SCMUi extends EXPUi { constructor(page: Page) { super(page); } async scmNav(key: keyof typeof NAV) { await this.go(NAV[key]); } tasksNav() { return this.page.getByRole('navigation', { name: 'Tasks' }); } /** Manage Item Quantities -> Organization + Item -> Search. */ async itemQuantities(item: string, org?: string) { await this.scmNav('inventory_management'); await this.task(TASK.manageItemQuantities); if (org) await this.page.getByRole('combobox', { name: FIELD.organization, exact: true }).selectOption(org); await this.page.getByRole('textbox', { name: FIELD.item, exact: true }).fill(item); await this.btn(BUTTON.search).click(); } async searchBy(task: string, field: string, value: string) { await this.task(task); await this.page.getByRole('textbox', { name: field, exact: true }).fill(value); await this.btn(BUTTON.search).click(); } async expectHeading(name: string) { await expect(this.page.getByRole('heading', { level: 1, name, exact: true })).toBeVisible(); } }