aria-ease 4.0.1 → 5.0.1

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.
Files changed (44) hide show
  1. package/README.md +22 -24
  2. package/bin/cli.cjs +85 -13
  3. package/bin/cli.js +1 -1
  4. package/bin/{contractTestRunnerPlaywright-EZLNNJV5.js → contractTestRunnerPlaywright-YPBTKJP7.js} +85 -13
  5. package/bin/{test-45KMD4F4.js → test-TAH4VGZV.js} +1 -1
  6. package/dist/{contractTestRunnerPlaywright-UQQI5MYS.js → contractTestRunnerPlaywright-45CFWUOD.js} +85 -13
  7. package/dist/index.cjs +97 -157
  8. package/dist/index.d.cts +1 -57
  9. package/dist/index.d.ts +1 -57
  10. package/dist/index.js +12 -140
  11. package/dist/src/{Types.d-BrHSyS03.d.ts → Types.d-COr5IFp5.d.cts} +1 -17
  12. package/dist/src/{Types.d-BrHSyS03.d.cts → Types.d-COr5IFp5.d.ts} +1 -17
  13. package/dist/src/accordion/index.cjs +0 -27
  14. package/dist/src/accordion/index.d.cts +2 -12
  15. package/dist/src/accordion/index.d.ts +2 -12
  16. package/dist/src/accordion/index.js +1 -27
  17. package/dist/src/block/index.d.cts +1 -1
  18. package/dist/src/block/index.d.ts +1 -1
  19. package/dist/src/checkbox/index.cjs +0 -32
  20. package/dist/src/checkbox/index.d.cts +2 -12
  21. package/dist/src/checkbox/index.d.ts +2 -12
  22. package/dist/src/checkbox/index.js +1 -32
  23. package/dist/src/combobox/index.cjs +1 -1
  24. package/dist/src/combobox/index.d.cts +1 -1
  25. package/dist/src/combobox/index.d.ts +1 -1
  26. package/dist/src/combobox/index.js +1 -1
  27. package/dist/src/menu/index.cjs +9 -18
  28. package/dist/src/menu/index.d.cts +1 -1
  29. package/dist/src/menu/index.d.ts +1 -1
  30. package/dist/src/menu/index.js +9 -18
  31. package/dist/src/radio/index.cjs +0 -31
  32. package/dist/src/radio/index.d.cts +2 -12
  33. package/dist/src/radio/index.d.ts +2 -12
  34. package/dist/src/radio/index.js +1 -31
  35. package/dist/src/toggle/index.cjs +0 -28
  36. package/dist/src/toggle/index.d.cts +2 -12
  37. package/dist/src/toggle/index.d.ts +2 -12
  38. package/dist/src/toggle/index.js +1 -28
  39. package/dist/src/utils/test/{contractTestRunnerPlaywright-UQQI5MYS.js → contractTestRunnerPlaywright-45CFWUOD.js} +85 -13
  40. package/dist/src/utils/test/contracts/AccordionContract.json +55 -0
  41. package/dist/src/utils/test/contracts/MenuContract.json +1 -1
  42. package/dist/src/utils/test/index.cjs +85 -13
  43. package/dist/src/utils/test/index.js +1 -1
  44. package/package.json +1 -1
@@ -9310,10 +9310,11 @@ async function runContractTestsPlaywright(componentName, url) {
9310
9310
  return trigger && trigger.getAttribute("data-menu-initialized") === "true";
9311
9311
  },
9312
9312
  componentContract.selectors.trigger,
9313
- { timeout: 6e3 }
9313
+ { timeout: 1e4 }
9314
9314
  ).catch(() => {
9315
9315
  console.warn("Menu initialization signal not detected, continuing with tests...");
9316
9316
  });
9317
+ await page.waitForTimeout(300);
9317
9318
  }
