Files
weiguang-jewelry-ledger/新账系统/e2e/writes/operations-helpers.mjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
862 B
JavaScript
Raw Normal View History

import assert from 'node:assert/strict';
export async function section(page, ctx, key) {
if (ctx.version === 'new') await page.goto(ctx.base + '/next/' + key);
else {
await page.goto(ctx.base + '/');
await page
.locator('nav button[data-tab="' + key + '"]:visible')
.first()
.click();
}
}
export function action(scope, name) {
return scope.locator('[data-action="' + name + '"]:visible').first();
}
export async function postFrom(page, url, click, expectedStatus = 200) {
const [response] = await Promise.all([
page.waitForResponse(r => new URL(r.url()).pathname === url && r.request().method() === 'POST'),
click(),
]);
const result = await response.json();
assert.equal(response.status(), expectedStatus, url + ' ' + JSON.stringify(result));
await page.waitForLoadState('networkidle');
return result;
}