-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support multiple settings being defined in *-commands.csv
#1125
base: master
Are you sure you want to change the base?
Changes from all commits
29e33f8
49b0924
af94498
57f2343
542256a
51cd2bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,8 +149,9 @@ 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 [primarySetting, ...additionalSettings] = command.settings | ||
? command.settings.split(' ') | ||
: ['defaultMode']; | ||
|
||
if (isEmptyObject(testsParsed[arrPosition])) { | ||
testsParsed[arrPosition] = { | ||
|
@@ -162,7 +163,7 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) { | |
ats: [ | ||
{ | ||
...atTargetInfo, | ||
settings: settingsValue, | ||
settings: primarySetting, | ||
}, | ||
], | ||
}, | ||
|
@@ -178,12 +179,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 === primarySetting | ||
) | ||
) | ||
testsParsed[arrPosition].target.ats.push({ | ||
...atTargetInfo, | ||
settings: settingsValue, | ||
settings: primarySetting, | ||
}); | ||
} | ||
} | ||
|
@@ -203,25 +204,28 @@ function parseTestCSVRowV2({ tests, assertions, scripts, commands }) { | |
return ( | ||
testId === commandInfo.testId && | ||
command === commandInfo.command && | ||
settings === commandInfo.settings && | ||
settings === commandInfo.settings && // the primary settings value | ||
presentationNumber === commandInfo.presentationNumber | ||
); | ||
} | ||
|
||
for (const command of commands) { | ||
testsParsed.forEach(test => { | ||
const [primarySetting, ...additionalSettings] = command.settings | ||
? command.settings.split(' ') | ||
: ['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 === primarySetting) | ||
) { | ||
const commandInfo = { | ||
testId: command.testId, | ||
command: command.command, | ||
settings: command.settings || 'defaultMode', | ||
settings: primarySetting, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This definition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree! I figured as much when sharing the initial gist on what's different here. I proposed
I don't think it necessary. Seems to be something to consider as an implementation detail.
A widespread refactor across the references in this repository, aria-at-app (as well as some migration or backward compatibility work) and also in aria-at-automation-harness and related resources I assume. That will certainly need a bit of coordination that I'm uneasy trying to get that done now. Do you feel strongly otherwise? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it's an implementation detail for the Community Group at large. That said, the amount of inter-project coordination needed to support change makes it feel like a public-facing design. This change creates a gap between what the CG calls "settings" and what code maintainers call "settings", and to me, that's a problem which is distinct from the internally inconsistent names. I dropped in from w3c/aria-at-automation-harness#73 to verify that my understanding of the situation was accurate. I trust your judgement when it comes to coordinating changes; I'd only advocate for prioritizing that refactoring sooner rather than later! |
||
presentationNumber: Number(command.presentationNumber), | ||
assertionExceptions: command.assertionExceptions, | ||
additionalSettings, | ||
}; | ||
|
||
// Test level commandInfo, useful for getting assertionExceptions and | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ const processCollectedTests = ({ collectedTest, commandsAPI, atKey, mode, task, | |
commandsValuesForInstructions, | ||
modeInstructions = undefined; | ||
|
||
// TODO: Standardize naming on settings instead of outdated 'mode' | ||
let additionalSettings = []; | ||
|
||
/** @type {CollectedTestAT} */ | ||
const at = commandsAPI.isKnownAT(atKey); | ||
const defaultConfigurationInstructions = unescapeHTML( | ||
|
@@ -50,6 +53,15 @@ const processCollectedTests = ({ collectedTest, commandsAPI, atKey, mode, task, | |
}) | ||
: undefined; | ||
|
||
function findCommandInfo(assertionForCommand) { | ||
return collectedTest.commandsInfo?.[at.key]?.find( | ||
c => | ||
c.command === assertionForCommand.key && | ||
c.settings === assertionForCommand.settings && | ||
c.presentationNumber === assertionForCommand.presentationNumber | ||
); | ||
} | ||
|
||
/** | ||
* Check default assertion priorities to verify if there is a priority exception and return the | ||
* updated list of assertions | ||
|
@@ -64,9 +76,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
); | ||
|
||
if (foundCommandInfo) { | ||
|
@@ -105,6 +118,36 @@ const processCollectedTests = ({ collectedTest, commandsAPI, atKey, mode, task, | |
assertionsForCommandsInstructions.length && | ||
typeof assertionsForCommandsInstructions[0] === 'object' | ||
) { | ||
// Check for additional settings | ||
const foundCommandInfos = assertionsForCommandsInstructions.map(findCommandInfo); | ||
assertionsForCommandsInstructions = assertionsForCommandsInstructions.map( | ||
(assertionForCommand, index) => { | ||
const foundCommandInfo = foundCommandInfos[index]; | ||
|
||
const additionalSettingsExpanded = []; | ||
for (const additionalSetting of foundCommandInfo.additionalSettings) { | ||
if (!additionalSettings.includes(additionalSetting)) | ||
additionalSettings.push(additionalSetting); | ||
|
||
const expandedSettings = { | ||
settings: additionalSetting, | ||
settingsText: at.settings[additionalSetting].screenText, | ||
}; | ||
|
||
// Update value text if additional settings exist | ||
assertionForCommand.value = | ||
assertionForCommand.value.slice(0, -1) + ` and ${expandedSettings.settingsText})`; | ||
|
||
additionalSettingsExpanded.push(expandedSettings); | ||
} | ||
|
||
return { | ||
...assertionForCommand, | ||
additionalSettingsExpanded, | ||
additionalSettings: foundCommandInfo.additionalSettings, | ||
}; | ||
} | ||
); | ||
commandsValuesForInstructions = assertionsForCommandsInstructions.map(each => each.value); | ||
} else { | ||
// V1 came in as array of strings | ||
|
@@ -149,7 +192,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.split('_'), ...additionalSettings])]; | ||
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 = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure with the primary setting as the first item in a space-separated collection feels a bit fragile. I'd rather have this as a distinct column. It feels like there is significance not surfaced by a quick read of the input. I assume that this is a design decision towards a better authoring experience so I support leaving as-is for now