HH-847 / HH-799: add draft review and idempotent enqueue (#24)
This commit is contained in:
@@ -57,6 +57,7 @@ test('keeps account and network-exit pages inside 599px, 900px and 1280px', asyn
|
||||
const networkExit = { id: 'exit-a', protocol: 'socks5', host: hostname, port: 1080, health_status: 'healthy', credential_reference: { id: credentialID, provider: 'os_keyring' } }
|
||||
await page.route('**/api/phase-a/accounts', route => route.fulfill({ json: [account] }))
|
||||
await page.route('**/api/phase-a/accounts/account-a', route => route.fulfill({ json: account }))
|
||||
await page.route('**/api/phase-a/drafts?account_id=account-a', route => route.fulfill({ json: [] }))
|
||||
await page.route('**/api/browsers', route => route.fulfill({ json: [binding] }))
|
||||
await page.route('**/api/network-exits', route => route.fulfill({ json: [networkExit] }))
|
||||
|
||||
@@ -75,6 +76,7 @@ test('opens account detail at the phase A route', async ({ page }) => {
|
||||
await page.route('**/api/phase-a/accounts', route => route.fulfill({ json: [account] }))
|
||||
await page.route('**/api/phase-a/accounts/account-a', route => route.fulfill({ json: account }))
|
||||
await page.route('**/api/browsers', route => route.fulfill({ json: [] }))
|
||||
await page.route('**/api/phase-a/drafts?account_id=account-a', route => route.fulfill({ json: [] }))
|
||||
await page.setViewportSize({ width: 599, height: 900 })
|
||||
await page.goto('/#/accounts')
|
||||
|
||||
@@ -83,3 +85,37 @@ test('opens account detail at the phase A route', async ({ page }) => {
|
||||
await expect(page.getByRole('heading', { level: 1, name: 'shop-a' })).toBeVisible()
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(599)
|
||||
})
|
||||
|
||||
test('keeps draft review responsive and restores focus after dialog close and successful save', async ({ page }) => {
|
||||
const account = { id: 'account-a', platform: 'mock', platform_account_key: 'shop-a', authorization_status: 'authorized', runtime_status: 'active', version: 2 }
|
||||
const draft = {
|
||||
id: 'draft-a', account_id: 'account-a', version: 1, content: 'x'.repeat(1000), account,
|
||||
versions: [{ id: 'draft-a', account_id: 'account-a', version: 1, content: 'x'.repeat(1000) }],
|
||||
confirmations: [], tasks: [],
|
||||
}
|
||||
const binding = { alias: 'env-a', name: '店铺环境', account_id: 'account-a', network_exit_id: 'exit-a', network_exit_health: 'healthy', binding_version: 4, schedule_status: 'ready', schedule_block_reason: '' }
|
||||
await page.route('**/api/phase-a/drafts/draft-a', route => route.fulfill({ json: draft }))
|
||||
await page.route('**/api/browsers', route => route.fulfill({ json: [binding] }))
|
||||
await page.route('**/api/phase-a/confirmations', route => route.fulfill({ json: { id: 'confirmation-a' } }))
|
||||
|
||||
for (const width of [599, 900, 1280]) {
|
||||
await page.setViewportSize({ width, height: 900 })
|
||||
await page.goto('/#/drafts/draft-a')
|
||||
await expect(page.getByRole('heading', { level: 1, name: '草稿核对' })).toBeVisible()
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width)
|
||||
}
|
||||
|
||||
await page.setViewportSize({ width: 599, height: 900 })
|
||||
await page.getByRole('checkbox', { name: /我已核对当前账号/ }).check()
|
||||
const trigger = page.getByRole('button', { name: '确认当前快照' })
|
||||
await trigger.click()
|
||||
await expect(page.getByRole('dialog', { name: '确认草稿版本' })).toBeVisible()
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(page.getByRole('dialog')).toBeHidden()
|
||||
await expect(trigger).toBeFocused()
|
||||
|
||||
await trigger.click()
|
||||
await page.getByRole('button', { name: '保存确认' }).click()
|
||||
await expect(page.getByRole('dialog')).toBeHidden()
|
||||
await expect(trigger).toBeFocused()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user