-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TextField] Replace autocomplete off with nope #4053
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9c86a82
[TextField] Replace autocomplete off with nope
aa2fb50
Add to UNRELEASED
8092455
Update the accessibility check to use the shared package
cfff283
Adding package and bumping node version
6bcd1db
Bump node version in workflows
3dd4471
Fix iframe path
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v10.15.0 | ||
v10.24.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,25 @@ | ||
/* eslint-disable no-console */ | ||
const os = require('os'); | ||
const path = require('path'); | ||
|
||
const puppeteer = require('puppeteer'); | ||
const pMap = require('p-map'); | ||
const chalk = require('chalk'); | ||
|
||
// eslint-disable-next-line node/no-path-concat | ||
const iframePath = `file://${__dirname}/../build/storybook/static/iframe.html`; | ||
const concurrentCount = os.cpus().length; | ||
const skippedStoryIds = ['playground-playground', 'all-examples']; | ||
|
||
const getUrls = async (browser) => { | ||
// Get the URLS from storybook | ||
const page = await browser.newPage(); | ||
await page.goto(iframePath); | ||
const storyIds = await page.evaluate(() => | ||
window.__STORYBOOK_CLIENT_API__.raw().map((story) => story.id), | ||
); | ||
await page.close(); | ||
|
||
const urls = storyIds.reduce((memo, storyId) => { | ||
// If it is a story id that is not in excludedStoryIds | ||
if (skippedStoryIds.every((id) => !storyId.includes(id))) { | ||
const url = `${iframePath}?id=${storyId}`; | ||
memo.push( | ||
url, | ||
// Dark mode has lots of errors. It is still very WIP so ignore for now | ||
// `${url}&contexts=Color%20scheme%3DDark%20Mode`, | ||
); | ||
} | ||
|
||
return memo; | ||
}, []); | ||
|
||
return urls; | ||
}; | ||
|
||
const formatFailure = (fail) => { | ||
return ` - ${fail.failureSummary.split('\n ')[1]}\n ${fail.html}`; | ||
}; | ||
|
||
const formatMessage = (id, violations) => { | ||
const url = chalk.underline.blue( | ||
`http://localhost:6006/iframe.html?id=all-components-${id}`, | ||
); | ||
return violations | ||
.map((fail) => { | ||
const message = fail.nodes | ||
.map((error) => formatFailure(error)) | ||
.join('\n'); | ||
return `${chalk.red(fail.impact)} => ${url}\n${message}`; | ||
}) | ||
.join('\n'); | ||
}; | ||
const {storybookA11yTest} = require('@shopify/storybook-a11y-test'); | ||
|
||
(async () => { | ||
try { | ||
// Open a browser | ||
console.log(chalk.bold(`🌐 Opening ${concurrentCount} tabs in chromium`)); | ||
const browser = await puppeteer.launch(); | ||
|
||
// Get the test ids from storybook | ||
const testIds = await getUrls(browser); | ||
|
||
console.log(chalk.bold(`🧪 Testing ${testIds.length} urls with axe`)); | ||
|
||
// Test the pages with axe | ||
const testPage = async (url) => { | ||
const id = url.replace(`${iframePath}?id=all-components-`, ''); | ||
console.log(` - ${id}`); | ||
|
||
try { | ||
const page = await browser.newPage(); | ||
await page.goto(url); | ||
const result = await page.evaluate(() => | ||
window.axe.run(document.getElementById('root'), {}), | ||
); | ||
await page.close(); | ||
|
||
if (result.violations.length) { | ||
return formatMessage(id, result.violations); | ||
} | ||
} catch (error) { | ||
return `please retry => ${id}:\n - ${error.message}`; | ||
} | ||
}; | ||
|
||
const results = await pMap(testIds, testPage, { | ||
concurrency: concurrentCount, | ||
}); | ||
await browser.close(); | ||
|
||
// Format the results and log them out | ||
const messages = results.filter((x) => x); | ||
if (messages.length) { | ||
console.error(chalk.bold(`‼️ Test failures found`)); | ||
console.log(messages.join('\n')); | ||
process.exit(1); | ||
} else { | ||
console.log(chalk.bold('🧚♀️ Accessibility is all g')); | ||
} | ||
} catch (error) { | ||
console.error(error.message); | ||
const options = { | ||
iframePath: path.join( | ||
'file://', | ||
__dirname, | ||
'../build/storybook/static/iframe.html', | ||
), | ||
skippedStoryIds: ['playground-playground', 'all-examples'], | ||
}; | ||
|
||
const results = await storybookA11yTest(options); | ||
|
||
if (results.length) { | ||
console.error(`‼️ Test failures found`); | ||
console.log(results.join('\n')); | ||
process.exit(1); | ||
} else { | ||
console.log('🧚♀️ Accessibility is all g'); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unblocked by Shopify/quilt#1764