This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
hlk_autotest/tests/pages/inventory/inventoryTransferManagementPage.ts
2024-12-22 21:12:43 +08:00

45 lines
1.4 KiB
TypeScript

import { Page } from 'playwright';
import { waitSpecifyApiLoad } from '@/utils/utils';
export class TransferManagementPage {
page: Page;
subPages: { name: string; url?: string[] }[];
/**
* 库存-调货管理页面
* @param {import('@playwright/test').Page} page
*/
constructor(page: Page) {
this.page = page;
this.subPages = [
{ name: '门店要货', url: ['/stock'] },
{ name: '要货单', url: ['/transfer_stock_bill'] },
{ name: '调货管理', url: ['/transfer_stock_bill'] },
];
}
gotoSubPage = async (subPageName: string) => {
if (!this.subPages.some(item => item.name === subPageName)) {
throw new Error(`暂不支持${subPageName}页面`);
}
const $dropDown = this.page
.locator('.top_tab .tab_item', {
hasText: '调货管理',
})
.locator('.ant-dropdown-link');
await $dropDown.click();
const subPage = this.subPages.find(item => item.name === subPageName);
if (subPage?.url) {
await Promise.all([
this.page.getByRole('menuitem', { name: subPageName }).click(),
waitSpecifyApiLoad(subPage.url),
]);
} else {
await this.page.getByRole('menuitem', { name: subPageName }).click();
}
};
}