test: verify optional order amount in purchase detail (#306)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
const purchaseTaskRoute = [{ path: '/collection-purchase', component: 'Layout', menuName: 'GoAutoCollectionPurchase', title: '采集采购', visible: '0', children: [{ path: '/purchase-tasks/index', component: '/goauto/purchase-tasks/index', menuName: 'GoAutoPurchaseTasks', title: '采购管理', visible: '0' }] }];
|
||||||
|
|
||||||
const task = {
|
const task = {
|
||||||
id: 11,
|
id: 11,
|
||||||
executionMode: 'live',
|
executionMode: 'live',
|
||||||
@@ -35,8 +37,8 @@ const task = {
|
|||||||
createdAt: '2026-08-20T08:00:00Z',
|
createdAt: '2026-08-20T08:00:00Z',
|
||||||
};
|
};
|
||||||
|
|
||||||
async function mockAdmin(page: any, status = 'order_created') {
|
async function mockAdmin(page: any, status = 'order_created', pddOrderAmountCent: number | null = 2298) {
|
||||||
let current = { ...task, status };
|
let current = { ...task, status, pddOrderAmountCent };
|
||||||
let paymentPayload: any;
|
let paymentPayload: any;
|
||||||
let listQuery: URLSearchParams | undefined;
|
let listQuery: URLSearchParams | undefined;
|
||||||
await page.context().addCookies([{ name: 'Admin-Token', value: 'prototype-test-token', domain: 'localhost', path: '/' }]);
|
await page.context().addCookies([{ name: 'Admin-Token', value: 'prototype-test-token', domain: 'localhost', path: '/' }]);
|
||||||
@@ -44,6 +46,7 @@ async function mockAdmin(page: any, status = 'order_created') {
|
|||||||
const url = new URL(route.request().url());
|
const url = new URL(route.request().url());
|
||||||
if (url.pathname.startsWith('/src/api/')) return route.continue();
|
if (url.pathname.startsWith('/src/api/')) return route.continue();
|
||||||
if (url.pathname.endsWith('/api/v1/getinfo')) return route.fulfill({ json: { code: 200, data: { roles: ['admin'], name: '管理员', avatar: '', introduction: '', permissions: [] } } });
|
if (url.pathname.endsWith('/api/v1/getinfo')) return route.fulfill({ json: { code: 200, data: { roles: ['admin'], name: '管理员', avatar: '', introduction: '', permissions: [] } } });
|
||||||
|
if (url.pathname.endsWith('/api/v1/menurole')) return route.fulfill({ json: { code: 200, data: purchaseTaskRoute } });
|
||||||
if (url.pathname.endsWith('/api/admin/v1/purchase-tasks/11/payment-review')) {
|
if (url.pathname.endsWith('/api/admin/v1/purchase-tasks/11/payment-review')) {
|
||||||
paymentPayload = route.request().postDataJSON();
|
paymentPayload = route.request().postDataJSON();
|
||||||
current = { ...current, paymentReviewStatus: paymentPayload.status, paymentReviewedAt: '2026-08-20T09:00:00Z' };
|
current = { ...current, paymentReviewStatus: paymentPayload.status, paymentReviewedAt: '2026-08-20T09:00:00Z' };
|
||||||
@@ -63,7 +66,7 @@ async function mockAdmin(page: any, status = 'order_created') {
|
|||||||
|
|
||||||
test('采购管理只管理已有任务,并可复核支付状态', async ({ page }) => {
|
test('采购管理只管理已有任务,并可复核支付状态', async ({ page }) => {
|
||||||
const state = await mockAdmin(page);
|
const state = await mockAdmin(page);
|
||||||
await page.goto('http://localhost:9527/#/purchase-tasks/index');
|
await page.goto('/#/purchase-tasks/index');
|
||||||
|
|
||||||
await expect(page.locator('.page-heading')).toHaveCount(0);
|
await expect(page.locator('.page-heading')).toHaveCount(0);
|
||||||
await expect(page.getByLabel('模式')).toHaveCount(0);
|
await expect(page.getByLabel('模式')).toHaveCount(0);
|
||||||
@@ -88,9 +91,39 @@ test('采购管理只管理已有任务,并可复核支付状态', async ({ pa
|
|||||||
await expect(page.getByText('已支付', { exact: true }).first()).toBeVisible();
|
await expect(page.getByText('已支付', { exact: true }).first()).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('采购详情显示已获取的实付价格', async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1920, height: 1080 });
|
||||||
|
await mockAdmin(page, 'order_created', 2298);
|
||||||
|
await page.goto('/#/purchase-tasks/index');
|
||||||
|
await page.getByRole('button', { name: '详情' }).click();
|
||||||
|
const orderCard = page.locator('.state-card').filter({ hasText: '实付价格:CNY 22.98' });
|
||||||
|
await orderCard.evaluate(element => element.scrollIntoView({ block: 'center' }));
|
||||||
|
await expect(orderCard).toBeInViewport();
|
||||||
|
const amountText = page.getByText('实付价格:CNY 22.98');
|
||||||
|
await expect(amountText).toBeVisible();
|
||||||
|
await expect(amountText).toBeInViewport();
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
await page.screenshot({ path: 'test-results/issue-306-paid-amount.png', fullPage: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('采购详情明确显示尚未获取实付价格', async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1920, height: 1080 });
|
||||||
|
await mockAdmin(page, 'order_created', null);
|
||||||
|
await page.goto('/#/purchase-tasks/index');
|
||||||
|
await page.getByRole('button', { name: '详情' }).click();
|
||||||
|
const orderCard = page.locator('.state-card').filter({ hasText: '实付价格:尚未获取' });
|
||||||
|
await orderCard.evaluate(element => element.scrollIntoView({ block: 'center' }));
|
||||||
|
await expect(orderCard).toBeInViewport();
|
||||||
|
const amountText = page.getByText('实付价格:尚未获取');
|
||||||
|
await expect(amountText).toBeVisible();
|
||||||
|
await expect(amountText).toBeInViewport();
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
await page.screenshot({ path: 'test-results/issue-306-paid-amount-missing.png', fullPage: true });
|
||||||
|
});
|
||||||
|
|
||||||
test('订单结果未知时明确禁止重复采购并可人工解除', async ({ page }) => {
|
test('订单结果未知时明确禁止重复采购并可人工解除', async ({ page }) => {
|
||||||
await mockAdmin(page, 'order_result_unknown');
|
await mockAdmin(page, 'order_result_unknown');
|
||||||
await page.goto('http://localhost:9527/#/purchase-tasks/index');
|
await page.goto('/#/purchase-tasks/index');
|
||||||
await page.getByRole('button', { name: '详情' }).click();
|
await page.getByRole('button', { name: '详情' }).click();
|
||||||
|
|
||||||
await expect(page.getByText('订单结果未知,禁止重复采购')).toBeVisible();
|
await expect(page.getByText('订单结果未知,禁止重复采购')).toBeVisible();
|
||||||
|
|||||||
Reference in New Issue
Block a user