aria-ease 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import "./chunk-JSBRDJBE.js";
1
+ import "./chunk-2P3A4VVY.js";
2
2
 
3
3
  // src/utils/audit/src/audit/audit.ts
4
4
  import AxeBuilder from "@axe-core/playwright";
@@ -7,6 +7,10 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
10
14
  var __copyProps = (to, from, except, desc) => {
11
15
  if (from && typeof from === "object" || typeof from === "function") {
12
16
  for (let key of __getOwnPropNames(from))
@@ -15,6 +19,7 @@ var __copyProps = (to, from, except, desc) => {
15
19
  }
16
20
  return to;
17
21
  };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
23
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
24
  // If the importer is in node compatibility mode or this is not an ESM
20
25
  // file that has been converted to a CommonJS file using a Babel-
@@ -26,5 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
31
 
27
32
  export {
28
33
  __commonJS,
34
+ __export,
35
+ __reExport,
29
36
  __toESM
30
37
  };
package/bin/cli.cjs CHANGED
@@ -24,6 +24,7 @@ var __copyProps = (to, from, except, desc) => {
24
24
  }
25
25
  return to;
26
26
  };
27
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
27
28
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
29
  // If the importer is in node compatibility mode or this is not an ESM
29
30
  // file that has been converted to a CommonJS file using a Babel-
@@ -13274,6 +13275,20 @@ var init_contractTestRunner = __esm({
13274
13275
  }
13275
13276
  });
13276
13277
 
13278
+ // node_modules/@playwright/test/index.mjs
13279
+ var test_exports = {};
13280
+ __export(test_exports, {
13281
+ default: () => import_test.default
13282
+ });
13283
+ var import_test;
13284
+ var init_test = __esm({
13285
+ "node_modules/@playwright/test/index.mjs"() {
13286
+ "use strict";
13287
+ __reExport(test_exports, require("playwright/test"));
13288
+ import_test = __toESM(require("playwright/test"), 1);
13289
+ }
13290
+ });
13291
+
13277
13292
  // src/utils/test/contract/contractTestRunnerPlaywright.ts
13278
13293
  var contractTestRunnerPlaywright_exports = {};
