aria-ease 6.10.0 → 6.11.0
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.
- package/README.md +1 -1
- package/{bin/buildContracts-S22V7AGV.js → dist/buildContracts-FT6KWUJN.js} +3 -3
- package/{bin → dist}/cli.cjs +4 -4
- package/{bin → dist}/cli.js +1 -1
- package/dist/index.cjs +132 -56
- package/dist/index.js +132 -56
- package/dist/src/{Types.d-yGC2bBaB.d.ts → Types.d-DYfYR3Vc.d.cts} +1 -1
- package/dist/src/{Types.d-yGC2bBaB.d.cts → Types.d-DYfYR3Vc.d.ts} +1 -1
- package/dist/src/accordion/index.d.cts +1 -1
- package/dist/src/accordion/index.d.ts +1 -1
- package/dist/src/block/index.d.cts +1 -1
- package/dist/src/block/index.d.ts +1 -1
- package/dist/src/checkbox/index.d.cts +1 -1
- package/dist/src/checkbox/index.d.ts +1 -1
- package/dist/src/combobox/index.d.cts +1 -1
- package/dist/src/combobox/index.d.ts +1 -1
- package/dist/src/menu/index.d.cts +1 -1
- package/dist/src/menu/index.d.ts +1 -1
- package/dist/src/radio/index.d.cts +1 -1
- package/dist/src/radio/index.d.ts +1 -1
- package/dist/src/tabs/index.d.cts +1 -1
- package/dist/src/tabs/index.d.ts +1 -1
- package/dist/src/toggle/index.d.cts +1 -1
- package/dist/src/toggle/index.d.ts +1 -1
- package/dist/src/utils/test/dsl/index.cjs +132 -56
- package/dist/src/utils/test/dsl/index.js +132 -56
- package/package.json +4 -5
- package/bin/AccordionComponentStrategy-4ZEIQ2V6.js +0 -42
- package/bin/ComboboxComponentStrategy-OGRVZXAF.js +0 -64
- package/bin/MenuComponentStrategy-JAMTCSNF.js +0 -81
- package/bin/TabsComponentStrategy-3SQURPMX.js +0 -29
- package/bin/chunk-I2KLQ2HA.js +0 -22
- package/bin/chunk-PK5L2SAF.js +0 -17
- package/bin/chunk-XERMSYEH.js +0 -363
- /package/{bin → dist}/audit-RM6TCZ5C.js +0 -0
- /package/{bin → dist}/badgeHelper-JOWO6RQG.js +0 -0
- /package/{bin → dist}/chunk-JJEPLK7L.js +0 -0
- /package/{bin → dist}/chunk-NI3MQCAS.js +0 -0
- /package/{bin → dist}/cli.d.cts +0 -0
- /package/{bin → dist}/cli.d.ts +0 -0
- /package/{bin → dist}/configLoader-UJZHQBYS.js +0 -0
- /package/{bin → dist}/contractTestRunnerPlaywright-QDXSK3FE.js +0 -0
- /package/{bin → dist}/formatters-32KQIIYS.js +0 -0
- /package/{bin → dist}/test-O3J4ZPQR.js +0 -0
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ npx aria-ease audit --url https://yoursite.com
|
|
|
60
60
|
|
|
61
61
|
#### 3. **Contract Testing** (Available Now)
|
|
62
62
|
|
|
63
|
-
This is the game-changer.
|
|
63
|
+
This is the game-changer. Encode a deterministic, testable interpretation of WAI-ARIA APG guidance into JSON "contracts" using Aria-Ease DSL API, and validate your contract against your component using Aria-Ease's Playwright runner with isolated test-harness architecture. Run it locally or in CI/CD.
|
|
64
64
|
|
|
65
65
|
Teams and experts can enforce their own standards and maintain reusability and consistency.
|
|
66
66
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./chunk-I2KLQ2HA.js";
|
|
2
2
|
|
|
3
|
-
// src/utils/
|
|
3
|
+
// src/utils/test/dsl/src/buildContracts.ts
|
|
4
4
|
import path from "path";
|
|
5
5
|
import fs from "fs-extra";
|
|
6
6
|
import { glob } from "fs/promises";
|
|
7
7
|
import chalk from "chalk";
|
|
8
8
|
|
|
9
|
-
// src/utils/
|
|
9
|
+
// src/utils/test/dsl/src/contractValidator.ts
|
|
10
10
|
function validateContractSchema(contract) {
|
|
11
11
|
const errors = [];
|
|
12
12
|
if (!contract || typeof contract !== "object") {
|
|
@@ -348,7 +348,7 @@ function validateTargetReferences(contract, selectorKeys) {
|
|
|
348
348
|
return errors;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
// src/utils/
|
|
351
|
+
// src/utils/test/dsl/src/buildContracts.ts
|
|
352
352
|
async function buildContracts(cwd, config) {
|
|
353
353
|
const errors = [];
|
|
354
354
|
const built = [];
|
package/{bin → dist}/cli.cjs
RENAMED
|
@@ -2865,7 +2865,7 @@ var init_test3 = __esm({
|
|
|
2865
2865
|
}
|
|
2866
2866
|
});
|
|
2867
2867
|
|
|
2868
|
-
// src/utils/
|
|
2868
|
+
// src/utils/test/dsl/src/contractValidator.ts
|
|
2869
2869
|
function validateContractSchema(contract) {
|
|
2870
2870
|
const errors = [];
|
|
2871
2871
|
if (!contract || typeof contract !== "object") {
|
|
@@ -3207,12 +3207,12 @@ function validateTargetReferences(contract, selectorKeys) {
|
|
|
3207
3207
|
return errors;
|
|
3208
3208
|
}
|
|
3209
3209
|
var init_contractValidator = __esm({
|
|
3210
|
-
"src/utils/
|
|
3210
|
+
"src/utils/test/dsl/src/contractValidator.ts"() {
|
|
3211
3211
|
"use strict";
|
|
3212
3212
|
}
|
|
3213
3213
|
});
|
|
3214
3214
|
|
|
3215
|
-
// src/utils/
|
|
3215
|
+
// src/utils/test/dsl/src/buildContracts.ts
|
|
3216
3216
|
var buildContracts_exports = {};
|
|
3217
3217
|
__export(buildContracts_exports, {
|
|
3218
3218
|
buildContracts: () => buildContracts
|
|
@@ -3330,7 +3330,7 @@ ${errorLines}`;
|
|
|
3330
3330
|
}
|
|
3331
3331
|
var import_path7, import_fs_extra3, import_promises2, import_chalk2;
|
|
3332
3332
|
var init_buildContracts = __esm({
|
|
3333
|
-
"src/utils/
|
|
3333
|
+
"src/utils/test/dsl/src/buildContracts.ts"() {
|
|
3334
3334
|
"use strict";
|
|
3335
3335
|
import_path7 = __toESM(require("path"), 1);
|
|
3336
3336
|
import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
package/{bin → dist}/cli.js
RENAMED
|
@@ -127,7 +127,7 @@ program.command("test").description("Run core a11y accessibility standard tests
|
|
|
127
127
|
});
|
|
128
128
|
program.command("build").description("Build accessibility artifacts").addCommand(
|
|
129
129
|
new Command("contracts").description("Build DSL contracts to JSON").action(async () => {
|
|
130
|
-
const { buildContracts } = await import("./buildContracts-
|
|
130
|
+
const { buildContracts } = await import("./buildContracts-FT6KWUJN.js");
|
|
131
131
|
const { loadConfig: loadConfig2 } = await import("./configLoader-UJZHQBYS.js");
|
|
132
132
|
const cwd = process.cwd();
|
|
133
133
|
const { config, configPath, errors } = await loadConfig2(cwd);
|
package/dist/index.cjs
CHANGED
|
@@ -3761,90 +3761,141 @@ function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation
|
|
|
3761
3761
|
}
|
|
3762
3762
|
|
|
3763
3763
|
// src/utils/test/dsl/src/state-packs/comboboxStatePack.ts
|
|
3764
|
+
function hasCapabilities(ctx, requiredCaps) {
|
|
3765
|
+
return requiredCaps.some((cap) => ctx.capabilities.includes(cap));
|
|
3766
|
+
}
|
|
3767
|
+
function resolveSetup(setup, ctx) {
|
|
3768
|
+
if (Array.isArray(setup) && setup.length && !setup[0].when) {
|
|
3769
|
+
setup = [{ when: ["keyboard"], steps: () => setup }];
|
|
3770
|
+
}
|
|
3771
|
+
for (const strat of setup) {
|
|
3772
|
+
if (hasCapabilities(ctx, strat.when)) {
|
|
3773
|
+
return strat.steps(ctx);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
throw new Error(
|
|
3777
|
+
`No setup strategy matches capabilities: ${ctx.capabilities.join(", ")}`
|
|
3778
|
+
);
|
|
3779
|
+
}
|
|
3764
3780
|
var COMBOBOX_STATES = {
|
|
3765
3781
|
"listbox.open": {
|
|
3766
|
-
setup:
|
|
3767
|
-
|
|
3782
|
+
setup: [
|
|
3783
|
+
{
|
|
3784
|
+
when: ["keyboard", "textInput"],
|
|
3785
|
+
steps: () => [
|
|
3786
|
+
{ type: "keypress", target: "input", key: "ArrowDown" }
|
|
3787
|
+
]
|
|
3788
|
+
},
|
|
3789
|
+
{
|
|
3790
|
+
when: ["pointer"],
|
|
3791
|
+
steps: () => [
|
|
3792
|
+
{ type: "click", target: "button" }
|
|
3793
|
+
]
|
|
3794
|
+
}
|
|
3795
|
+
],
|
|
3796
|
+
assertion: isComboboxOpen
|
|
3768
3797
|
},
|
|
3769
3798
|
"listbox.closed": {
|
|
3770
|
-
setup:
|
|
3771
|
-
|
|
3799
|
+
setup: [
|
|
3800
|
+
{
|
|
3801
|
+
when: ["keyboard"],
|
|
3802
|
+
steps: () => [
|
|
3803
|
+
/* { type: "keypress", target: "input", key: "Escape" } */
|
|
3804
|
+
]
|
|
3805
|
+
},
|
|
3806
|
+
{
|
|
3807
|
+
when: ["pointer"],
|
|
3808
|
+
steps: () => [
|
|
3809
|
+
/* { type: "click", target: "button" } */
|
|
3810
|
+
]
|
|
3811
|
+
}
|
|
3812
|
+
],
|
|
3813
|
+
assertion: isComboboxClosed
|
|
3772
3814
|
},
|
|
3773
3815
|
"input.focused": {
|
|
3774
|
-
setup:
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3816
|
+
setup: [
|
|
3817
|
+
{
|
|
3818
|
+
when: ["keyboard"],
|
|
3819
|
+
steps: () => [
|
|
3820
|
+
{ type: "focus", target: "input" }
|
|
3821
|
+
]
|
|
3822
|
+
}
|
|
3823
|
+
],
|
|
3824
|
+
assertion: isInputFocused
|
|
3778
3825
|
},
|
|
3779
3826
|
"input.filled": {
|
|
3780
|
-
setup:
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3827
|
+
setup: [
|
|
3828
|
+
{
|
|
3829
|
+
when: ["keyboard", "textInput"],
|
|
3830
|
+
steps: () => [
|
|
3831
|
+
{ type: "type", target: "input", value: "test" }
|
|
3832
|
+
]
|
|
3833
|
+
}
|
|
3834
|
+
],
|
|
3835
|
+
assertion: isInputFilled
|
|
3784
3836
|
},
|
|
3785
3837
|
"activeOption.first": {
|
|
3786
3838
|
requires: ["listbox.open"],
|
|
3787
3839
|
setup: [
|
|
3788
|
-
{
|
|
3840
|
+
{
|
|
3841
|
+
when: ["keyboard"],
|
|
3842
|
+
steps: () => [
|
|
3843
|
+
{ type: "keypress", target: "input", key: "ArrowDown" }
|
|
3844
|
+
]
|
|
3845
|
+
}
|
|
3789
3846
|
],
|
|
3790
|
-
assertion:
|
|
3791
|
-
...isActiveDescendantNotEmpty()
|
|
3792
|
-
]
|
|
3847
|
+
assertion: isActiveDescendantNotEmpty
|
|
3793
3848
|
},
|
|
3794
3849
|
"activeOption.last": {
|
|
3795
3850
|
requires: ["activeOption.first"],
|
|
3796
3851
|
setup: [
|
|
3797
|
-
{
|
|
3852
|
+
{
|
|
3853
|
+
when: ["keyboard"],
|
|
3854
|
+
steps: () => [
|
|
3855
|
+
{ type: "keypress", target: "input", key: "ArrowUp" }
|
|
3856
|
+
]
|
|
3857
|
+
}
|
|
3798
3858
|
],
|
|
3799
|
-
assertion:
|
|
3800
|
-
...isActiveDescendantNotEmpty()
|
|
3801
|
-
]
|
|
3859
|
+
assertion: isActiveDescendantNotEmpty
|
|
3802
3860
|
},
|
|
3803
3861
|
"selectedOption.first": {
|
|
3804
3862
|
requires: ["listbox.open"],
|
|
3805
3863
|
setup: [
|
|
3806
|
-
{
|
|
3864
|
+
{
|
|
3865
|
+
when: ["pointer"],
|
|
3866
|
+
steps: () => [
|
|
3867
|
+
{ type: "click", target: "relative", relativeTarget: "first" }
|
|
3868
|
+
]
|
|
3869
|
+
}
|
|
3807
3870
|
],
|
|
3808
|
-
assertion:
|
|
3809
|
-
...isAriaSelected("first")
|
|
3810
|
-
]
|
|
3871
|
+
assertion: () => isAriaSelected("first")
|
|
3811
3872
|
},
|
|
3812
3873
|
"selectedOption.last": {
|
|
3813
3874
|
requires: ["listbox.open"],
|
|
3814
3875
|
setup: [
|
|
3815
|
-
{
|
|
3876
|
+
{
|
|
3877
|
+
when: ["pointer"],
|
|
3878
|
+
steps: () => [
|
|
3879
|
+
{ type: "click", target: "relative", relativeTarget: "last" }
|
|
3880
|
+
]
|
|
3881
|
+
}
|
|
3816
3882
|
],
|
|
3817
|
-
assertion:
|
|
3818
|
-
...isAriaSelected("first")
|
|
3819
|
-
]
|
|
3883
|
+
assertion: () => isAriaSelected("last")
|
|
3820
3884
|
}
|
|
3821
3885
|
};
|
|
3822
|
-
function openCombobox() {
|
|
3823
|
-
return [
|
|
3824
|
-
{ type: "keypress", target: "input", key: "ArrowDown" }
|
|
3825
|
-
];
|
|
3826
|
-
}
|
|
3827
|
-
function closeCombobox() {
|
|
3828
|
-
return [
|
|
3829
|
-
{ type: "keypress", target: "input", key: "Escape" }
|
|
3830
|
-
];
|
|
3831
|
-
}
|
|
3832
|
-
function focusInput() {
|
|
3833
|
-
return [
|
|
3834
|
-
{ type: "focus", target: "input" }
|
|
3835
|
-
];
|
|
3836
|
-
}
|
|
3837
|
-
function fillInput() {
|
|
3838
|
-
return [
|
|
3839
|
-
{ type: "type", target: "input", value: "test" }
|
|
3840
|
-
];
|
|
3841
|
-
}
|
|
3842
3886
|
function isComboboxOpen() {
|
|
3843
3887
|
return [
|
|
3844
3888
|
{
|
|
3845
3889
|
target: "listbox",
|
|
3846
3890
|
assertion: "toBeVisible",
|
|
3847
3891
|
failureMessage: "Expected listbox to be visible"
|
|
3892
|
+
},
|
|
3893
|
+
{
|
|
3894
|
+
target: "input",
|
|
3895
|
+
assertion: "toHaveAttribute",
|
|
3896
|
+
attribute: "aria-expanded",
|
|
3897
|
+
expectedValue: "true",
|
|
3898
|
+
failureMessage: "Expect combobox input to have aria-expanded='true'"
|
|
3848
3899
|
}
|
|
3849
3900
|
];
|
|
3850
3901
|
}
|
|
@@ -3854,6 +3905,13 @@ function isComboboxClosed() {
|
|
|
3854
3905
|
target: "listbox",
|
|
3855
3906
|
assertion: "notToBeVisible",
|
|
3856
3907
|
failureMessage: "Expected listbox to be closed"
|
|
3908
|
+
},
|
|
3909
|
+
{
|
|
3910
|
+
target: "input",
|
|
3911
|
+
assertion: "toHaveAttribute",
|
|
3912
|
+
attribute: "aria-expanded",
|
|
3913
|
+
expectedValue: "false",
|
|
3914
|
+
failureMessage: "Expect combobox input to have aria-expanded='false'"
|
|
3857
3915
|
}
|
|
3858
3916
|
];
|
|
3859
3917
|
}
|
|
@@ -3876,7 +3934,7 @@ function isAriaSelected(index) {
|
|
|
3876
3934
|
assertion: "toHaveAttribute",
|
|
3877
3935
|
attribute: "aria-selected",
|
|
3878
3936
|
expectedValue: "true",
|
|
3879
|
-
failureMessage: `Expected
|
|
3937
|
+
failureMessage: `Expected ${index} option to have aria-selected='true'`
|
|
3880
3938
|
}
|
|
3881
3939
|
];
|
|
3882
3940
|
}
|
|
@@ -4022,7 +4080,17 @@ var DynamicTestBuilder = class {
|
|
|
4022
4080
|
return this.parent;
|
|
4023
4081
|
}
|
|
4024
4082
|
_finalize() {
|
|
4025
|
-
const
|
|
4083
|
+
const capabilityMap = {
|
|
4084
|
+
keypress: "keyboard",
|
|
4085
|
+
click: "pointer",
|
|
4086
|
+
type: "textInput",
|
|
4087
|
+
focus: "keyboard",
|
|
4088
|
+
hover: "pointer"
|
|
4089
|
+
// add more mappings as needed
|
|
4090
|
+
};
|
|
4091
|
+
const capability = capabilityMap[this._as || "keyboard"] || (this._as || "keyboard");
|
|
4092
|
+
const ctx = { capabilities: [capability] };
|
|
4093
|
+
const resolveAllSetups = (stateName, visited = /* @__PURE__ */ new Set()) => {
|
|
4026
4094
|
if (visited.has(stateName)) return [];
|
|
4027
4095
|
visited.add(stateName);
|
|
4028
4096
|
const s = this.statePack[stateName];
|
|
@@ -4030,22 +4098,30 @@ var DynamicTestBuilder = class {
|
|
|
4030
4098
|
let actions = [];
|
|
4031
4099
|
if (Array.isArray(s.requires)) {
|
|
4032
4100
|
for (const req of s.requires) {
|
|
4033
|
-
actions = actions.concat(
|
|
4101
|
+
actions = actions.concat(resolveAllSetups(req, visited));
|
|
4034
4102
|
}
|
|
4035
4103
|
}
|
|
4036
|
-
if (s.setup) actions = actions.concat(s.setup);
|
|
4104
|
+
if (s.setup) actions = actions.concat(resolveSetup(s.setup, ctx));
|
|
4037
4105
|
return actions;
|
|
4038
4106
|
};
|
|
4039
4107
|
const setup = [];
|
|
4040
4108
|
for (const state of this._given) {
|
|
4041
|
-
setup.push(...
|
|
4109
|
+
setup.push(...resolveAllSetups(state));
|
|
4042
4110
|
}
|
|
4043
4111
|
const assertions = [];
|
|
4044
4112
|
for (const state of this._then) {
|
|
4045
4113
|
const s = this.statePack[state];
|
|
4046
|
-
if (s && s.assertion) {
|
|
4047
|
-
|
|
4048
|
-
|
|
4114
|
+
if (s && s.assertion !== void 0) {
|
|
4115
|
+
let value = s.assertion;
|
|
4116
|
+
if (typeof value === "function") {
|
|
4117
|
+
try {
|
|
4118
|
+
value = value();
|
|
4119
|
+
} catch (e) {
|
|
4120
|
+
throw new Error(`Error calling assertion function for state '${state}': ${e.message}`);
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
if (Array.isArray(value)) assertions.push(...value);
|
|
4124
|
+
else assertions.push(value);
|
|
4049
4125
|
}
|
|
4050
4126
|
}
|
|
4051
4127
|
const action = [
|
package/dist/index.js
CHANGED
|
@@ -1509,90 +1509,141 @@ function makeTabsAccessible({ tabListId, tabsClass, tabPanelsClass, orientation
|
|
|
1509
1509
|
}
|
|
1510
1510
|
|
|
1511
1511
|
// src/utils/test/dsl/src/state-packs/comboboxStatePack.ts
|
|
1512
|
+
function hasCapabilities(ctx, requiredCaps) {
|
|
1513
|
+
return requiredCaps.some((cap) => ctx.capabilities.includes(cap));
|
|
1514
|
+
}
|
|
1515
|
+
function resolveSetup(setup, ctx) {
|
|
1516
|
+
if (Array.isArray(setup) && setup.length && !setup[0].when) {
|
|
1517
|
+
setup = [{ when: ["keyboard"], steps: () => setup }];
|
|
1518
|
+
}
|
|
1519
|
+
for (const strat of setup) {
|
|
1520
|
+
if (hasCapabilities(ctx, strat.when)) {
|
|
1521
|
+
return strat.steps(ctx);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
throw new Error(
|
|
1525
|
+
`No setup strategy matches capabilities: ${ctx.capabilities.join(", ")}`
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1512
1528
|
var COMBOBOX_STATES = {
|
|
1513
1529
|
"listbox.open": {
|
|
1514
|
-
setup:
|
|
1515
|
-
|
|
1530
|
+
setup: [
|
|
1531
|
+
{
|
|
1532
|
+
when: ["keyboard", "textInput"],
|
|
1533
|
+
steps: () => [
|
|
1534
|
+
{ type: "keypress", target: "input", key: "ArrowDown" }
|
|
1535
|
+
]
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
when: ["pointer"],
|
|
1539
|
+
steps: () => [
|
|
1540
|
+
{ type: "click", target: "button" }
|
|
1541
|
+
]
|
|
1542
|
+
}
|
|
1543
|
+
],
|
|
1544
|
+
assertion: isComboboxOpen
|
|
1516
1545
|
},
|
|
1517
1546
|
"listbox.closed": {
|
|
1518
|
-
setup:
|
|
1519
|
-
|
|
1547
|
+
setup: [
|
|
1548
|
+
{
|
|
1549
|
+
when: ["keyboard"],
|
|
1550
|
+
steps: () => [
|
|
1551
|
+
/* { type: "keypress", target: "input", key: "Escape" } */
|
|
1552
|
+
]
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
when: ["pointer"],
|
|
1556
|
+
steps: () => [
|
|
1557
|
+
/* { type: "click", target: "button" } */
|
|
1558
|
+
]
|
|
1559
|
+
}
|
|
1560
|
+
],
|
|
1561
|
+
assertion: isComboboxClosed
|
|
1520
1562
|
},
|
|
1521
1563
|
"input.focused": {
|
|
1522
|
-
setup:
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1564
|
+
setup: [
|
|
1565
|
+
{
|
|
1566
|
+
when: ["keyboard"],
|
|
1567
|
+
steps: () => [
|
|
1568
|
+
{ type: "focus", target: "input" }
|
|
1569
|
+
]
|
|
1570
|
+
}
|
|
1571
|
+
],
|
|
1572
|
+
assertion: isInputFocused
|
|
1526
1573
|
},
|
|
1527
1574
|
"input.filled": {
|
|
1528
|
-
setup:
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1575
|
+
setup: [
|
|
1576
|
+
{
|
|
1577
|
+
when: ["keyboard", "textInput"],
|
|
1578
|
+
steps: () => [
|
|
1579
|
+
{ type: "type", target: "input", value: "test" }
|
|
1580
|
+
]
|
|
1581
|
+
}
|
|
1582
|
+
],
|
|
1583
|
+
assertion: isInputFilled
|
|
1532
1584
|
},
|
|
1533
1585
|
"activeOption.first": {
|
|
1534
1586
|
requires: ["listbox.open"],
|
|
1535
1587
|
setup: [
|
|
1536
|
-
{
|
|
1588
|
+
{
|
|
1589
|
+
when: ["keyboard"],
|
|
1590
|
+
steps: () => [
|
|
1591
|
+
{ type: "keypress", target: "input", key: "ArrowDown" }
|
|
1592
|
+
]
|
|
1593
|
+
}
|
|
1537
1594
|
],
|
|
1538
|
-
assertion:
|
|
1539
|
-
...isActiveDescendantNotEmpty()
|
|
1540
|
-
]
|
|
1595
|
+
assertion: isActiveDescendantNotEmpty
|
|
1541
1596
|
},
|
|
1542
1597
|
"activeOption.last": {
|
|
1543
1598
|
requires: ["activeOption.first"],
|
|
1544
1599
|
setup: [
|
|
1545
|
-
{
|
|
1600
|
+
{
|
|
1601
|
+
when: ["keyboard"],
|
|
1602
|
+
steps: () => [
|
|
1603
|
+
{ type: "keypress", target: "input", key: "ArrowUp" }
|
|
1604
|
+
]
|
|
1605
|
+
}
|
|
1546
1606
|
],
|
|
1547
|
-
assertion:
|
|
1548
|
-
...isActiveDescendantNotEmpty()
|
|
1549
|
-
]
|
|
1607
|
+
assertion: isActiveDescendantNotEmpty
|
|
1550
1608
|
},
|
|
1551
1609
|
"selectedOption.first": {
|
|
1552
1610
|
requires: ["listbox.open"],
|
|
1553
1611
|
setup: [
|
|
1554
|
-
{
|
|
1612
|
+
{
|
|
1613
|
+
when: ["pointer"],
|
|
1614
|
+
steps: () => [
|
|
1615
|
+
{ type: "click", target: "relative", relativeTarget: "first" }
|
|
1616
|
+
]
|
|
1617
|
+
}
|
|
1555
1618
|
],
|
|
1556
|
-
assertion:
|
|
1557
|
-
...isAriaSelected("first")
|
|
1558
|
-
]
|
|
1619
|
+
assertion: () => isAriaSelected("first")
|
|
1559
1620
|
},
|
|
1560
1621
|
"selectedOption.last": {
|
|
1561
1622
|
requires: ["listbox.open"],
|
|
1562
1623
|
setup: [
|
|
1563
|
-
{
|
|
1624
|
+
{
|
|
1625
|
+
when: ["pointer"],
|
|
1626
|
+
steps: () => [
|
|
1627
|
+
{ type: "click", target: "relative", relativeTarget: "last" }
|
|
1628
|
+
]
|
|
1629
|
+
}
|
|
1564
1630
|
],
|
|
1565
|
-
assertion:
|
|
1566
|
-
...isAriaSelected("first")
|
|
1567
|
-
]
|
|
1631
|
+
assertion: () => isAriaSelected("last")
|
|
1568
1632
|
}
|
|
1569
1633
|
};
|
|
1570
|
-
function openCombobox() {
|
|
1571
|
-
return [
|
|
1572
|
-
{ type: "keypress", target: "input", key: "ArrowDown" }
|
|
1573
|
-
];
|
|
1574
|
-
}
|
|
1575
|
-
function closeCombobox() {
|
|
1576
|
-
return [
|
|
1577
|
-
{ type: "keypress", target: "input", key: "Escape" }
|
|
1578
|
-
];
|
|
1579
|
-
}
|
|
1580
|
-
function focusInput() {
|
|
1581
|
-
return [
|
|
1582
|
-
{ type: "focus", target: "input" }
|
|
1583
|
-
];
|
|
1584
|
-
}
|
|
1585
|
-
function fillInput() {
|
|
1586
|
-
return [
|
|
1587
|
-
{ type: "type", target: "input", value: "test" }
|
|
1588
|
-
];
|
|
1589
|
-
}
|
|
1590
1634
|
function isComboboxOpen() {
|
|
1591
1635
|
return [
|
|
1592
1636
|
{
|
|
1593
1637
|
target: "listbox",
|
|
1594
1638
|
assertion: "toBeVisible",
|
|
1595
1639
|
failureMessage: "Expected listbox to be visible"
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
target: "input",
|
|
1643
|
+
assertion: "toHaveAttribute",
|
|
1644
|
+
attribute: "aria-expanded",
|
|
1645
|
+
expectedValue: "true",
|
|
1646
|
+
failureMessage: "Expect combobox input to have aria-expanded='true'"
|
|
1596
1647
|
}
|
|
1597
1648
|
];
|
|
1598
1649
|
}
|
|
@@ -1602,6 +1653,13 @@ function isComboboxClosed() {
|
|
|
1602
1653
|
target: "listbox",
|
|
1603
1654
|
assertion: "notToBeVisible",
|
|
1604
1655
|
failureMessage: "Expected listbox to be closed"
|
|
1656
|
+
},
|
|
1657
|
+
{
|
|
1658
|
+
target: "input",
|
|
1659
|
+
assertion: "toHaveAttribute",
|
|
1660
|
+
attribute: "aria-expanded",
|
|
1661
|
+
expectedValue: "false",
|
|
1662
|
+
failureMessage: "Expect combobox input to have aria-expanded='false'"
|
|
1605
1663
|
}
|
|
1606
1664
|
];
|
|
1607
1665
|
}
|
|
@@ -1624,7 +1682,7 @@ function isAriaSelected(index) {
|
|
|
1624
1682
|
assertion: "toHaveAttribute",
|
|
1625
1683
|
attribute: "aria-selected",
|
|
1626
1684
|
expectedValue: "true",
|
|
1627
|
-
failureMessage: `Expected
|
|
1685
|
+
failureMessage: `Expected ${index} option to have aria-selected='true'`
|
|
1628
1686
|
}
|
|
1629
1687
|
];
|
|
1630
1688
|
}
|
|
@@ -1770,7 +1828,17 @@ var DynamicTestBuilder = class {
|
|
|
1770
1828
|
return this.parent;
|
|
1771
1829
|
}
|
|
1772
1830
|
_finalize() {
|
|
1773
|
-
const
|
|
1831
|
+
const capabilityMap = {
|
|
1832
|
+
keypress: "keyboard",
|
|
1833
|
+
click: "pointer",
|
|
1834
|
+
type: "textInput",
|
|
1835
|
+
focus: "keyboard",
|
|
1836
|
+
hover: "pointer"
|
|
1837
|
+
// add more mappings as needed
|
|
1838
|
+
};
|
|
1839
|
+
const capability = capabilityMap[this._as || "keyboard"] || (this._as || "keyboard");
|
|
1840
|
+
const ctx = { capabilities: [capability] };
|
|
1841
|
+
const resolveAllSetups = (stateName, visited = /* @__PURE__ */ new Set()) => {
|
|
1774
1842
|
if (visited.has(stateName)) return [];
|
|
1775
1843
|
visited.add(stateName);
|
|
1776
1844
|
const s = this.statePack[stateName];
|
|
@@ -1778,22 +1846,30 @@ var DynamicTestBuilder = class {
|
|
|
1778
1846
|
let actions = [];
|
|
1779
1847
|
if (Array.isArray(s.requires)) {
|
|
1780
1848
|
for (const req of s.requires) {
|
|
1781
|
-
actions = actions.concat(
|
|
1849
|
+
actions = actions.concat(resolveAllSetups(req, visited));
|
|
1782
1850
|
}
|
|
1783
1851
|
}
|
|
1784
|
-
if (s.setup) actions = actions.concat(s.setup);
|
|
1852
|
+
if (s.setup) actions = actions.concat(resolveSetup(s.setup, ctx));
|
|
1785
1853
|
return actions;
|
|
1786
1854
|
};
|
|
1787
1855
|
const setup = [];
|
|
1788
1856
|
for (const state of this._given) {
|
|
1789
|
-
setup.push(...
|
|
1857
|
+
setup.push(...resolveAllSetups(state));
|
|
1790
1858
|
}
|
|
1791
1859
|
const assertions = [];
|
|
1792
1860
|
for (const state of this._then) {
|
|
1793
1861
|
const s = this.statePack[state];
|
|
1794
|
-
if (s && s.assertion) {
|
|
1795
|
-
|
|
1796
|
-
|
|
1862
|
+
if (s && s.assertion !== void 0) {
|
|
1863
|
+
let value = s.assertion;
|
|
1864
|
+
if (typeof value === "function") {
|
|
1865
|
+
try {
|
|
1866
|
+
value = value();
|
|
1867
|
+
} catch (e) {
|
|
1868
|
+
throw new Error(`Error calling assertion function for state '${state}': ${e.message}`);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
if (Array.isArray(value)) assertions.push(...value);
|
|
1872
|
+
else assertions.push(value);
|
|
1797
1873
|
}
|
|
1798
1874
|
}
|
|
1799
1875
|
const action = [
|
|
@@ -88,4 +88,4 @@ interface MenuCallback {
|
|
|
88
88
|
onOpenChange?: (isOpen: boolean) => void;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export type {
|
|
91
|
+
export type { AccordionConfig as A, ComboboxConfig as C, MenuConfig as M, TabsConfig as T, AccessibilityInstance as a };
|
|
@@ -88,4 +88,4 @@ interface MenuCallback {
|
|
|
88
88
|
onOpenChange?: (isOpen: boolean) => void;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export type {
|
|
91
|
+
export type { AccordionConfig as A, ComboboxConfig as C, MenuConfig as M, TabsConfig as T, AccessibilityInstance as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes an accordion accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AccordionConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes an accordion accessible by managing ARIA attributes, keyboard interaction, and state.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ComboboxConfig,
|
|
1
|
+
import { C as ComboboxConfig, a as AccessibilityInstance } from '../Types.d-DYfYR3Vc.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Makes a Combobox accessible by adding appropriate ARIA attributes, keyboard interactions and focus management.
|