补齐固定旧版的浏览器逐笔写入对照并记录账务差异
This commit is contained in:
1 parent
e77588b337
commit
7d2007955f
39 files changed
+3653
-41
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
export function ui({ version, step }) {
|
||||
const action = (scope, name) => scope.locator('[data-action="' + name + '"]:visible').first();
|
||||
const field = (scope, name) => scope.locator('[name="' + name + '"]');
|
||||
const dialog = page => page.locator('dialog[open]').last();
|
||||
async function fill(scope, values) {
|
||||
for (const [key, value] of Object.entries(values)) await field(scope, key).fill(value);
|
||||
}
|
||||
async function navigate(page, section) {
|
||||
while (await page.locator('dialog[open]').count()) await page.keyboard.press('Escape');
|
||||
const link = version === 'old' ? '[data-tab="' + section + '"]' : 'a[href="/next/' + section + '"]';
|
||||
await page.locator('nav:visible').locator(link).first().click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
}
|
||||
async function write(name, page, endpoint, click, { status = 200, after } = {}) {
|
||||
let response;
|
||||
await step(name, async () => {
|
||||
const waiting = page.waitForResponse(r => {
|
||||
const url = new URL(r.url()).pathname;
|
||||
return (
|
||||
r.request().method() === 'POST' && (typeof endpoint === 'string' ? url === endpoint : endpoint.test(url))
|
||||
);
|
||||
});
|
||||
[response] = await Promise.all([waiting, click()]);
|
||||
assert.equal(response.status(), status, name + ' ' + (await response.text()));
|
||||
assert.ok(response.request().headers()['idempotency-key'], name + ' 缺少原操作号');
|
||||
if (after) await after();
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
return response;
|
||||
}
|
||||
const submit = form => form.locator('button[type="submit"]').click();
|
||||
return { action, field, dialog, fill, navigate, write, submit };
|
||||
}
|
||||
Reference in new issue
Block a user