Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update collection form to be consistent with updated review pages #1017

Merged
merged 15 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
59 changes: 22 additions & 37 deletions lib/data/parse-test-csv-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,45 +193,30 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) {

for (const command of commands) {
testsParsed.forEach(test => {
test.assertions?.forEach(assertion => {
if (
command.testId === test.testId &&
test.target.ats.some(
at => at.key === key && at.settings === (command.settings || 'defaultMode')
)
) {
if (!assertion.commandInfo) assertion.commandInfo = {};
if (!assertion.commandInfo[key]) assertion.commandInfo[key] = [];

const commandInfo = {
testId: command.testId,
command: command.command,
settings: command.settings || 'defaultMode',
presentationNumber: Number(command.presentationNumber),
};

// assertion level commandInfo, useful for getting assertionExceptions
const assertionCommandInfoExists = assertion.commandInfo[key].find(each =>
findCommandInfo(each, commandInfo)
);
if (!assertionCommandInfoExists) {
const assertionCommandInfo = {
...commandInfo,
assertionExceptions: command.assertionExceptions,
};
assertion.commandInfo[key].push(assertionCommandInfo);
}
if (
command.testId === test.testId &&
test.target.ats.some(
at => at.key === key && at.settings === (command.settings || 'defaultMode')
)
) {
const commandInfo = {
testId: command.testId,
command: command.command,
settings: command.settings || 'defaultMode',
presentationNumber: Number(command.presentationNumber),
assertionExceptions: command.assertionExceptions,
};

// Test level commandInfo, useful for getting review level information
if (!test.commandsInfo) test.commandsInfo = {};
if (!test.commandsInfo[key]) test.commandsInfo[key] = [];
const testCommandInfoExists = test.commandsInfo[key].find(each =>
findCommandInfo(each, commandInfo)
);
// Test level commandInfo, useful for getting assertionExceptions and
// sort order in review and test pages
if (!test.commandsInfo) test.commandsInfo = {};
if (!test.commandsInfo[key]) test.commandsInfo[key] = [];
const testCommandInfoExists = test.commandsInfo[key].find(each =>
findCommandInfo(each, commandInfo)
);

if (!testCommandInfoExists) test.commandsInfo[key].push(commandInfo);
}
});
if (!testCommandInfoExists) test.commandsInfo[key].push(commandInfo);
}
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/data/process-test-directory-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ const processTestDirectory = async ({ directory, args = {} }) => {
applies_to: appliesTo,
mode: mode,
task: task,
assertionResponseQuestion: supportJson.testPlanStrings.assertionResponseQuestion,
testPlanStrings: supportJson.testPlanStrings,
specific_user_instruction: test.instructions,
output_assertions: assertions,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/data/process-test-directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const processTestDirectory = async ({ directory, args = {} }) => {
const validCommandKeys = /^(?:testId|command|settings|assertionExceptions|presentationNumber)$/;
const numericKeyFormat = /^_(\d+)$/;
const idFormat = /^[A-Za-z0-9-]+$/;
const assertionsExceptionsFormat = /^([0123]:[a-zA-Z-]+\s*)+$/;
const assertionsExceptionsFormat = /^([0123]:[a-zA-Z-\d]+\s*)+$/;
const settingsFormat = /^[A-Za-z0-9-\s]+$/;
function validateCommandsKeys(row) {
// example header:
Expand Down Expand Up @@ -528,7 +528,7 @@ const processTestDirectory = async ({ directory, args = {} }) => {
setup_script_description: getSetupScriptDescription(test.setupScript.scriptDescription),
setupTestPage: test.setupScript.script,
specific_user_instruction: test.instructions,
assertionResponseQuestion: supportJson.testPlanStrings.assertionResponseQuestion,
testPlanStrings: supportJson.testPlanStrings,
commandsInfo: test.commandsInfo,
output_assertions: test.assertions,
};
Expand Down
44 changes: 15 additions & 29 deletions scripts/test-reviewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ fse.readdirSync(testsBuildDirectory).forEach(function (directory) {
commandListPreface,
commandListSettingsPreface,
settingInstructionsPreface,
assertionResponseQuestion,
},
} = support;
referencesData = referencesData.map(
Expand Down Expand Up @@ -315,7 +314,6 @@ fse.readdirSync(testsBuildDirectory).forEach(function (directory) {
priority: getPriorityString(a[0]),
assertionPhrase: 'N/A',
assertionStatement: a[1],
commandInfo: null,
};
}

Expand All @@ -326,7 +324,6 @@ fse.readdirSync(testsBuildDirectory).forEach(function (directory) {
assertionPhrase: a.assertionPhrase,
assertionStatement:
a.tokenizedAssertionStatements?.[at.key] || a.assertionStatement,
commandInfo: a.commandInfo,
};
})
: undefined;
Expand Down Expand Up @@ -368,33 +365,22 @@ fse.readdirSync(testsBuildDirectory).forEach(function (directory) {
let priority = assertion.priority;

// Check to see if there is any command info exceptions for current at key
if (assertion.commandInfo && assertion.commandInfo[at.key]) {
assertion.commandInfo[at.key].forEach(commandInfoForAt => {
// Reconfirm against the known testData.commandsInfo;
// order should be maintained as presorted during build
// process
const testDataCommandInfoForAt =
testData.commandsInfo[at.key][assertionForCommandIndex];

if (
commandInfoForAt.testId === task &&
commandInfoForAt.command === assertionForCommand.key &&
commandInfoForAt.assertionExceptions.includes(assertion.assertionId) &&
commandInfoForAt.presentationNumber ===
testDataCommandInfoForAt.presentationNumber
) {
for (const exceptionPair of commandInfoForAt.assertionExceptions.split(
' '
)) {
let [exceptionPriority, exceptionAssertion] = exceptionPair.split(':');
exceptionPriority = Number(exceptionPriority);

if (assertion.assertionId === exceptionAssertion) {
priority = getPriorityString(exceptionPriority);
}
}
const foundCommandInfo = testData.commandsInfo?.[at.key]?.find(
c =>
c.assertionExceptions.includes(assertion.assertionId) &&
c.command === assertionForCommand.key &&
c.settings === assertionForCommand.settings
);

if (foundCommandInfo) {
for (const exceptionPair of foundCommandInfo.assertionExceptions.split(' ')) {
let [exceptionPriority, exceptionAssertion] = exceptionPair.split(':');
exceptionPriority = Number(exceptionPriority);

if (assertion.assertionId === exceptionAssertion) {
priority = getPriorityString(exceptionPriority);
}
});
}
}

return {
Expand Down
23 changes: 13 additions & 10 deletions tests/resources/aria-at-harness.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ function renderVirtualInstructionDocument(doc) {

instructCommands(doc.instructions.instructions),

instructAssertions(doc.instructions.assertions),
instructSettings(doc.instructions.settings),

button(
disabled(!doc.instructions.openTestPage.enabled),
Expand Down Expand Up @@ -529,17 +529,11 @@ function renderVirtualInstructionDocument(doc) {
* @param {InstructionDocumentInstructionsInstructions} param0
* @returns
*/
function instructCommands({
header,
instructions,
strongInstructions: boldInstructions,
commands,
}) {
function instructCommands({ header, instructions, commands }) {
return fragment(
h2(rich(header)),
ol(
...map(instructions, compose(li, rich)),
...map(boldInstructions, compose(li, em, rich)),
li(rich(commands.description), ul(...map(commands.commands, compose(li, em, rich))))
)
);
Expand All @@ -550,8 +544,7 @@ function renderVirtualInstructionDocument(doc) {
*/
function instructionHeader({ header, description }) {
return fragment(
h1(id('behavior-header'), tabIndex('0'), focus(header.focus), rich(header.header)),
p(rich(description))
h1(id('behavior-header'), tabIndex('0'), focus(header.focus), rich(header.header))
);
}

Expand All @@ -565,6 +558,15 @@ function renderVirtualInstructionDocument(doc) {
ol(...map(assertions, compose(li, em, rich)))
);
}

/**
* @param {InstructionDocumentInstructionsSettings[]} settings
*/
function instructSettings(settings) {
return Object.values(settings).map(({ screenText, instructions }) => {
return fragment(p(rich(screenText)), ol(...map(instructions, compose(li, rich))));
});
}
}

/**
Expand Down Expand Up @@ -627,6 +629,7 @@ function renderVirtualResultsTable(results) {
/** @typedef {import('./aria-at-test-run.mjs').InstructionDocumentResultsCommand} InstructionDocumentResultsCommand */
/** @typedef {import('./aria-at-test-run.mjs').InstructionDocumentResultsCommandsUnexpected} InstructionDocumentResultsCommandsUnexpected */
/** @typedef {import("./aria-at-test-run.mjs").InstructionDocumentResultsCommandsAssertion} InstructionDocumentResultsCommandsAssertion */
/** @typedef {import("./aria-at-test-run.mjs").InstructionDocumentResultsCommandsSettings} InstructionDocumentResultsCommandsSettings */
/** @typedef {import("./aria-at-test-run.mjs").InstructionDocumentAssertionChoice} InstructionDocumentAssertionChoice */
/** @typedef {import("./aria-at-test-run.mjs").InstructionDocumentInstructionsInstructions} InstructionDocumentInstructionsInstructions */

Expand Down
Loading
Loading