aria-ease 5.0.2 → 5.0.3

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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var default2 = require('playwright/test');
4
3
  var playwright = require('playwright');
4
+ var test = require('@playwright/test');
5
5
  var fs = require('fs');
6
6
  var jestAxe = require('jest-axe');
7
7
  var fs$1 = require('fs/promises');
@@ -9,31 +9,10 @@ var fs$1 = require('fs/promises');
9
9
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
- function _interopNamespace(e) {
13
- if (e && e.__esModule) return e;
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n.default = e;
27
- return Object.freeze(n);
28
- }
29
-
30
- var default2__namespace = /*#__PURE__*/_interopNamespace(default2);
31
12
  var fs__default = /*#__PURE__*/_interopDefault(fs$1);
32
13
 
33
14
  var __defProp = Object.defineProperty;
34
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
35
15
  var __getOwnPropNames = Object.getOwnPropertyNames;
36
- var __hasOwnProp = Object.prototype.hasOwnProperty;
37
16
  var __esm = (fn, res) => function __init() {
38
17
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
39
18
  };
@@ -41,15 +20,6 @@ var __export = (target, all) => {
41
20
  for (var name in all)
42
21
  __defProp(target, name, { get: all[name], enumerable: true });
43
22
  };
44
- var __copyProps = (to, from, except, desc) => {
45
- if (from && typeof from === "object" || typeof from === "function") {
46
- for (let key of __getOwnPropNames(from))
47
- if (!__hasOwnProp.call(to, key) && key !== except)
48
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
49
- }
50
- return to;
51
- };
52
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
53
23
 
54
24
  // src/utils/test/contract/contract.json
55
25
  var contract_default;
@@ -63,6 +33,10 @@ var init_contract = __esm({
63
33
  combobox: {
64
34
  path: "./contracts/ComboboxContract.json",
65
35
  component: "combobox"
36
+ },
37
+ accordion: {
38
+ path: "./contracts/AccordionContract.json",
39
+ component: "accordion"
66
40
  }
67
41
  };
68
42
  }
