Skip to content

Commit

Permalink
Merge pull request #1291 from skbkontur/improve-button-screenshots
Browse files Browse the repository at this point in the history
test(Button): add screenshots for different states (680 buttons)
  • Loading branch information
zhzz authored Apr 1, 2019
2 parents 570df16 + 7afca07 commit 28bb53a
Show file tree
Hide file tree
Showing 62 changed files with 432 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/react-ui-screenshot-tests/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function exec(commandLine, { detached = false, env = {} } = {}) {
stdio: [0, 1, 2],
env: {
NODE_ENV: 'production',
enableReactTesting: true,
...process.env,
...env,
},
Expand Down
34 changes: 34 additions & 0 deletions packages/react-ui-screenshot-tests/gemini/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,37 @@ gemini.suite('Button with width', suite => {
.setCaptureElements('#test-element')
.capture('plain');
});

gemini.suite('Button states', () => {
const paginatedScenario = (suite, pagesCount) => {
var paginatedSuite = suite
.before((actions, find) => {
this.nextPage = find('#next-page');
})
.ignoreElements('#paginator')
.setCaptureElements('#test-element');

for (var page = 1; page <= pagesCount; page++) {
paginatedSuite.capture('page - ' + page, (actions, find) => {
if (page > 1) {
actions.click(this.nextPage);
}
});
}
};

gemini.suite('different aligns', suite => {
suite
.before(renderStory('Button', 'different aligns'))
.setCaptureElements('#test-element')
.capture('plain');
});

gemini.suite('different visual states', suite => {
paginatedScenario(suite.before(renderStory('Button', 'different visual states')), 9);
});

gemini.suite('different content', suite => {
paginatedScenario(suite.before(renderStory('Button', 'different content')), 8);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/react-ui-screenshot-tests/screenshotTestStyles.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*,
*:hover,
*:before,
*:after {
animation-delay: -0.0001ms !important;
animation-duration: 0s !important;
animation-play-state: paused !important;
cursor: none !important;
caret-color: transparent !important;
}
25 changes: 25 additions & 0 deletions packages/retail-ui/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ const WatchExternalFilesPlugin = require('webpack-watch-files-plugin').default;
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const isProd = process.env.NODE_ENV === 'production';
const enableReactTesting = process.env.enableReactTesting;
const REACT_SELENIUM_TESTING_PATH = path.resolve(__dirname, '../../react-ui-testing/react-selenium-testing.js');
const SCREENSHOT_TESTS_STYLES_PATH = path.resolve(
__dirname,
'../../react-ui-screenshot-tests/screenshotTestStyles.less',
);

module.exports = (baseConfig, env) => {
const config = baseConfig;

if (enableReactTesting) {
config.entry.preview.unshift(REACT_SELENIUM_TESTING_PATH, SCREENSHOT_TESTS_STYLES_PATH);
}

config.resolve.extensions.unshift('.ts', '.tsx');

config.module.rules.push(
Expand Down Expand Up @@ -38,9 +48,24 @@ module.exports = (baseConfig, env) => {
{ test: /\.json/, loader: 'json-loader' },
);

if (enableReactTesting) {
config.module.rules.push({
test: /\.js$/,
include: REACT_SELENIUM_TESTING_PATH,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: ['transform-object-assign', 'transform-es2015-typeof-symbol', 'transform-runtime'],
},
},
});
}

config.plugins.push(
new webpack.DefinePlugin({
'process.env.REACT_APP_EXPERIMENTAL_CSS_IN_JS': JSON.stringify(process.env.REACT_APP_EXPERIMENTAL_CSS_IN_JS),
'process.env.enableReactTesting': JSON.stringify(enableReactTesting),
}),
new WatchExternalFilesPlugin({
files: ['*.less'],
Expand Down
Loading

0 comments on commit 28bb53a

Please sign in to comment.