27 lines
862 B
JavaScript
27 lines
862 B
JavaScript
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;
|
||
|
|
}
|