@@ -294,17 +268,6 @@ ${"\u2550".repeat(60)}`);
294
268
  }
295
269
  });
296
270
 
297
- // node_modules/@playwright/test/index.mjs
298
- var test_exports = {};
299
- __export(test_exports, {
300
- default: () => default2__namespace.default
301
- });
302
- var init_test = __esm({
303
- "node_modules/@playwright/test/index.mjs"() {
304
- __reExport(test_exports, default2__namespace);
305
- }
306
- });
307
-
308
271
  // src/utils/test/contract/contractTestRunnerPlaywright.ts
309
272
  var contractTestRunnerPlaywright_exports = {};
310
273
  __export(contractTestRunnerPlaywright_exports, {
@@ -333,25 +296,21 @@ async function runContractTestsPlaywright(componentName, url) {
333
296
  const page = await context.newPage();
334
297
  await page.goto(url, {
335
298
  waitUntil: "domcontentloaded",
336
- timeout: 9e4
299
+ timeout: 9e5
337
300
  });
301
+ await page.addStyleTag({ content: `* { transition: none !important; animation: none !important; }` });
338
302
  const mainSelector = componentContract.selectors.trigger || componentContract.selectors.input || componentContract.selectors.container;
339
303
  if (!mainSelector) {
340
304
  throw new Error(`No main selector (trigger, input, or container) found in contract for ${componentName}`);
341
305
  }
342
- await page.waitForSelector(mainSelector, { timeout: 9e4 });
306
+ await page.locator(mainSelector).first().waitFor({ state: "attached", timeout: 9e5 });
343
307
  if (componentName === "menu" && componentContract.selectors.trigger) {
344
- await page.waitForFunction(
345
- (selector) => {
346
- const trigger = document.querySelector(selector);
347
- return trigger && trigger.getAttribute("data-menu-initialized") === "true";
348
- },
349
- componentContract.selectors.trigger,
350
- { timeout: 1e4 }
351
- ).catch(() => {
352
- console.warn("Menu initialization signal not detected, continuing with tests...");
308
+ await page.locator(componentContract.selectors.trigger).first().waitFor({
309
+ state: "visible",
310
+ timeout: 1e4
311
+ }).catch(() => {
312
+ console.warn("Menu trigger not visible, continuing with tests...");
353
313
  });
354
- await page.waitForTimeout(300);
355
314
  }
356
315
  async function resolveRelativeTarget(selector, relative) {
357
316
  const items = await page.locator(selector).all();
@@ -427,7 +386,7 @@ async function runContractTestsPlaywright(componentName, url) {
427
386
  const popupSelector = componentContract.selectors.listbox || componentContract.selectors.container;
428
387
  if (!popupSelector) continue;
429
388
  const popupElement = page.locator(popupSelector).first();
430
- const isPopupVisible = await popupElement.isVisible();
389
+ const isPopupVisible = await popupElement.isVisible().catch(() => false);
431
390
  if (isPopupVisible) {
432
391
  let menuClosed = false;
433
392
  let closeSelector = componentContract.selectors.input;
@@ -439,44 +398,17 @@ async function runContractTestsPlaywright(componentName, url) {
439
398
  if (closeSelector) {
440
399
  const closeElement = page.locator(closeSelector).first();
441
400
  await closeElement.focus();
442
- await page.waitForTimeout(200);
443
401
  await page.keyboard.press("Escape");
444
- menuClosed = await page.waitForFunction(
445
- (selector) => {
446
- const popup = document.querySelector(selector);
447
- return popup && getComputedStyle(popup).display === "none";
448
- },
449
- popupSelector,
450
- { timeout: 3e3 }
451
- ).then(() => true).catch(() => false);
402
+ menuClosed = await test.expect(popupElement).toBeHidden({ timeout: 3e3 }).then(() => true).catch(() => false);
452
403
  }
453
404
  if (!menuClosed && componentContract.selectors.trigger) {
454
405
  const triggerElement = page.locator(componentContract.selectors.trigger).first();
455
406
  await triggerElement.click();
456
- await page.waitForTimeout(500);
457
- menuClosed = await page.waitForFunction(
458
- (selector) => {
459
- const popup = document.querySelector(selector);
460
- return popup && getComputedStyle(popup).display === "none";
461
- },
462
- popupSelector,
463
- { timeout: 3e3 }
464
- ).then(() => true).catch(() => false);
407
+ menuClosed = await test.expect(popupElement).toBeHidden({ timeout: 3e3 }).then(() => true).catch(() => false);
465
408
  }
466
409
  if (!menuClosed) {
467
410
  await page.mouse.click(10, 10);
468
- await page.waitForTimeout(500);
469
- menuClosed = await page.waitForFunction(
470
- (selector) => {
471
- const popup = document.querySelector(selector);
472
- return popup && getComputedStyle(popup).display === "none";
473
- },
474
- popupSelector,
475
- { timeout: 3e3 }
476
- ).then(() => true).catch(() => false);
477
- if (menuClosed) {
478
- console.log("\u{1F3AF} Strategy 3 (Click outside) worked");
479
- }
411
+ menuClosed = await test.expect(popupElement).toBeHidden({ timeout: 3e3 }).then(() => true).catch(() => false);
480
412
  }
481
413
  if (!menuClosed) {
482
414
  throw new Error(
@@ -487,25 +419,12 @@ async function runContractTestsPlaywright(componentName, url) {
487
419
  This indicates a problem with the menu component's close functionality.`
488
420
  );
489
421
  }
490
- if (componentName === "menu" && componentContract.selectors.trigger) {
491
- await page.waitForFunction(
492
- (selector) => {
493
- const trigger = document.querySelector(selector);
494
- return document.activeElement === trigger;
495
- },
496
- componentContract.selectors.trigger,
497
- { timeout: 2e3 }
498
- ).catch(async () => {
499
- const triggerElement = page.locator(componentContract.selectors.trigger).first();
500
- await triggerElement.focus();
501
- await page.waitForTimeout(200);
502
- });
503
- }
504
- await page.waitForTimeout(500);
505
422
  if (componentContract.selectors.input) {
506
- const inputElement = page.locator(componentContract.selectors.input).first();
507
- await inputElement.clear();
508
- await page.waitForTimeout(100);
423
+ await page.locator(componentContract.selectors.input).first().clear();
424
+ }
425
+ if (componentName === "menu" && componentContract.selectors.trigger) {
426
+ const triggerElement = page.locator(componentContract.selectors.trigger).first();
427
+ await triggerElement.focus();
509
428
  }