9318
9319
  async function resolveRelativeTarget(selector, relative) {
9319
9320
  const items = await page.locator(selector).all();
@@ -9391,18 +9392,84 @@ async function runContractTestsPlaywright(componentName, url) {
9391
9392
  const popupElement = page.locator(popupSelector).first();
9392
9393
  const isPopupVisible = await popupElement.isVisible();
9393
9394
  if (isPopupVisible) {
9394
- const closeSelector = componentContract.selectors.input || componentContract.selectors.trigger;
9395
+ let menuClosed = false;
9396
+ let closeSelector = componentContract.selectors.input;
9397
+ if (!closeSelector && componentContract.selectors.focusable) {
9398
+ closeSelector = componentContract.selectors.focusable;
9399
+ } else if (!closeSelector) {
9400
+ closeSelector = componentContract.selectors.trigger;
9401
+ }
9395
9402
  if (closeSelector) {
9396
9403
  const closeElement = page.locator(closeSelector).first();
9397
9404
  await closeElement.focus();
9398
- await page.keyboard.press("Escape");
9399
9405
  await page.waitForTimeout(200);
9400
- if (componentContract.selectors.input) {
9401
- const inputElement = page.locator(componentContract.selectors.input).first();
9402
- await inputElement.clear();
9403
- await page.waitForTimeout(100);
9406
+ await page.keyboard.press("Escape");
9407
+ menuClosed = await page.waitForFunction(
9408
+ (selector) => {
9409
+ const popup = document.querySelector(selector);
9410
+ return popup && getComputedStyle(popup).display === "none";
9411
+ },
9412
+ popupSelector,
9413
+ { timeout: 3e3 }
9414
+ ).then(() => true).catch(() => false);
9415
+ }
9416
+ if (!menuClosed && componentContract.selectors.trigger) {
9417
+ const triggerElement = page.locator(componentContract.selectors.trigger).first();
9418
+ await triggerElement.click();
9419
+ await page.waitForTimeout(500);
9420
+ menuClosed = await page.waitForFunction(
9421
+ (selector) => {
9422
+ const popup = document.querySelector(selector);
9423
+ return popup && getComputedStyle(popup).display === "none";
9424
+ },
9425
+ popupSelector,
9426
+ { timeout: 3e3 }
9427
+ ).then(() => true).catch(() => false);
9428
+ }
9429
+ if (!menuClosed) {
9430
+ await page.mouse.click(10, 10);
9431
+ await page.waitForTimeout(500);
9432
+ menuClosed = await page.waitForFunction(
9433
+ (selector) => {
9434
+ const popup = document.querySelector(selector);
9435
+ return popup && getComputedStyle(popup).display === "none";
9436
+ },
9437
+ popupSelector,
9438
+ { timeout: 3e3 }
9439
+ ).then(() => true).catch(() => false);
9440
+ if (menuClosed) {
9441
+ console.log("\u{1F3AF} Strategy 3 (Click outside) worked");
9404
9442
  }
9405
9443
  }
9444
+ if (!menuClosed) {
9445
+ throw new Error(
9446
+ `\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
9447
+ 1. Escape key
9448
+ 2. Clicking trigger
9449
+ 3. Clicking outside
9450
+ This indicates a problem with the menu component's close functionality.`
9451
+ );
9452
+ }
9453
+ if (componentName === "menu" && componentContract.selectors.trigger) {
9454
+ await page.waitForFunction(
9455
+ (selector) => {
9456
+ const trigger = document.querySelector(selector);
9457
+ return document.activeElement === trigger;
9458
+ },
9459
+ componentContract.selectors.trigger,
9460
+ { timeout: 2e3 }
9461
+ ).catch(async () => {
9462
+ const triggerElement = page.locator(componentContract.selectors.trigger).first();
9463
+ await triggerElement.focus();
9464
+ await page.waitForTimeout(200);
9465
+ });
9466
+ }
9467
+ await page.waitForTimeout(500);
9468
+ if (componentContract.selectors.input) {
9469
+ const inputElement = page.locator(componentContract.selectors.input).first();
9470
+ await inputElement.clear();
9471
+ await page.waitForTimeout(100);
9472
+ }
9406
9473
  }
9407
9474
  }
9408
9475
  let shouldSkipTest = false;
@@ -9471,7 +9538,7 @@ async function runContractTestsPlaywright(componentName, url) {
9471
9538
  continue;
9472
9539
  }
9473
9540
  await relativeElement.click();
9474
- await page.waitForTimeout(componentName === "menu" ? 500 : 200);
9541
+ await page.waitForTimeout(componentName === "menu" ? 800 : 200);
9475
9542
  } else {
9476
9543
  const actionSelector = componentContract.selectors[act.target];
9477
9544
  if (!actionSelector) {
@@ -9479,7 +9546,7 @@ async function runContractTestsPlaywright(componentName, url) {
9479
9546
  continue;
9480
9547
  }
9481
9548
  await page.locator(actionSelector).first().click();
9482
- await page.waitForTimeout(componentName === "menu" ? 500 : 200);
9549
+ await page.waitForTimeout(componentName === "menu" ? 800 : 200);
9483
9550
  }
9484
9551
  }
9485
9552
  if (act.type === "keypress" && act.key) {
@@ -9502,9 +9569,9 @@ async function runContractTestsPlaywright(componentName, url) {
9502
9569
  keyValue = keyValue.replace(/ /g, "");
9503
9570
  }
9504
9571
  if (act.target === "focusable" && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Escape"].includes(keyValue)) {
9505
- await page.waitForTimeout(100);
9572
+ await page.waitForTimeout(componentName === "menu" ? 200 : 100);
9506
9573
  await page.keyboard.press(keyValue);
9507
- await page.waitForTimeout(100);
9574
+ await page.waitForTimeout(componentName === "menu" ? 300 : 100);
9508
9575
  } else {
9509
9576
  const keypressSelector = componentContract.selectors[act.target];
9510
9577
  if (!keypressSelector) {
@@ -9544,8 +9611,9 @@ async function runContractTestsPlaywright(componentName, url) {
9544
9611
  await page.waitForTimeout(100);
9545
9612
  }
9546
9613
  }
9547
- await page.waitForTimeout(100);
9614
+ await page.waitForTimeout(componentName === "menu" ? 200 : 100);
9548
9615
  }
9616
+ await page.waitForTimeout(componentName === "menu" ? 300 : 100);
9549
9617
  for (const assertion of assertions) {
9550
9618
  let target;
9551
9619
  if (assertion.target === "relative") {
@@ -9643,7 +9711,11 @@ async function runContractTestsPlaywright(componentName, url) {
9643
9711
  await (0, test_exports.expect)(target).toBeFocused({ timeout: 5e3 });
9644
9712
  passes.push(`${assertion.target} has focus as expected. Test: "${dynamicTest.description}".`);
9645
9713
  } catch {
9646
- failures.push(`${assertion.failureMessage}`);
9714
+ const actualFocus = await page.evaluate(() => {
9715
+ const focused = document.activeElement;
9716
+ return focused ? `${focused.tagName}#${focused.id || "no-id"}.${focused.className || "no-class"}` : "no element focused";
9717
+ });
9718
+ failures.push(`${assertion.failureMessage} (actual focus: ${actualFocus})`);
9647
9719
  }
9648
9720
  }
9649
9721
  if (assertion.assertion === "toHaveRole" && assertion.expectedValue) {
@@ -12580,7 +12580,7 @@ Error: ${error instanceof Error ? error.message : String(error)}`
12580
12580
  URL must include protocol (e.g., "http://localhost:5173/test")`
12581
12581
  );
12582
12582
  }
12583
- const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-UQQI5MYS.js');
12583
+ const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-45CFWUOD.js');
12584
12584
  contract = await runContractTestsPlaywright(componentName, url);
12585
12585
  } else {
12586
12586
  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": "4.0.1",
3
+ "version": "5.0.1",
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",