修正 OALAUNCH1 登录与业务流回归(05-28-oalaunch1-parallel-closeout)

这个提交包含在:
2026-05-28 16:23:56 +08:00
父节点 c8b41a4056
当前提交 c30e2b1348
共修改 9 个文件,包含 162 行新增和 53 行删除
+1 -1
查看文件
@@ -33,7 +33,7 @@ export function ForgotPasswordPage() {
queryFn: () => fetchAuthCapabilities(),
staleTime: 60_000,
});
const emailDeliveryReady = authCapabilitiesQuery.data?.emailDelivery.ready === true;
const emailDeliveryReady = authCapabilitiesQuery.data?.emailDelivery?.ready === true;
const emailDeliveryChecking = authCapabilitiesQuery.isLoading;
const emailDeliveryUnavailable = authCapabilitiesQuery.isSuccess && !emailDeliveryReady;
const emailDeliveryUnknown = authCapabilitiesQuery.isError;
+1 -1
查看文件
@@ -76,7 +76,7 @@ export function LoginPage() {
queryFn: () => fetchAuthCapabilities(),
staleTime: 60_000,
});
const emailDeliveryReady = authCapabilitiesQuery.data?.emailDelivery.ready === true;
const emailDeliveryReady = authCapabilitiesQuery.data?.emailDelivery?.ready === true;
const emailDeliveryChecking = authCapabilitiesQuery.isLoading;
const emailDeliveryUnavailable = authCapabilitiesQuery.isSuccess && !emailDeliveryReady;
const emailDeliveryUnknown = authCapabilitiesQuery.isError;
+10 -3
查看文件
@@ -368,7 +368,7 @@ export function PaymentBatchesPage() {
</div>
<div className="finance-workspace-grid">
<div className="finance-command-panel space-y-4">
<div className="finance-command-panel space-y-4" data-testid="payment-batch-create-panel">
<h3 className="text-base font-semibold text-zinc-900">新建批次</h3>
{!canManageBatch ? (
<div className="rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-2 text-sm text-zinc-600">
@@ -379,6 +379,7 @@ export function PaymentBatchesPage() {
<Label>实体类型</Label>
<select
className="select-std"
data-testid="payment-batch-create-entity-type"
value={entityType}
disabled={!canManageBatch}
onChange={(event) => setEntityType(event.target.value as PaymentBatchEntityType)}
@@ -390,6 +391,7 @@ export function PaymentBatchesPage() {
<div className="space-y-2">
<Label>批次名称</Label>
<Input
data-testid="payment-batch-create-name"
value={name}
disabled={!canManageBatch}
onChange={(event) => setName(event.target.value)}
@@ -400,6 +402,7 @@ export function PaymentBatchesPage() {
<Label>待付款单据 ID</Label>
<textarea
className="min-h-28 w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm disabled:bg-zinc-50"
data-testid="payment-batch-create-entity-ids"
value={entityIds}
disabled={!canManageBatch}
onChange={(event) => setEntityIds(event.target.value)}
@@ -410,6 +413,7 @@ export function PaymentBatchesPage() {
<div className="space-y-2">
<Label>默认付款日期</Label>
<DateTextInput
data-testid="payment-batch-create-payment-date"
value={defaultPaymentDate}
disabled={!canManageBatch}
onChange={(event) => setDefaultPaymentDate(event.target.value)}
@@ -419,6 +423,7 @@ export function PaymentBatchesPage() {
<Label>默认渠道</Label>
<select
className="select-std"
data-testid="payment-batch-create-payment-channel"
value={defaultPaymentChannel}
disabled={!canManageBatch}
onChange={(event) => setDefaultPaymentChannel((event.target.value as PaymentChannel | "") || "") }
@@ -431,6 +436,7 @@ export function PaymentBatchesPage() {
<div className="space-y-2">
<Label>凭证前缀</Label>
<Input
data-testid="payment-batch-create-voucher-prefix"
value={voucherPrefix}
disabled={!canManageBatch}
onChange={(event) => setVoucherPrefix(event.target.value)}
@@ -475,7 +481,7 @@ export function PaymentBatchesPage() {
{selectedBatch ? (
<div className="space-y-5">
<div className="finance-command-panel space-y-3">
<div className="finance-command-panel space-y-3" data-testid="payment-batch-detail-panel">
<div className="flex flex-wrap items-center justify-between gap-3">
<div>
<div className="text-xs text-zinc-500">{selectedBatch.batchNo}</div>
@@ -546,7 +552,7 @@ export function PaymentBatchesPage() {
</div>
</div>
<div className="finance-command-panel space-y-4">
<div className="finance-command-panel space-y-4" data-testid="payment-batch-receipt-panel">
<div className="flex flex-wrap items-start justify-between gap-3">
<div>
<h3 className="text-base font-semibold text-zinc-900">银行回单附件</h3>
@@ -557,6 +563,7 @@ export function PaymentBatchesPage() {
<input
ref={receiptInputRef}
type="file"
data-testid="payment-batch-receipt-file-input"
className="hidden"
accept=".pdf,image/jpeg,image/png,image/webp"
multiple
@@ -1,8 +1,50 @@
import { devices, expect, test } from "@playwright/test";
import { createAuthenticatedApiClient, MANAGER, type E2EUser } from "./helpers/auth";
import { createSubmittedTravelRequestViaApi } from "./helpers/travel";
import { apiGetData, apiPostData, createAuthenticatedApiClient, EMPLOYEE, MANAGER, type E2EUser } from "./helpers/auth";
import { approveWorkflowTaskViaApi, waitForWorkflowTask } from "./helpers/workflow";
type LeaveTypeListResponse = {
items: Array<{ id: string; requiresAttachment: boolean }>;
};
type WorkflowSubmitResponse = {
workflowInstanceId: string;
};
function formatDate(offsetDays: number) {
const value = new Date();
value.setUTCDate(value.getUTCDate() + offsetDays);
return value.toISOString().slice(0, 10);
}
async function createSubmittedLeaveViaApi(input: { reasonPrefix: string }) {
const client = await createAuthenticatedApiClient(EMPLOYEE);
const leaveTypes = await apiGetData<LeaveTypeListResponse>(client.api, "/api/leave-types?enabled=true");
const leaveType = leaveTypes.items.find((item) => !item.requiresAttachment) ?? leaveTypes.items[0];
if (!leaveType) {
throw new Error("缺少可用于移动审批离线测试的请假类型");
}
const offset = 3600 + (Date.now() % 1200);
const startDate = formatDate(offset);
const created = await apiPostData<{ id: string }>(client.api, "/api/leave-requests", {
leaveTypeId: leaveType.id,
startDate,
endDate: startDate,
startSession: "am",
endSession: "pm",
reason: `${input.reasonPrefix}-${Date.now()}`,
});
await apiPostData<WorkflowSubmitResponse>(client.api, `/api/leave-requests/${created.id}/submit`, {});
return {
client,
leaveRequest: {
requestId: created.id,
startDate,
},
};
}
async function loginMobile(page: import("@playwright/test").Page, user: E2EUser) {
await page.goto("/login");
await page.getByTestId("login-identifier").fill(user.identifier);
@@ -62,23 +104,22 @@ test.use({
});
test("E2E 移动审批:deep link 分流 + 离线草稿重放", async ({ page }) => {
const created = await createSubmittedTravelRequestViaApi({
purposePrefix: "Playwright移动审批通过",
amount: "999.00",
const created = await createSubmittedLeaveViaApi({
reasonPrefix: "Playwright移动审批通过",
});
const managerApi = await createAuthenticatedApiClient(MANAGER);
try {
const task = await waitForWorkflowTask(managerApi.api, {
entityId: created.travelRequest.requestId,
entityType: "travel_request",
entityId: created.leaveRequest.requestId,
entityType: "leave",
});
await loginMobile(page, MANAGER);
await page.goto(`/workflow/tasks/${task.id}`);
await expectMobileApprovalDetailUrl(page, task.id);
await expect(page.getByTestId("mobile-approvals-detail")).toBeVisible({ timeout: 30_000 });
await expect(page.getByTestId("mobile-approvals-detail")).toContainText(created.travelRequest.requestNo);
await expect(page.getByTestId("mobile-approvals-detail")).toContainText("请假");
await waitForWorkflowTaskCache(page, task.id);
await page.context().setOffline(true);
@@ -98,23 +139,22 @@ test("E2E 移动审批:deep link 分流 + 离线草稿重放", async ({ page }
});
test("E2E 移动审批:离线草稿冲突态可见", async ({ page }) => {
const created = await createSubmittedTravelRequestViaApi({
purposePrefix: "Playwright移动审批冲突",
amount: "1099.00",
const created = await createSubmittedLeaveViaApi({
reasonPrefix: "Playwright移动审批冲突",
});
const managerApi = await createAuthenticatedApiClient(MANAGER);
try {
const task = await waitForWorkflowTask(managerApi.api, {
entityId: created.travelRequest.requestId,
entityType: "travel_request",
entityId: created.leaveRequest.requestId,
entityType: "leave",
});
await loginMobile(page, MANAGER);
await page.goto(`/workflow/tasks/${task.id}`);
await expectMobileApprovalDetailUrl(page, task.id);
await expect(page.getByTestId("mobile-approvals-detail")).toBeVisible({ timeout: 30_000 });
await expect(page.getByTestId("mobile-approvals-detail")).toContainText(created.travelRequest.requestNo);
await expect(page.getByTestId("mobile-approvals-detail")).toContainText("请假");
await waitForWorkflowTaskCache(page, task.id);
await page.context().setOffline(true);
@@ -523,7 +523,7 @@ test.describe("R3 权限直连审计", () => {
await expectApiStatus({ role: "employee", api: employee.api, path: "/api/notifications/deliveries", statuses: [403], note: "员工不得查看通知投递审计" });
await expectApiMutationStatus({ role: "employee", api: employee.api, path: "/api/exports/ap-operations", method: "post", data: { format: "csv" }, statuses: [403, 409], note: "员工不得导出 AP 运营数据;409 表示功能门禁关闭且未泄露数据" });
await expectApiStatus({ role: "employee", api: employee.api, path: "/api/contracts-registry", statuses: [200, 409], note: "员工合同台账只能走范围过滤或功能门禁" });
await expectApiStatus({ role: "employee", api: employee.api, path: "/api/travel-requests?mine=0&pageSize=50", statuses: [200], note: "员工差旅列表强制本人范围" });
await expectApiStatus({ role: "employee", api: employee.api, path: "/api/travel-requests?mine=0&pageSize=50", statuses: [403], note: "差旅冻结期员工不得直连差旅列表" });
const employeeInvoices = await expectApiStatus({
role: "employee",
@@ -535,22 +535,6 @@ test.describe("R3 权限直连审计", () => {
expect((employeeInvoices.body?.data as JsonObject)?.ownerScope).toBe("own");
expectArray((employeeInvoices.body?.data as JsonObject)?.items, "employee invoice items");
const employeeTravel = await expectApiStatus({
role: "employee",
api: employee.api,
path: "/api/travel-requests?mine=0&pageSize=50",
statuses: [200],
note: "员工差旅 mine=0 被服务端收敛为 mine=true",
});
const travelData = employeeTravel.body?.data as JsonObject;
expect(travelData.mine).toBe(true);
for (const item of expectArray(travelData.items, "employee travel items")) {
expect(
item.applicantEmployeeId === employee.me.id || item.submitterId === employee.me.id,
`travel request ${String(item.id)} must belong to employee scope`,
).toBe(true);
}
await expectApiStatus({ role: "manager", api: manager.api, path: "/api/ap-operations", statuses: [403, 409], note: "主管不得直连 AP" });
await expectApiStatus({ role: "manager", api: manager.api, path: "/api/ap-operations/reimbursement-ledger", statuses: [403, 409], note: "主管不得直连财务台账" });
await expectApiStatus({ role: "manager", api: manager.api, path: "/api/payment-batches", statuses: [403, 409], note: "主管不得直连付款批次" });
@@ -364,7 +364,7 @@ test.describe("R102 reimbursement main flow", () => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/mobile/reimbursements");
await expect(page.getByRole("heading", { name: "报销" })).toBeVisible();
await expect(page.getByRole("heading", { name: "移动报销", exact: true })).toBeVisible();
await expect(page.getByTestId("mobile-reimbursement-card")).toBeVisible();
await expect(page.getByText(formNumber)).toBeVisible();
await expect(page.getByText(reimbursementId)).toHaveCount(0);
@@ -134,6 +134,15 @@ async function mockR89Apis(page: Page) {
return;
}
if (path === "/api/auth/capabilities") {
await fulfillJson(route, {
emailDelivery: { ready: true, statusReasons: [] },
emailLoginCode: { enabled: true },
passwordReset: { enabled: true },
});
return;
}
if (path === "/api/auth/sso/providers") {
await fulfillJson(route, []);
return;
@@ -136,17 +136,17 @@ test("E2E 报销支付批次主链路:提交 -> 审批 -> 创建批次 -> 复
await page.goto("/payment-batches");
await expect(page).toHaveURL(/\/payment-batches/);
const createCard = page.locator(".card-std").filter({ hasText: "新建批次" }).first();
const createCard = page.getByTestId("payment-batch-create-panel");
const createBatchResponsePromise = page.waitForResponse((response) => {
const url = new URL(response.url());
return response.request().method() === "POST" && url.pathname === "/api/payment-batches" && response.ok();
});
await createCard.locator("select").nth(0).selectOption("reimbursement");
await createCard.getByPlaceholder("例如:2026Q2-财务付款批次-01").fill(batchName);
await createCard.getByPlaceholder("用逗号或换行分隔 reimbursement / travel_order ID").fill(reimbursementId);
await createCard.locator('input[type="date"]').fill(paymentDate);
await createCard.locator("select").nth(1).selectOption("bank");
await createCard.getByPlaceholder("例如 PBX").fill("R78PB");
await createCard.getByTestId("payment-batch-create-entity-type").selectOption("reimbursement");
await createCard.getByTestId("payment-batch-create-name").fill(batchName);
await createCard.getByTestId("payment-batch-create-entity-ids").fill(reimbursementId);
await createCard.getByTestId("payment-batch-create-payment-date").fill(paymentDate);
await createCard.getByTestId("payment-batch-create-payment-channel").selectOption("bank");
await createCard.getByTestId("payment-batch-create-voucher-prefix").fill("R78PB");
await createCard.getByRole("button", { name: "创建批次" }).click();
const createBatchPayload = (await (await createBatchResponsePromise).json()) as {
@@ -157,10 +157,10 @@ test("E2E 报销支付批次主链路:提交 -> 审批 -> 创建批次 -> 复
throw new Error(`创建支付批次后未返回 id: ${JSON.stringify(createBatchPayload)}`);
}
await page.goto(`/payment-batches?id=${batchId}`);
const batchDetailCard = page.locator(".card-std").filter({ hasText: batchName }).filter({ hasText: "复核进度:" }).last();
const batchDetailCard = page.getByTestId("payment-batch-detail-panel").filter({ hasText: batchName });
await expect(batchDetailCard).toBeVisible();
await expect(batchDetailCard).toContainText("状态:草稿");
await expect(batchDetailCard).toContainText("复核进度:0/1");
await expect(batchDetailCard).toContainText("草稿");
await expect(batchDetailCard).toContainText("0/1");
await logout(page, FINANCE.name);
@@ -179,12 +179,12 @@ test("E2E 报销支付批次主链路:提交 -> 审批 -> 创建批次 -> 复
await login(page, FINANCE);
await page.goto(`/payment-batches?id=${batchId}`);
const executedBatchDetailCard = page.locator(".card-std").filter({ hasText: batchName }).filter({ hasText: "复核进度:" }).last();
const executedBatchDetailCard = page.getByTestId("payment-batch-detail-panel").filter({ hasText: batchName });
await expect(executedBatchDetailCard).toBeVisible();
await expect(executedBatchDetailCard).toContainText("复核进度:1/1");
const receiptCard = page.locator(".card-std").filter({ hasText: "银行回单附件" }).first();
await expect(executedBatchDetailCard).toContainText("1/1");
const receiptCard = page.getByTestId("payment-batch-receipt-panel");
await expect(receiptCard).toBeVisible();
await receiptCard.locator('input[type="file"]').setInputFiles({
await receiptCard.getByTestId("payment-batch-receipt-file-input").setInputFiles({
name: "r78-bank-receipt.pdf",
mimeType: "application/pdf",
buffer: Buffer.from(`%PDF-1.4\npayment receipt ${marker}\n%%EOF\n`, "utf8"),
@@ -209,7 +209,7 @@ test("E2E 报销支付批次主链路:提交 -> 审批 -> 创建批次 -> 复
await expect(page.getByTestId("action-confirm-dialog")).toContainText("确认后将执行付款批次");
await page.getByTestId("action-confirm-submit").click();
await executeBatchResponsePromise;
await expect(executedBatchDetailCard).toContainText("状态:已执行", { timeout: 30_000 });
await expect(executedBatchDetailCard).toContainText("已执行", { timeout: 30_000 });
await page.goto(`/reimbursements/${reimbursementId}`);
await reimbursementDetail.assertLoaded();
@@ -243,7 +243,7 @@ test("E2E 报销支付批次主链路:提交 -> 审批 -> 创建批次 -> 复
).toBe(true);
await page.goto("/ap-operations");
await expect(page.getByRole("tab", { name: /财务台账/ })).toBeVisible();
await page.getByRole("tab", { name: /财务台账/ }).click();
await expect(page.getByTestId("finance-ledger-table")).toContainText(reimbursementDisplayCode);
await expect(page.getByTestId("finance-ledger-table")).toContainText("已付款");
await expect(page.getByRole("tab", { name: /待付款/ })).toBeVisible();