510
429
  }
511
430
  }
@@ -549,7 +468,6 @@ This indicates a problem with the menu component's close functionality.`
549
468
  continue;
550
469
  }
551
470
  await page.locator(focusSelector).first().focus();
552
- await page.waitForTimeout(100);
553
471
  }
554
472
  if (act.type === "type" && act.value) {
555
473
  const typeSelector = componentContract.selectors[act.target];
@@ -558,7 +476,6 @@ This indicates a problem with the menu component's close functionality.`
558
476
  continue;
559
477
  }
560
478
  await page.locator(typeSelector).first().fill(act.value);
561
- await page.waitForTimeout(100);
562
479
  }
563
480
  if (act.type === "click") {
564
481
  if (act.target === "document") {
@@ -575,7 +492,6 @@ This indicates a problem with the menu component's close functionality.`
575
492
  continue;
576
493
  }
577
494
  await relativeElement.click();
578
- await page.waitForTimeout(componentName === "menu" ? 800 : 200);
579
495
  } else {
580
496
  const actionSelector = componentContract.selectors[act.target];
581
497
  if (!actionSelector) {
@@ -583,7 +499,6 @@ This indicates a problem with the menu component's close functionality.`
583
499
  continue;
584
500
  }
585
501
  await page.locator(actionSelector).first().click();
586
- await page.waitForTimeout(componentName === "menu" ? 800 : 200);
587
502
  }
588
503
  }
589
504
  if (act.type === "keypress" && act.key) {
@@ -606,9 +521,7 @@ This indicates a problem with the menu component's close functionality.`
606
521
  keyValue = keyValue.replace(/ /g, "");
607
522
  }
608
523
  if (act.target === "focusable" && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Escape"].includes(keyValue)) {
609
- await page.waitForTimeout(componentName === "menu" ? 200 : 100);
610
524
  await page.keyboard.press(keyValue);
611
- await page.waitForTimeout(componentName === "menu" ? 300 : 100);
612
525
  } else {
613
526
  const keypressSelector = componentContract.selectors[act.target];
614
527
  if (!keypressSelector) {
@@ -637,7 +550,6 @@ This indicates a problem with the menu component's close functionality.`
637
550
  continue;
638
551
  }
639
552
  await relativeElement.hover();
640
- await page.waitForTimeout(100);
641
553
  } else {
642
554
  const hoverSelector = componentContract.selectors[act.target];
643
555
  if (!hoverSelector) {
@@ -645,12 +557,9 @@ This indicates a problem with the menu component's close functionality.`
645
557
  continue;
646
558
  }
647
559
  await page.locator(hoverSelector).first().hover();
648
- await page.waitForTimeout(100);
649
560
  }
650
561
  }
651
- await page.waitForTimeout(componentName === "menu" ? 200 : 100);
652
562
  }
