From 91b00e5c39726a1ba7312f01778193afdd84632b Mon Sep 17 00:00:00 2001 From: Virginia Cepeda Date: Mon, 7 Oct 2024 08:48:24 -0300 Subject: [PATCH] chore: update fillform example to use async check (#949) --- .../BrowserExamplesMenu/snippets/fillform.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/BrowserExamplesMenu/snippets/fillform.js b/src/components/BrowserExamplesMenu/snippets/fillform.js index b91bc495d..2b5487e00 100644 --- a/src/components/BrowserExamplesMenu/snippets/fillform.js +++ b/src/components/BrowserExamplesMenu/snippets/fillform.js @@ -1,5 +1,5 @@ -import { check } from 'k6'; import { browser } from 'k6/browser'; +import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js'; export const options = { scenarios: { @@ -35,15 +35,17 @@ export default async function () { // to resolve. await Promise.all([page.waitForNavigation(), page.locator('input[type="submit"]').click()]); - const h2 = page.locator('h2'); - const headerOK = (await h2.textContent()) == 'Welcome, admin!'; - check(headerOK, { header: headerOK }); + await check(page.locator('h2'), { + header: async (element) => { + return (await element.textContent()) == 'Welcome, admin!'; + }, + }); // Check whether we receive cookies from the logged site. - check(await context.cookies(), { - 'session cookie is set': (cookies) => { - const sessionID = cookies.find((c) => c.name == 'sid'); - return typeof sessionID !== 'undefined'; + await check(context, { + 'session cookie is set': async (ctx) => { + const cookies = await ctx.cookies(); + return cookies.find((c) => c.name == 'sid') !== undefined; }, }); } finally {