Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
29e33f8
Support space separated settings and render result for createAllTests
howard-e Aug 29, 2024
49b0924
Fix for collected test not properly handling presentationNumber when …
howard-e Sep 3, 2024
af94498
Support additional settings on review page
howard-e Sep 3, 2024
57f2343
Update snapshot
howard-e Sep 3, 2024
542256a
Remove unnecessary attributes
howard-e Sep 4, 2024
51cd2bc
'additional' as a better descriptor
howard-e Sep 5, 2024
cbcaa0b
Merge branch 'master' into fix-1002
howard-e Jan 22, 2025
5e515a6
Update process-test-directory scripts to account for space separated …
howard-e Jan 28, 2025
ea61658
Update test-reviewer to account for space separated settings string r…
howard-e Jan 28, 2025
94156f7
Fix errant closing bracket
howard-e Jan 29, 2025
8cc3a75
Revise how instructions.mode gets included in collected.json when the…
howard-e Jan 29, 2025
03fc960
Remove accounting for concept of 'additionalSettings' from harness
howard-e Jan 29, 2025
ca07c83
Merge branch 'master' into fix-1002
howard-e Jan 29, 2025
5a3bf63
Update tests snapshots
howard-e Jan 29, 2025
6cf4165
Adjust screenText
howard-e Jan 30, 2025
d124159
Conditionally show instructions on collected.json page
howard-e Jan 30, 2025
c5835de
Merge branch 'master' into fix-1002
howard-e Jan 30, 2025
d1a220d
Revert unnecessary snapshotting
howard-e Jan 30, 2025
e5f78ed
TODO for posterity
howard-e Feb 3, 2025
d3e5b14
Use settingsScreenTextRender function
howard-e Feb 10, 2025
42ef8ff
Merge branch 'master' into fix-1002
howard-e May 6, 2025
093a2e2
Generate .html source files with scripts automatically
howard-e May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/data/parse-command-csv-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ function parseCommandCSVRowV2({ commands }, commandsJson) {
const commandIds = command.command.split(' ');
const commandKVs = findValuesByKeys(flattenedCommandsJson, [command.command]);

// Also account for 'modeless' AT configurations with 'defaultMode'
const settings = command.settings || 'defaultMode';

const foundCommandIndex = commandsParsed.findIndex(
e =>
e.testId === command.testId &&
e.target.at.key === atTargetInfo.key &&
e.target.at.settings === settings &&
(e.commands.length
? e.commands.every(
({ presentationNumber }) =>
parseInt(presentationNumber) === parseInt(command.presentationNumber)
)
: true)
);

const assertionExceptions = command.assertionExceptions.length
? sanitizeWhitespace(command.assertionExceptions).split(' ')
: [];
Expand All @@ -209,30 +225,14 @@ function parseCommandCSVRowV2({ commands }, commandsJson) {
assertionExceptions,
}));

// Also account for 'modeless' AT configurations with 'defaultMode'
const settingsValue = command.settings || 'defaultMode';

const foundCommandIndex = commandsParsed.findIndex(
e =>
e.testId === command.testId &&
e.target.at.key === atTargetInfo.key &&
e.target.at.settings === settingsValue &&
(e.commands.length
? e.commands.every(
({ presentationNumber }) =>
parseInt(presentationNumber) === parseInt(command.presentationNumber)
)
: true)
);