13279
13294
  __export(contractTestRunnerPlaywright_exports, {
@@ -13307,6 +13322,18 @@ async function runContractTestsPlaywright(componentName, url) {
13307
13322
  throw new Error(`No main selector (trigger, input, or container) found in contract for ${componentName}`);
13308
13323
  }
13309
13324
  await page.waitForSelector(mainSelector, { timeout: 6e4 });
13325
+ if (componentName === "menu" && componentContract.selectors.trigger) {
13326
+ await page.waitForFunction(
13327
+ (selector) => {
13328
+ const trigger = document.querySelector(selector);
13329
+ return trigger && trigger.getAttribute("data-menu-initialized") === "true";
13330
+ },
13331
+ componentContract.selectors.trigger,
13332
+ { timeout: 5e3 }
13333
+ ).catch(() => {
13334
+ console.warn("Menu initialization signal not detected, continuing with tests...");
13335
+ });
13336
+ }
13310
13337
  async function resolveRelativeTarget(selector, relative) {
13311
13338
  const items = await page.locator(selector).all();
13312
13339
  switch (relative) {
@@ -13431,7 +13458,7 @@ async function runContractTestsPlaywright(componentName, url) {
13431
13458
  continue;
13432
13459
  }
13433
13460
  await relativeElement.click();
13434
- await page.waitForTimeout(200);
13461
+ await page.waitForTimeout(componentName === "menu" ? 500 : 200);
13435
13462
  } else {
13436
13463
  const actionSelector = componentContract.selectors[act.target];
13437
13464
  if (!actionSelector) {
@@ -13439,7 +13466,7 @@ async function runContractTestsPlaywright(componentName, url) {
13439
13466
  continue;
13440
13467
  }
13441
13468
  await page.locator(actionSelector).first().click();
13442
- await page.waitForTimeout(200);
13469
+ await page.waitForTimeout(componentName === "menu" ? 500 : 200);
13443
13470
  }
13444
13471
  }
13445
13472
  if (act.type === "keypress" && act.key) {
@@ -13533,32 +13560,48 @@ async function runContractTestsPlaywright(componentName, url) {
13533
13560
  continue;
13534
13561
  }
13535
13562
  if (assertion.assertion === "toBeVisible") {
13536
- const isVisible = await target.isVisible();
13537
- if (isVisible) {
13563
+ try {
13564
+ await (0, test_exports.expect)(target).toBeVisible({ timeout: 3e3 });
13538
13565
  passes.push(`${assertion.target} is visible as expected. Test: "${dynamicTest.description}".`);
13539
- } else {
13540
- failures.push(`${assertion.failureMessage}`);
13566
+ } catch {
13567
+ const debugState = await page.evaluate((sel) => {
13568
+ const el = sel ? document.querySelector(sel) : null;
13569
+ if (!el) return "element not found";
13570
+ const styles = window.getComputedStyle(el);
13571
+ return `display:${styles.display}, visibility:${styles.visibility}, opacity:${styles.opacity}`;
13572
+ }, componentContract.selectors[assertion.target] || "");
13573
+ failures.push(`${assertion.failureMessage} (actual: ${debugState})`);
13541
13574
  }
13542
13575
  }
13543
13576
  if (assertion.assertion === "notToBeVisible") {
13544
- const isVisible = await target.isVisible();
13545
- if (!isVisible) {
13577
+ try {
13578
+ await (0, test_exports.expect)(target).toBeHidden({ timeout: 5e3 });
13546
13579
  passes.push(`${assertion.target} is not visible as expected. Test: "${dynamicTest.description}".`);
13547
- } else {
13548
- failures.push(assertion.failureMessage + ` ${assertion.target} is still visible.`);
13580
+ } catch {
13581
+ const debugState = await page.evaluate((sel) => {
13582
+ const el = sel ? document.querySelector(sel) : null;
13583
+ if (!el) return "element not found";
13584
+ const styles = window.getComputedStyle(el);
13585
+ return `display:${styles.display}, visibility:${styles.visibility}, opacity:${styles.opacity}`;
13586
+ }, componentContract.selectors[assertion.target] || "");
13587
+ failures.push(assertion.failureMessage + ` ${assertion.target} is still visible (actual: ${debugState}).`);
13549
13588
  }
13550
13589
  }
13551
13590
  if (assertion.assertion === "toHaveAttribute" && assertion.attribute && assertion.expectedValue) {
13552
- const attributeValue = await target.getAttribute(assertion.attribute);
13553
- if (assertion.expectedValue === "!empty") {
13554
- if (attributeValue && attributeValue.trim() !== "") {
13555
- passes.push(`${assertion.target} has non-empty "${assertion.attribute}". Test: "${dynamicTest.description}".`);
13591
+ try {
13592
+ if (assertion.expectedValue === "!empty") {
13593
+ const attributeValue = await target.getAttribute(assertion.attribute);
13594
+ if (attributeValue && attributeValue.trim() !== "") {
13595
+ passes.push(`${assertion.target} has non-empty "${assertion.attribute}". Test: "${dynamicTest.description}".`);
13596
+ } else {
13597
+ failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
13598
+ }
13556
13599
  } else {
13557
- failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
13600
+ await (0, test_exports.expect)(target).toHaveAttribute(assertion.attribute, assertion.expectedValue, { timeout: 3e3 });
13601
+ passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
13558
13602
  }
13559
- } else if (attributeValue === assertion.expectedValue) {
13560
- passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
13561
- } else {
13603
+ } catch {
13604
+ const attributeValue = await target.getAttribute(assertion.attribute);
13562
13605
  failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should be "${assertion.expectedValue}", found "${attributeValue}".`);
13563
13606
  }
13564
13607
  }
@@ -13583,10 +13626,10 @@ async function runContractTestsPlaywright(componentName, url) {
13583
13626
  }
13584
13627
  }
13585
13628
  if (assertion.assertion === "toHaveFocus") {
13586
- const hasFocus = await target.evaluate((el) => el === document.activeElement);
13587
- if (hasFocus) {
13629
+ try {
13630
+ await (0, test_exports.expect)(target).toBeFocused({ timeout: 5e3 });
13588
13631
  passes.push(`${assertion.target} has focus as expected. Test: "${dynamicTest.description}".`);
13589
- } else {
13632
+ } catch {
13590
13633
  failures.push(`${assertion.failureMessage}`);
13591
13634
  }
13592
13635
  }
@@ -13634,6 +13677,7 @@ var init_contractTestRunnerPlaywright = __esm({
13634
13677
  "src/utils/test/contract/contractTestRunnerPlaywright.ts"() {
13635
13678
  "use strict";
13636
13679
  import_playwright3 = require("playwright");
13680
+ init_test();
13637
13681
  import_fs = require("fs");
13638
13682
  init_contract();
13639
13683
  init_ContractReporter();
@@ -13688,7 +13732,7 @@ ${violationDetails}
13688
13732
  return result;
13689
13733
  }
13690
13734
  var import_jest_axe, runTest;
13691
- var init_test = __esm({
13735
+ var init_test2 = __esm({
13692
13736
  "src/utils/test/src/test.ts"() {
13693
13737
  "use strict";
13694
13738
  import_jest_axe = require("jest-axe");
@@ -13721,15 +13765,15 @@ var init_test = __esm({
13721
13765
  });
13722
13766
 
13723
13767
  // src/utils/test/index.ts
13724
- var test_exports = {};
13725
- __export(test_exports, {
13768
+ var test_exports2 = {};
13769
+ __export(test_exports2, {
13726
13770
  runTest: () => runTest,
13727
13771
  testUiComponent: () => testUiComponent
13728
13772
  });
13729
- var init_test2 = __esm({
13773
+ var init_test3 = __esm({
13730
13774
  "src/utils/test/index.ts"() {
13731
13775
  "use strict";
13732
- init_test();
13776
+ init_test2();
13733
13777
  }
13734
13778
  });
13735
13779
 
@@ -13936,7 +13980,7 @@ program.command("audit").description("Run axe-core powered accessibility audit o
13936
13980
  console.log(import_chalk.default.green("\n\u{1F389} All audits completed."));
13937
13981
  });
13938
13982
  program.command("test").description("Run core a11y accessibility standard tests on UI components").action(async () => {
13939
- const { runTest: runTest2 } = await Promise.resolve().then(() => (init_test2(), test_exports));
13983
+ const { runTest: runTest2 } = await Promise.resolve().then(() => (init_test3(), test_exports2));
13940
13984
  runTest2();
13941
13985
  });
13942
13986
  program.command("help").description("Display help information").action(() => {
package/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-JSBRDJBE.js";
2
+ import "./chunk-2P3A4VVY.js";
3
3
 
4
4
  // src/utils/cli/cli.ts
5
5
  import { Command } from "commander";
@@ -128,8 +128,8 @@ var program = new Command();
128
128
  program.name("aria-ease").description("Run accessibility tests and audits").version("2.2.3");
129
129
  program.command("audit").description("Run axe-core powered accessibility audit on webpages").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv | html | all", "all").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports/audit").action(async (opts) => {
130
130
  console.log(chalk.cyanBright("\u{1F680} Starting accessibility audit...\n"));
131
- const { runAudit } = await import("./audit-XZJXMUPL.js");
132
- const { formatResults } = await import("./formatters-U4E5EVPL.js");
131
+ const { runAudit } = await import("./audit-6A7OW5NJ.js");
132
+ const { formatResults } = await import("./formatters-FCDHFTPI.js");
133
133
  const { config, configPath, errors } = await loadConfig(process.cwd());
134
134
  if (configPath) {
135
135
  console.log(chalk.green(`\u2705 Loaded config from ${path2.basename(configPath)}
@@ -204,7 +204,7 @@ program.command("audit").description("Run axe-core powered accessibility audit o
204
204
  console.log(chalk.green("\n\u{1F389} All audits completed."));
205
205
  });
206
206
  program.command("test").description("Run core a11y accessibility standard tests on UI components").action(async () => {
207
- const { runTest } = await import("./test-PK5MBHIN.js");
207
+ const { runTest } = await import("./test-Q7W3WQEA.js");
208
208
  runTest();
209
209
  });
210
210
  program.command("help").description("Display help information").action(() => {
@@ -2,10 +2,24 @@ import {
2
2
  ContractReporter,
3
3
  contract_default
4
4
  } from "./chunk-5Z7PR3VC.js";
5
- import "./chunk-JSBRDJBE.js";
5
+ import {
6
+ __export,
7
+ __reExport
8
+ } from "./chunk-2P3A4VVY.js";
6
9
 
7
10
  // src/utils/test/contract/contractTestRunnerPlaywright.ts
8
11
  import { chromium } from "playwright";
12
+
13
+ // node_modules/@playwright/test/index.mjs
14
+ var test_exports = {};
15
+ __export(test_exports, {
16
+ default: () => default2
17
+ });
18
+ __reExport(test_exports, test_star);
19
+ import * as test_star from "playwright/test";
20
+ import { default as default2 } from "playwright/test";
21
+
22
+ // src/utils/test/contract/contractTestRunnerPlaywright.ts
9
23
  import { readFileSync } from "fs";
10
24
  async function runContractTestsPlaywright(componentName, url) {
11
25
  const reporter = new ContractReporter(true);
@@ -35,6 +49,18 @@ async function runContractTestsPlaywright(componentName, url) {
35
49
  throw new Error(`No main selector (trigger, input, or container) found in contract for ${componentName}`);
36
50
  }
37
51
  await page.waitForSelector(mainSelector, { timeout: 6e4 });
52
+ if (componentName === "menu" && componentContract.selectors.trigger) {
53
+ await page.waitForFunction(
54
+ (selector) => {
55
+ const trigger = document.querySelector(selector);
56
+ return trigger && trigger.getAttribute("data-menu-initialized") === "true";
57
+ },
58
+ componentContract.selectors.trigger,
59
+ { timeout: 5e3 }
60
+ ).catch(() => {
61
+ console.warn("Menu initialization signal not detected, continuing with tests...");
62
+ });
63
+ }
38
64
  async function resolveRelativeTarget(selector, relative) {
39
65
  const items = await page.locator(selector).all();
40
66
  switch (relative) {
@@ -159,7 +185,7 @@ async function runContractTestsPlaywright(componentName, url) {
159
185
  continue;
160
186
  }
161
187
  await relativeElement.click();
162
- await page.waitForTimeout(200);
188
+ await page.waitForTimeout(componentName === "menu" ? 500 : 200);
163
189
  } else {
164
190
  const actionSelector = componentContract.selectors[act.target];
165
191
  if (!actionSelector) {
@@ -167,7 +193,7 @@ async function runContractTestsPlaywright(componentName, url) {
167
193
  continue;
168
194
  }
169
195
  await page.locator(actionSelector).first().click();
170
- await page.waitForTimeout(200);
196
+ await page.waitForTimeout(componentName === "menu" ? 500 : 200);
171
197
  }
172
198
  }
173
199
  if (act.type === "keypress" && act.key) {
@@ -261,32 +287,48 @@ async function runContractTestsPlaywright(componentName, url) {
261
287
  continue;
262
288
  }
263
289
  if (assertion.assertion === "toBeVisible") {
264
- const isVisible = await target.isVisible();
265
- if (isVisible) {
290
+ try {
291
+ await (0, test_exports.expect)(target).toBeVisible({ timeout: 3e3 });
266
292
  passes.push(`${assertion.target} is visible as expected. Test: "${dynamicTest.description}".`);
267
- } else {
268
- failures.push(`${assertion.failureMessage}`);
293
+ } catch {
294
+ const debugState = await page.evaluate((sel) => {
295
+ const el = sel ? document.querySelector(sel) : null;
296
+ if (!el) return "element not found";
297
+ const styles = window.getComputedStyle(el);
298
+ return `display:${styles.display}, visibility:${styles.visibility}, opacity:${styles.opacity}`;
299
+ }, componentContract.selectors[assertion.target] || "");
300
+ failures.push(`${assertion.failureMessage} (actual: ${debugState})`);
269
301
  }
270
302
  }
271
303
  if (assertion.assertion === "notToBeVisible") {
272
- const isVisible = await target.isVisible();
273
- if (!isVisible) {
304
+ try {
305
+ await (0, test_exports.expect)(target).toBeHidden({ timeout: 5e3 });
274
306
  passes.push(`${assertion.target} is not visible as expected. Test: "${dynamicTest.description}".`);
275
- } else {
276
- failures.push(assertion.failureMessage + ` ${assertion.target} is still visible.`);
307
+ } catch {
308
+ const debugState = await page.evaluate((sel) => {
309
+ const el = sel ? document.querySelector(sel) : null;
310
+ if (!el) return "element not found";
311
+ const styles = window.getComputedStyle(el);
312
+ return `display:${styles.display}, visibility:${styles.visibility}, opacity:${styles.opacity}`;
313
+ }, componentContract.selectors[assertion.target] || "");
314
+ failures.push(assertion.failureMessage + ` ${assertion.target} is still visible (actual: ${debugState}).`);
277
315
  }
278
316
  }
279
317
  if (assertion.assertion === "toHaveAttribute" && assertion.attribute && assertion.expectedValue) {
280
- const attributeValue = await target.getAttribute(assertion.attribute);
281
- if (assertion.expectedValue === "!empty") {
282
- if (attributeValue && attributeValue.trim() !== "") {
283
- passes.push(`${assertion.target} has non-empty "${assertion.attribute}". Test: "${dynamicTest.description}".`);
318
+ try {
319
+ if (assertion.expectedValue === "!empty") {
320
+ const attributeValue = await target.getAttribute(assertion.attribute);
321
+ if (attributeValue && attributeValue.trim() !== "") {
322
+ passes.push(`${assertion.target} has non-empty "${assertion.attribute}". Test: "${dynamicTest.description}".`);
323
+ } else {
324
+ failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
325
+ }
284
326
  } else {
285
- failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
327
+ await (0, test_exports.expect)(target).toHaveAttribute(assertion.attribute, assertion.expectedValue, { timeout: 3e3 });
328
+ passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
286
329
  }
287
- } else if (attributeValue === assertion.expectedValue) {
288
- passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
289
- } else {
330
+ } catch {
331
+ const attributeValue = await target.getAttribute(assertion.attribute);
290
332
  failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should be "${assertion.expectedValue}", found "${attributeValue}".`);
291
333
  }
292
334
  }
@@ -311,10 +353,10 @@ async function runContractTestsPlaywright(componentName, url) {
311
353
  }
312
354
  }
313
355
  if (assertion.assertion === "toHaveFocus") {
314
- const hasFocus = await target.evaluate((el) => el === document.activeElement);
315
- if (hasFocus) {
356
+ try {
357
+ await (0, test_exports.expect)(target).toBeFocused({ timeout: 5e3 });
316
358
  passes.push(`${assertion.target} has focus as expected. Test: "${dynamicTest.description}".`);
317
- } else {
359
+ } catch {
318
360
  failures.push(`${assertion.failureMessage}`);
319
361
  }
320
362
  }
@@ -1,4 +1,4 @@
1
- import "./chunk-JSBRDJBE.js";
1
+ import "./chunk-2P3A4VVY.js";
2
2
 
3
3
  // src/utils/audit/src/formatters/formatters.ts
4
4
  function formatResults(allResults, format) {
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  __commonJS,
7
7
  __toESM
8
- } from "./chunk-JSBRDJBE.js";
8
+ } from "./chunk-2P3A4VVY.js";
9
9
 
10
10
  // node_modules/ansi-styles/index.js
11
11
  var require_ansi_styles = __commonJS({
@@ -12750,7 +12750,7 @@ async function testUiComponent(componentName, component, url) {
12750
12750
  let contract;
12751
12751
  if (url) {
12752
12752
  console.log(`\u{1F3AD} Running Playwright E2E tests on ${url}`);
12753
- const { runContractTestsPlaywright } = await import("./contractTestRunnerPlaywright-62LXHK7K.js");
12753
+ const { runContractTestsPlaywright } = await import("./contractTestRunnerPlaywright-TLQZGKW7.js");
12754
12754
  contract = await runContractTestsPlaywright(componentName, url);
12755
12755
  } else {
12756
12756
  console.log(`\u{1F9EA} Running jsdom tests (limited event handling)`);
@@ -7,6 +7,10 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
10
14
  var __copyProps = (to, from, except, desc) => {
11
15
  if (from && typeof from === "object" || typeof from === "function") {
12
16
  for (let key of __getOwnPropNames(from))
@@ -15,6 +19,7 @@ var __copyProps = (to, from, except, desc) => {
15
19
  }
16
20
  return to;
17
21
  };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
23
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
24
  // If the importer is in node compatibility mode or this is not an ESM
20
25
  // file that has been converted to a CommonJS file using a Babel-
@@ -204,6 +209,8 @@ ${"\u2550".repeat(60)}`);
204
209
 
205
210
  export {
206
211
  __commonJS,
212
+ __export,
213
+ __reExport,
207
214
  __toESM,
208
215
  contract_default,
209
216
  ContractReporter
@@ -1,10 +1,23 @@
1
1
  import {
2
2
  ContractReporter,
3
+ __export,
4
+ __reExport,
3
5
  contract_default
4
- } from "./chunk-57O4KFP4.js";
6
+ } from "./chunk-IPJYOFRK.js";
5
7
 
6
8
  // src/utils/test/contract/contractTestRunnerPlaywright.ts
7
9
  import { chromium } from "playwright";
10
+
11
+ // node_modules/@playwright/test/index.mjs
12
+ var test_exports = {};
13
+ __export(test_exports, {
14
+ default: () => default2
15
+ });
16
+ __reExport(test_exports, test_star);
17
+ import * as test_star from "playwright/test";
18
+ import { default as default2 } from "playwright/test";
19
+
20
+ // src/utils/test/contract/contractTestRunnerPlaywright.ts
8
21
  import { readFileSync } from "fs";
9
22
  async function runContractTestsPlaywright(componentName, url) {
10
23
  const reporter = new ContractReporter(true);
@@ -34,6 +47,18 @@ async function runContractTestsPlaywright(componentName, url) {
34
47
  throw new Error(`No main selector (trigger, input, or container) found in contract for ${componentName}`);
35
48
  }
36
49
  await page.waitForSelector(mainSelector, { timeout: 6e4 });
50
+ if (componentName === "menu" && componentContract.selectors.trigger) {
51
+ await page.waitForFunction(
52
+ (selector) => {
53
+ const trigger = document.querySelector(selector);
54
+ return trigger && trigger.getAttribute("data-menu-initialized") === "true";
55
+ },
56
+ componentContract.selectors.trigger,
57
+ { timeout: 5e3 }
58
+ ).catch(() => {
59
+ console.warn("Menu initialization signal not detected, continuing with tests...");
60
+ });
61
+ }
37
62
  async function resolveRelativeTarget(selector, relative) {
38
63
  const items = await page.locator(selector).all();
39
64
  switch (relative) {
@@ -158,7 +183,7 @@ async function runContractTestsPlaywright(componentName, url) {
158
183
  continue;
159
184
  }
160
185
  await relativeElement.click();
161
- await page.waitForTimeout(200);
186
+ await page.waitForTimeout(componentName === "menu" ? 500 : 200);
162
187
  } else {
163
188
  const actionSelector = componentContract.selectors[act.target];
164
189
  if (!actionSelector) {
@@ -166,7 +191,7 @@ async function runContractTestsPlaywright(componentName, url) {
166
191
  continue;
167
192
  }
168
193
  await page.locator(actionSelector).first().click();
169
- await page.waitForTimeout(200);
194
+ await page.waitForTimeout(componentName === "menu" ? 500 : 200);
170
195
  }
171
196
  }
172
197
  if (act.type === "keypress" && act.key) {
@@ -260,32 +285,48 @@ async function runContractTestsPlaywright(componentName, url) {
260
285
  continue;
261
286
  }
262
287
  if (assertion.assertion === "toBeVisible") {
263
- const isVisible = await target.isVisible();
264
- if (isVisible) {
288
+ try {
289
+ await (0, test_exports.expect)(target).toBeVisible({ timeout: 3e3 });
265
290
  passes.push(`${assertion.target} is visible as expected. Test: "${dynamicTest.description}".`);
266
- } else {
267
- failures.push(`${assertion.failureMessage}`);
291
+ } catch {
292
+ const debugState = await page.evaluate((sel) => {
293
+ const el = sel ? document.querySelector(sel) : null;
294
+ if (!el) return "element not found";
295
+ const styles = window.getComputedStyle(el);
296
+ return `display:${styles.display}, visibility:${styles.visibility}, opacity:${styles.opacity}`;
297
+ }, componentContract.selectors[assertion.target] || "");
298
+ failures.push(`${assertion.failureMessage} (actual: ${debugState})`);
268
299
  }
269
300
  }
270
301
  if (assertion.assertion === "notToBeVisible") {
271
- const isVisible = await target.isVisible();
272
- if (!isVisible) {
302
+ try {
303
+ await (0, test_exports.expect)(target).toBeHidden({ timeout: 5e3 });
273
304
  passes.push(`${assertion.target} is not visible as expected. Test: "${dynamicTest.description}".`);
274
- } else {
275
- failures.push(assertion.failureMessage + ` ${assertion.target} is still visible.`);
305
+ } catch {
306
+ const debugState = await page.evaluate((sel) => {
307
+ const el = sel ? document.querySelector(sel) : null;
308
+ if (!el) return "element not found";
309
+ const styles = window.getComputedStyle(el);
310
+ return `display:${styles.display}, visibility:${styles.visibility}, opacity:${styles.opacity}`;
311
+ }, componentContract.selectors[assertion.target] || "");
312
+ failures.push(assertion.failureMessage + ` ${assertion.target} is still visible (actual: ${debugState}).`);
276
313
  }
277
314
  }
278
315
  if (assertion.assertion === "toHaveAttribute" && assertion.attribute && assertion.expectedValue) {
279
- const attributeValue = await target.getAttribute(assertion.attribute);
280
- if (assertion.expectedValue === "!empty") {
281
- if (attributeValue && attributeValue.trim() !== "") {
282
- passes.push(`${assertion.target} has non-empty "${assertion.attribute}". Test: "${dynamicTest.description}".`);
316
+ try {
317
+ if (assertion.expectedValue === "!empty") {
318
+ const attributeValue = await target.getAttribute(assertion.attribute);
319
+ if (attributeValue && attributeValue.trim() !== "") {
320
+ passes.push(`${assertion.target} has non-empty "${assertion.attribute}". Test: "${dynamicTest.description}".`);
321
+ } else {
322
+ failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
323
+ }
283
324
  } else {
284
- failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
325
+ await (0, test_exports.expect)(target).toHaveAttribute(assertion.attribute, assertion.expectedValue, { timeout: 3e3 });
326
+ passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
285
327
  }
286
- } else if (attributeValue === assertion.expectedValue) {
287
- passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
288
- } else {
328
+ } catch {
329
+ const attributeValue = await target.getAttribute(assertion.attribute);
289
330
  failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should be "${assertion.expectedValue}", found "${attributeValue}".`);
290
331
  }
291
332
  }
@@ -310,10 +351,10 @@ async function runContractTestsPlaywright(componentName, url) {
310
351
  }
311
352
  }
312
353
  if (assertion.assertion === "toHaveFocus") {
313
- const hasFocus = await target.evaluate((el) => el === document.activeElement);
314
- if (hasFocus) {
354
+ try {
355
+ await (0, test_exports.expect)(target).toBeFocused({ timeout: 5e3 });
315
356
  passes.push(`${assertion.target} has focus as expected. Test: "${dynamicTest.description}".`);
316
- } else {
357
+ } catch {
317
358
  failures.push(`${assertion.failureMessage}`);
318
359
  }
319
360
  }