-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
chore: Northstar screener should read from screenerStates.json #24848
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { task, series } from 'gulp'; | ||
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. Split up The two steps have nothing in common with each other either |
||
import fs from 'fs'; | ||
|
||
import config from '../../config'; | ||
import getScreenerStates from '../../screener/screener.states'; | ||
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. same public api chore like in former comment |
||
|
||
const { paths } = config; | ||
|
||
task('screener:states', cb => { | ||
const states = getScreenerStates(); | ||
const statesJson = JSON.stringify(states, null, 2); | ||
fs.writeFile(paths.docsDist('screenerStates.json'), statesJson, { encoding: 'utf8' }, err => { | ||
if (err) { | ||
cb(err); | ||
} | ||
|
||
cb(); | ||
}); | ||
}); | ||
|
||
task('screener:build', series('screener:states')); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,42 +7,44 @@ import path from 'path'; | |
import getScreenerSteps from './screener.steps'; | ||
import { ScreenerState } from './screener.types'; | ||
|
||
const baseUrl = `${process.env.DEPLOYURL}/react-northstar-screener`; | ||
const examplePaths = glob.sync('packages/fluentui/docs/src/examples/**/*.tsx', { | ||
ignore: ['**/index.tsx', '**/*.knobs.tsx', '**/BestPractices/*.tsx', '**/Playground.tsx'], | ||
}); | ||
|
||
const pathFilter = process.env.SCREENER_FILTER; | ||
const filteredPaths: string[] = minimatch.match(examplePaths, pathFilter || '*', { | ||
matchBase: true, | ||
}); | ||
|
||
if (pathFilter) { | ||
console.log(chalk.bgGreen.black(' --filter '), pathFilter); | ||
filteredPaths.forEach(filteredPath => console.log(`${_.repeat(' ', 10)} ${filteredPath}`)); | ||
} | ||
|
||
const getStateForPath = (examplePath: string): ScreenerState => { | ||
const { name: exampleNameWithoutExtension, base: exampleNameWithExtension, dir: exampleDir } = path.parse( | ||
examplePath, | ||
); | ||
|
||
const rtl = exampleNameWithExtension.endsWith('.rtl.tsx'); | ||
const exampleUrl = _.kebabCase(exampleNameWithoutExtension); | ||
const pageUrl = `${baseUrl}/maximize/${exampleUrl}/${rtl}`; | ||
|
||
return { | ||
url: pageUrl, | ||
name: exampleNameWithExtension, | ||
|
||
// https://www.npmjs.com/package/screener-runner#testing-interactions | ||
steps: getScreenerSteps(pageUrl, `${exampleDir}/${exampleNameWithoutExtension}.steps`), | ||
export default function getScreenerStates() { | ||
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 file used to require all of northstar, refactored this to be a factory to only require northstar when needed 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. suggestion: can we stop using/introducing new default exports ? not explicit API contracts / subpar DX .... 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. the logic for particular library should not live here as it introduces tight coupling. I understand this PR purpose is to quick fix current behaviours, but would be great if we can come up with long term solution. |
||
const baseUrl = `${process.env.DEPLOYURL}/react-northstar-screener`; | ||
const examplePaths = glob.sync('packages/fluentui/docs/src/examples/**/*.tsx', { | ||
ignore: ['**/index.tsx', '**/*.knobs.tsx', '**/BestPractices/*.tsx', '**/Playground.tsx'], | ||
}); | ||
|
||
const pathFilter = process.env.SCREENER_FILTER; | ||
const filteredPaths: string[] = minimatch.match(examplePaths, pathFilter || '*', { | ||
matchBase: true, | ||
}); | ||
|
||
if (pathFilter) { | ||
console.log(chalk.bgGreen.black(' --filter '), pathFilter); | ||
filteredPaths.forEach(filteredPath => console.log(`${_.repeat(' ', 10)} ${filteredPath}`)); | ||
} | ||
|
||
const getStateForPath = (examplePath: string): ScreenerState => { | ||
const { name: exampleNameWithoutExtension, base: exampleNameWithExtension, dir: exampleDir } = path.parse( | ||
examplePath, | ||
); | ||
|
||
const rtl = exampleNameWithExtension.endsWith('.rtl.tsx'); | ||
const exampleUrl = _.kebabCase(exampleNameWithoutExtension); | ||
const pageUrl = `${baseUrl}/maximize/${exampleUrl}/${rtl}`; | ||
|
||
return { | ||
url: pageUrl, | ||
name: exampleNameWithExtension, | ||
|
||
// https://www.npmjs.com/package/screener-runner#testing-interactions | ||
steps: getScreenerSteps(pageUrl, `${exampleDir}/${exampleNameWithoutExtension}.steps`), | ||
}; | ||
}; | ||
}; | ||
|
||
const screenerStates = filteredPaths.reduce((states, examplePath) => { | ||
states.push(getStateForPath(examplePath)); | ||
return states; | ||
}, [] as ReturnType<typeof getStateForPath>[]); | ||
const screenerStates = filteredPaths.reduce((states, examplePath) => { | ||
states.push(getStateForPath(examplePath)); | ||
return states; | ||
}, [] as ReturnType<typeof getStateForPath>[]); | ||
|
||
export default screenerStates; | ||
return screenerStates; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,22 @@ export type ScreenerRunnerConfig = { | |
apiKey: string; | ||
projectRepo: string; | ||
|
||
diffOptions: { | ||
diffOptions?: { | ||
structure: boolean; | ||
layout: boolean; | ||
style: boolean; | ||
content: boolean; | ||
minLayoutPosition: number; // Optional threshold for Layout changes. Defaults to 4 pixels. | ||
minLayoutDimension: number; // Optional threshold for Layout changes. Defaults to 10 pixels. | ||
minShiftGraphic: number; // Optional threshold for pixel shifts in graphics. | ||
compareSVGDOM: number; // Pass if SVG DOM is the same. Defaults to false. | ||
compareSVGDOM: boolean; // Pass if SVG DOM is the same. Defaults to false. | ||
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 was always typed incorrectly before applying the types to the screener.config.js |
||
}; | ||
|
||
states: ScreenerState[]; | ||
|
||
alwaysAcceptBaseBranch: boolean; | ||
baseBranch: string; | ||
commit: string; | ||
commit?: string; | ||
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 should be optional because master builds do not require a commit |
||
failureExitCode: number; | ||
|
||
/** Base url of deployed storybook screener should test */ | ||
|
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.
improve typings in screener.config.js files
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 deep import is bit unfortunate. can we expose
scripts/screener
api from barrel file ? this whole directory would be move do to separate package later on.Note: not needed for this PR but as a follow-up