// Add new parsed command since none exist
if (foundCommandIndex < 0) {
commandsParsed.push({
testId: command.testId,
target: {
at: {
...atTargetInfo,
settings: settingsValue,
settings,
},
},
commands,
Expand Down
22 changes: 13 additions & 9 deletions lib/data/parse-test-csv-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ function parseTestCSVRow(testRow) {
};
}

/**
* Utility function to check if @param object has any keys present
* @param object
* @returns {boolean}
*/
function isEmptyObject(object) {
return object && Object.keys(object).length === 0;
}
Expand Down Expand Up @@ -149,8 +154,7 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) {
}

// Also account for 'modeless' AT configurations with 'defaultMode'
// TODO: Account for a list of settings as described by https://github.com/w3c/aria-at/wiki/Test-Format-Definition-V2#settings
const settingsValue = command.settings || 'defaultMode';
const settings = command.settings || 'defaultMode';

if (isEmptyObject(testsParsed[arrPosition])) {
testsParsed[arrPosition] = {
Expand All @@ -162,7 +166,7 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) {
ats: [
{
...atTargetInfo,
settings: settingsValue,
settings,
},
],
},
Expand All @@ -178,12 +182,12 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) {
} else {
if (
!testsParsed[arrPosition].target.ats.find(
e => e.key === atTargetInfo.key && e.settings === settingsValue
e => e.key === atTargetInfo.key && e.settings === settings
)
)
testsParsed[arrPosition].target.ats.push({
...atTargetInfo,
settings: settingsValue,
settings,
});
}
}
Expand All @@ -210,16 +214,16 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) {

for (const command of commands) {
testsParsed.forEach(test => {
const settings = command.settings || 'defaultMode';

if (
command.testId === test.testId &&
test.target.ats.some(
at => at.key === key && at.settings === (command.settings || 'defaultMode')
)
test.target.ats.some(at => at.key === key && at.settings === settings)
) {
const commandInfo = {
testId: command.testId,
command: command.command,
settings: command.settings || 'defaultMode',
settings: settings,
presentationNumber: Number(command.presentationNumber),
assertionExceptions: command.assertionExceptions,
};
Expand Down
60 changes: 48 additions & 12 deletions lib/data/process-test-directory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,13 @@ const processTestDirectory = async config => {
}

function getModeValue({ settings }) {
let v = settings.trim();
if (!validModes.includes(v)) {
let v = settings.trim().split(' ');
if (!v.every(el => validModes.includes(el))) {
utils.addTestError(
test.testId,
'"' + settings + '" is not valid value for "settings" property.'
'"' +
settings +
'" is not valid value for "settings" property. Check again that each setting is correctly spelt.'
);
}
return v;
Expand Down Expand Up @@ -686,11 +688,38 @@ const processTestDirectory = async config => {
// Declare a common collectedTest that will be modified (if needed)
let common = collectedTestsGroupedByAtGroupedByTestIds[0];
const settings = common.target.at.settings;

// Convert the mode attribute FROM the following:
// {
// 'setting1 setting2': [
// [
// ...setting1 string array of instructions
// ],
// [
// ...setting2 string array of instructions
// ]
// ]
// }
//
// TO:
// {
// 'setting1': [
// ...setting1 array of instructions
// ],
// 'setting2': [
// ...setting2 string array of instructions
// ]
// }
const settingsResult = {};
settings
.split(' ')
.forEach((setting, index) => (settingsResult[setting] = common.instructions.mode[index]));

common = {
...common,
instructions: {
...common.instructions,
mode: { [settings]: common.instructions.mode },
mode: settingsResult, // TODO: Replace 'mode' references with 'settings'
},
commands: common.commands.map(command => ({
...command,
Expand All @@ -704,7 +733,10 @@ const processTestDirectory = async config => {
const settings = additional.target.at.settings;

common.target.at.settings = `${common.target.at.settings}_${settings}`;
common.instructions.mode[settings] = additional.instructions.mode;
settings.split(' ').forEach((setting, index) => {
if (!common.instructions.mode[setting])
common.instructions.mode[setting] = additional.instructions.mode[index];
});
common.commands.push(
...additional.commands.map(command => ({
...command,
Expand Down Expand Up @@ -931,9 +963,11 @@ function validateTest(testParsed, data, { addTestError = () => {} } = {}) {
});

testParsed.target.ats.forEach(at => {
if (!data.mode.where(at.settings)) {
addTestError(`"${at.settings}" is not valid value for "settings" property.`);
}
at.settings.split(' ').forEach(setting => {
if (!data.mode.where(setting)) {
addTestError(`"${at.settings}" is not valid value for "settings" property.`);
}
});
});

const references = testParsed.references.filter(({ refId }) => {
Expand Down Expand Up @@ -1080,10 +1114,12 @@ function collectTestData({ test, command, supportAt, example, modeInstructionTem
},
instructions: {
instructions: test.instructions,
mode: modeInstructionTemplate.where({
at: command.target.at.key,
mode: command.target.at.settings,
}).render,
mode: command.target.at.settings.split(' ').map(setting => {
return modeInstructionTemplate.where({
at: command.target.at.key,
mode: setting,
}).render;
}),
},
commands: command.commands,
assertions: test.assertions,
Expand Down
16 changes: 9 additions & 7 deletions scripts/test-reviewer/processCollectedTests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { unescapeHTML } from './utils.mjs';
* @param {CollectedTest} collectedTest
* @param {commandsAPI} commandsAPI
* @param {string} atKey
* @param {string} mode
* @param {string} mode // TODO: Standardize naming on settings instead of outdated 'mode'
* @param {string} task
* @param {number} testNumber
* @returns {{defaultConfigurationInstructions, assertionsForCommandsInstructions, at, modeInstructions, userInstruction, commandsValuesForInstructions}}
Expand Down Expand Up @@ -64,9 +64,10 @@ const processCollectedTests = ({ collectedTest, commandsAPI, atKey, mode, task,
// Check to see if there is any command info exceptions for current at key
const foundCommandInfo = collectedTest.commandsInfo?.[at.key]?.find(
c =>
c.assertionExceptions.includes(assertion.assertionId) &&
c.command === assertionForCommand.key &&
c.settings === assertionForCommand.settings
c.settings === assertionForCommand.settings &&
c.presentationNumber === assertionForCommand.presentationNumber &&
c.assertionExceptions.includes(assertion.assertionId)
);

if (foundCommandInfo) {
Expand All @@ -88,13 +89,12 @@ const processCollectedTests = ({ collectedTest, commandsAPI, atKey, mode, task,
}

try {
assertionsForCommandsInstructions = commandsAPI.getATCommands(mode, task, {
assertionsForCommandsInstructions = commandsAPI.getATCommands(mode.replace(/,/g, ' '), task, {
...at,
settings: {
...at.settings,
defaultMode: {
// TODO: If there is a need to explicitly state that the
// default mode is active for an AT
// TODO: If there is a need to explicitly state that the default mode is active for an AT
screenText: '',
// instructions: [at.defaultConfigurationInstructionsHTML],
},
Expand Down Expand Up @@ -149,7 +149,9 @@ const processCollectedTests = ({ collectedTest, commandsAPI, atKey, mode, task,
// An error will occur if there is no data for an AT, ignore it
}

for (const atMode of mode.split('_')) {
// Create unique set
const foundAtModes = [...new Set([...mode.replace(/,/g, '_').split('_')])];
for (const atMode of foundAtModes) {
// TODO: If there is ever need to explicitly show the instructions
// for an AT with the default mode active
// const atSettingsWithDefault = {
Expand Down
Loading
Loading