test: capture stable replacement confirmation states #258

This commit is contained in:
QiuSW
2026-09-10 15:48:17 +08:00
parent 2b01974fe5
commit 3181302c16
+3 -1
View File
@@ -40,7 +40,7 @@ async function setup(page: any, replacing = false) {
return state
}
test('replacement reuses row position; cancel writes nothing; confirm freezes target and matches', async ({ page }) => {
test('replacement reuses row position; cancel writes nothing; confirm freezes target and matches', async ({ page }, testInfo) => {
const state = await setup(page, true)
await expect(page.getByRole('button', { name: '查看 PDD 商品', exact: true })).toHaveCount(2)
await expect(page.getByRole('button', { name: '一键关联', exact: true })).toHaveCount(0)
@@ -48,6 +48,7 @@ test('replacement reuses row position; cancel writes nothing; confirm freezes ta
await choose(page, '手机A', '选择并继续')
const confirm = page.getByRole('dialog', { name: '确认替换 PDD 商品' })
await expect(confirm).toContainText('共用此蝦皮商品')
await page.screenshot({ path: testInfo.outputPath('replacement-confirm.png'), animations: 'disabled' })
await confirm.getByRole('button', { name: '取消', exact: true }).click()
expect(state.links).toHaveLength(0); expect(state.matches).toHaveLength(0)
await page.getByRole('button', { name: '一键替换', exact: true }).first().click()
@@ -56,6 +57,7 @@ test('replacement reuses row position; cancel writes nothing; confirm freezes ta
expect(state.links).toHaveLength(1)
expect(state.links[0].latestCollection.replacement).toMatchObject({ expectedPddProductId: 44, taskId: 7, targetPddProductId: 55, targetVersion: 'frozen' })
await expect(page.locator('tbody').getByText('可创建采购', { exact: true })).toBeVisible()
await expect(confirm).toBeHidden()
})
async function choose(page: any, name: string, button: string) {