Synchronize guidance navigation with fulfilled session and rendered state
creative workspace review checks / verify (pull_request) Successful in 23m45s
creative workspace review checks / verify (pull_request) Successful in 23m45s
This commit is contained in:
@@ -27,9 +27,11 @@ export async function verifyGuidanceWorkspaceUI(base: string, browser: Browser)
|
|||||||
requestedAuthor: string | null = null,
|
requestedAuthor: string | null = null,
|
||||||
published: Guidance | null = null;
|
published: Guidance | null = null;
|
||||||
const errors: string[] = [];
|
const errors: string[] = [];
|
||||||
|
let sessionReplies = 0;
|
||||||
try {
|
try {
|
||||||
await context.route("**/api/account/session", (route) =>
|
await context.route("**/api/account/session", async (route) => {
|
||||||
route.fulfill({
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
json: {
|
json: {
|
||||||
user: signedIn
|
user: signedIn
|
||||||
? {
|
? {
|
||||||
@@ -39,8 +41,9 @@ export async function verifyGuidanceWorkspaceUI(base: string, browser: Browser)
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
}),
|
});
|
||||||
);
|
sessionReplies += 1;
|
||||||
|
});
|
||||||
await context.route(
|
await context.route(
|
||||||
(url) => url.pathname === "/api/documents",
|
(url) => url.pathname === "/api/documents",
|
||||||
async (route) => {
|
async (route) => {
|
||||||
@@ -94,11 +97,12 @@ export async function verifyGuidanceWorkspaceUI(base: string, browser: Browser)
|
|||||||
page.on("requestfinished", request => pending.delete(request.url()));
|
page.on("requestfinished", request => pending.delete(request.url()));
|
||||||
page.on("requestfailed", request => {pending.delete(request.url());network.push(new URL(request.url()).pathname+": "+request.failure()?.errorText);});
|
page.on("requestfailed", request => {pending.delete(request.url());network.push(new URL(request.url()).pathname+": "+request.failure()?.errorText);});
|
||||||
async function navigate(url: string, reload = false) {
|
async function navigate(url: string, reload = false) {
|
||||||
const session = page.waitForResponse(response => new URL(response.url()).pathname === "/api/account/session" && response.status() === 200);
|
const previousSessionReplies = sessionReplies;
|
||||||
try {
|
try {
|
||||||
const [navigation] = await Promise.all([reload ? page.reload({waitUntil:"domcontentloaded"}) : page.goto(url,{waitUntil:"domcontentloaded"}),session]);
|
const navigation = await (reload ? page.reload({waitUntil:"domcontentloaded"}) : page.goto(url,{waitUntil:"domcontentloaded"}));
|
||||||
assert.ok(navigation?.ok(), "Navigation returns a successful document");
|
assert.ok(navigation?.ok(), "Navigation returns a successful document");
|
||||||
await page.getByText(signedIn ? "editor@example.com" : "登录你的账户",{exact:true}).first().waitFor({state:"attached"});
|
await page.getByText(signedIn ? "editor@example.com" : "登录你的账户",{exact:true}).first().waitFor({state:"attached"});
|
||||||
|
assert.ok(sessionReplies > previousSessionReplies, "The new document requests its account fixture and renders the resulting account state");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const probeStarted=Date.now();
|
const probeStarted=Date.now();
|
||||||
const server=await fetch(url,{signal:AbortSignal.timeout(3000)}).then(async response=>{await response.body?.cancel();return {status:response.status,elapsedMs:Date.now()-probeStarted}}).catch(error=>({error:error instanceof Error?error.name:"unknown",elapsedMs:Date.now()-probeStarted}));
|
const server=await fetch(url,{signal:AbortSignal.timeout(3000)}).then(async response=>{await response.body?.cancel();return {status:response.status,elapsedMs:Date.now()-probeStarted}}).catch(error=>({error:error instanceof Error?error.name:"unknown",elapsedMs:Date.now()-probeStarted}));
|
||||||
|
|||||||
Reference in New Issue
Block a user