653
- await page.waitForTimeout(componentName === "menu" ? 300 : 100);
654
563
  for (const assertion of assertions) {
655
564
  let target;
656
565
  if (assertion.target === "relative") {
@@ -679,7 +588,7 @@ This indicates a problem with the menu component's close functionality.`
679
588
  }
680
589
  if (assertion.assertion === "toBeVisible") {
681
590
  try {
682
- await (0, test_exports.expect)(target).toBeVisible({ timeout: 3e3 });
591
+ await test.expect(target).toBeVisible({ timeout: 3e3 });
683
592
  passes.push(`${assertion.target} is visible as expected. Test: "${dynamicTest.description}".`);
684
593
  } catch {
685
594
  const debugState = await page.evaluate((sel) => {
@@ -693,7 +602,7 @@ This indicates a problem with the menu component's close functionality.`
693
602
  }
694
603
  if (assertion.assertion === "notToBeVisible") {
695
604
  try {
696
- await (0, test_exports.expect)(target).toBeHidden({ timeout: 5e3 });
605
+ await test.expect(target).toBeHidden({ timeout: 5e3 });
697
606
  passes.push(`${assertion.target} is not visible as expected. Test: "${dynamicTest.description}".`);
698
607
  } catch {
699
608
  const debugState = await page.evaluate((sel) => {
@@ -715,7 +624,7 @@ This indicates a problem with the menu component's close functionality.`
715
624
  failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should not be empty, found "${attributeValue}".`);
716
625
  }
717
626
  } else {
718
- await (0, test_exports.expect)(target).toHaveAttribute(assertion.attribute, assertion.expectedValue, { timeout: 3e3 });
627
+ await test.expect(target).toHaveAttribute(assertion.attribute, assertion.expectedValue, { timeout: 3e3 });
719
628
  passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
720
629
  }
721
630
  } catch {
@@ -745,7 +654,7 @@ This indicates a problem with the menu component's close functionality.`
745
654
  }
746
655
  if (assertion.assertion === "toHaveFocus") {
747
656
  try {
748
- await (0, test_exports.expect)(target).toBeFocused({ timeout: 5e3 });
657
+ await test.expect(target).toBeFocused({ timeout: 5e3 });
749
658
  passes.push(`${assertion.target} has focus as expected. Test: "${dynamicTest.description}".`);
750
659
  } catch {
751
660
  const actualFocus = await page.evaluate(() => {
@@ -801,7 +710,6 @@ This indicates a problem with the menu component's close functionality.`
801
710
  }
802
711
  var init_contractTestRunnerPlaywright = __esm({
803
712
  "src/utils/test/contract/contractTestRunnerPlaywright.ts"() {
804
- init_test();
805
713
  init_contract();
806
714
  init_ContractReporter();
807
715
  }
@@ -1,4 +1,4 @@
1
- import { ContractReporter, contract_default } from './chunk-AVCZIF6G.js';
1
+ import { ContractReporter, contract_default } from './chunk-TUWQNVQJ.js';
2
2
  import { axe } from 'jest-axe';
3
3
  import fs from 'fs/promises';
4
4
 
@@ -109,7 +109,7 @@ Error: ${error instanceof Error ? error.message : String(error)}`
109
109
  const devServerUrl = await checkDevServer(url);
110
110
  if (devServerUrl) {
111
111
  console.log(`\u{1F3AD} Running Playwright E2E tests on ${devServerUrl}`);
112
- const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-BFHRDJTJ.js');
112
+ const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-P5QZAIDR.js');
113
113
  contract = await runContractTestsPlaywright(componentName, devServerUrl);
114
114
  } else {
115
115
  console.log(`\u{1F9EA} Running jsdom tests (limited event handling)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aria-ease",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "Out-of-the-box accessibility utility package to develop production ready applications.",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "clean": "rm -rf dist bin",
20
20
  "build:core": "tsup ./index.ts --format esm,cjs --dts --outDir dist --external jest-axe --external @testing-library/react --external @axe-core/playwright --external playwright",
21
21
  "build:modules": "tsup ./src/combobox/index.ts ./src/accordion/index.ts ./src/block/index.ts ./src/checkbox/index.ts ./src/menu/index.ts ./src/radio/index.ts ./src/toggle/index.ts --format esm,cjs --dts --treeshake --outDir dist/src",
22
- "build:test": "tsup ./src/utils/test/index.ts --format esm,cjs --dts --treeshake --external jest-axe --external @testing-library/react --outDir dist/src/utils/test",
22
+ "build:test": "tsup ./src/utils/test/index.ts --format esm,cjs --dts --treeshake --external jest-axe --external @testing-library/react --external playwright --external @playwright/test --outDir dist/src/utils/test",
23
23
  "build:cli": "tsup ./src/utils/cli/cli.ts --format esm,cjs --dts --outDir bin --external commander --external chalk --external jest-axe --external @testing-library/react --external @axe-core/playwright --external playwright",
24
24
  "build:contracts": "mkdir -p ./dist/src/utils/test && cp -r ./src/utils/test/contract/contracts ./dist/src/utils/test/",
25
25
  "build": "npm run clean && npm run build:core && npm run build:modules && npm run build:test && npm run build:cli && npm run build:contracts"