@applitools/eyes-storybook 3.51.1 → 3.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,133 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.52.1](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.52.0...js/eyes-storybook@3.52.1) (2024-11-09)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * @applitools/dom-snapshot bumped to 4.11.8
9
+ #### Bug Fixes
10
+
11
+ * overcome dom snapshot's failure to download resource from browser ([#2610](https://github.com/Applitools-Dev/sdk/issues/2610)) ([47d46fb](https://github.com/Applitools-Dev/sdk/commit/47d46fbe3baab12d5153f6617ab60142a8a215cf))
12
+ * @applitools/core bumped to 4.23.1
13
+ #### Bug Fixes
14
+
15
+ * overcome dom snapshot's failure to download resource from browser ([#2610](https://github.com/Applitools-Dev/sdk/issues/2610)) ([47d46fb](https://github.com/Applitools-Dev/sdk/commit/47d46fbe3baab12d5153f6617ab60142a8a215cf))
16
+
17
+
18
+
19
+
20
+ ## [3.52.0](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook-v3.51.2...js/eyes-storybook@3.52.0) (2024-11-07)
21
+
22
+
23
+ ### Features
24
+
25
+ * offline storybook ([#2596](https://github.com/Applitools-Dev/sdk/issues/2596)) ([c8edf80](https://github.com/Applitools-Dev/sdk/commit/c8edf80bc379d0cf5d94d798314bdad405d2f2b4))
26
+ * upgrade puppeteer to 23.5.1 ([#2457](https://github.com/Applitools-Dev/sdk/issues/2457)) ([62c2160](https://github.com/Applitools-Dev/sdk/commit/62c2160af3cd0ecc19a88c9668726d28d5d22e1a))
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * exit gracefully without stories ([#2602](https://github.com/Applitools-Dev/sdk/issues/2602)) ([00c9011](https://github.com/Applitools-Dev/sdk/commit/00c901113a9c760e1b10ced2ee4cc61cfd483b67))
32
+ * improve puppeteer related error handling ([#2601](https://github.com/Applitools-Dev/sdk/issues/2601)) ([2813462](https://github.com/Applitools-Dev/sdk/commit/2813462bc06f90b1c67d0fec6e252d3b5864406f))
33
+ * storybook with yarn pnp ([#2350](https://github.com/Applitools-Dev/sdk/issues/2350)) ([1b67e8f](https://github.com/Applitools-Dev/sdk/commit/1b67e8f5e37ed97aed55f38be1827db71243e38c))
34
+ * support reloadPagePerStory ([#2438](https://github.com/Applitools-Dev/sdk/issues/2438)) ([df457af](https://github.com/Applitools-Dev/sdk/commit/df457afcaf60bf272eec5b868401a1a84c98fdd4))
35
+ * trigger release ([88c4f81](https://github.com/Applitools-Dev/sdk/commit/88c4f812bd92eae61ee8ebbee5da0d64ad8c8859))
36
+ * tunnel client ([670b184](https://github.com/Applitools-Dev/sdk/commit/670b1843ce43347d97e19fa02f8bc630332ff414))
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * @applitools/utils bumped to 1.7.5
42
+ #### Code Refactoring
43
+
44
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
45
+ * @applitools/logger bumped to 2.0.19
46
+
47
+ * @applitools/dom-snapshot bumped to 4.11.7
48
+ #### Code Refactoring
49
+
50
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
51
+
52
+
53
+
54
+ * @applitools/socket bumped to 1.1.19
55
+
56
+ * @applitools/req bumped to 1.7.3
57
+
58
+ * @applitools/image bumped to 1.1.14
59
+
60
+ * @applitools/snippets bumped to 2.6.2
61
+ #### Bug Fixes
62
+
63
+ * provide a clear "stale element" exception message when passing detached regions to `check` ([#2590](https://github.com/Applitools-Dev/sdk/issues/2590)) ([1e5b49e](https://github.com/Applitools-Dev/sdk/commit/1e5b49e9aec6b8caf89f2cdb1f8e81a237d52896))
64
+ * @applitools/dom-capture bumped to 11.5.1
65
+ #### Code Refactoring
66
+
67
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
68
+ * @applitools/driver bumped to 1.19.7
69
+
70
+ * @applitools/spec-driver-webdriver bumped to 1.1.19
71
+ #### Code Refactoring
72
+
73
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
74
+
75
+
76
+
77
+ * @applitools/spec-driver-selenium bumped to 1.5.90
78
+
79
+ * @applitools/spec-driver-puppeteer bumped to 1.4.19
80
+
81
+ * @applitools/screenshoter bumped to 3.9.5
82
+
83
+ * @applitools/nml-client bumped to 1.8.17
84
+
85
+ * @applitools/tunnel-client bumped to 1.5.9
86
+ #### Code Refactoring
87
+
88
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
89
+
90
+
91
+
92
+ * @applitools/ufg-client bumped to 1.14.0
93
+ #### Features
94
+
95
+ * offline storybook ([#2596](https://github.com/Applitools-Dev/sdk/issues/2596)) ([c8edf80](https://github.com/Applitools-Dev/sdk/commit/c8edf80bc379d0cf5d94d798314bdad405d2f2b4))
96
+
97
+
98
+
99
+ * @applitools/core-base bumped to 1.19.2
100
+ #### Code Refactoring
101
+
102
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
103
+
104
+
105
+
106
+ * @applitools/ec-client bumped to 1.9.13
107
+ #### Code Refactoring
108
+
109
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
110
+
111
+
112
+
113
+ * @applitools/core bumped to 4.23.0
114
+ #### Features
115
+
116
+ * offline storybook ([#2596](https://github.com/Applitools-Dev/sdk/issues/2596)) ([c8edf80](https://github.com/Applitools-Dev/sdk/commit/c8edf80bc379d0cf5d94d798314bdad405d2f2b4))
117
+
118
+
119
+ #### Bug Fixes
120
+
121
+ * handle missing commits in parent and current branch ([#2586](https://github.com/Applitools-Dev/sdk/issues/2586)) ([3b40be5](https://github.com/Applitools-Dev/sdk/commit/3b40be544c36235b43121af82485bfc2e71d9e27))
122
+
123
+
124
+ #### Code Refactoring
125
+
126
+ * start linting "no-floating-promises" (wip) ([#2539](https://github.com/Applitools-Dev/sdk/issues/2539)) ([51b91cb](https://github.com/Applitools-Dev/sdk/commit/51b91cb15603f7d68e4bd6a16eb0f80e3f380295))
127
+
128
+
129
+
130
+
3
131
  ## [3.51.1](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.51.0...js/eyes-storybook@3.51.1) (2024-10-29)
4
132
 
5
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-storybook",
3
- "version": "3.51.1",
3
+ "version": "3.52.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "applitools",
@@ -54,14 +54,14 @@
54
54
  "up:framework": "cd test/fixtures/storybook-versions/${APPLITOOLS_FRAMEWORK_VERSION} && npm ci"
55
55
  },
56
56
  "dependencies": {
57
- "@applitools/core": "4.21.2",
58
- "@applitools/driver": "1.19.4",
57
+ "@applitools/core": "4.23.1",
58
+ "@applitools/driver": "1.19.7",
59
59
  "@applitools/functional-commons": "1.6.0",
60
- "@applitools/logger": "2.0.18",
60
+ "@applitools/logger": "2.0.19",
61
61
  "@applitools/monitoring-commons": "1.0.19",
62
- "@applitools/spec-driver-puppeteer": "1.4.16",
63
- "@applitools/ufg-client": "1.13.1",
64
- "@applitools/utils": "1.7.4",
62
+ "@applitools/spec-driver-puppeteer": "1.4.19",
63
+ "@applitools/ufg-client": "1.14.0",
64
+ "@applitools/utils": "1.7.5",
65
65
  "boxen": "4.2.0",
66
66
  "chalk": "3.0.0",
67
67
  "detect-port": "1.3.0",
package/src/cli.js CHANGED
@@ -16,6 +16,7 @@ const handleTapFile = require('./handleTapFile');
16
16
  const handleXmlFile = require('./handleXmlFile');
17
17
  const {presult} = require('@applitools/functional-commons');
18
18
  const chalk = require('chalk');
19
+ const utils = require('@applitools/utils');
19
20
  const {performance, timeItAsync} = makeTiming();
20
21
 
21
22
  (async function () {
@@ -41,7 +42,9 @@ const {performance, timeItAsync} = makeTiming();
41
42
  const [err, results] = await presult(
42
43
  timeItAsync('eyesStorybook', () => eyesStorybook({config, logger, performance, timeItAsync})),
43
44
  );
44
- if (err) {
45
+ if (utils.general.getEnvValue('OFFLINE_LOCATION_PATH')) {
46
+ process.exit();
47
+ } else if (err) {
45
48
  console.log(chalk.red(err.message));
46
49
  process.exit(config.exitcode ? 1 : 0);
47
50
  } else {
@@ -14,15 +14,13 @@ const browserLog = require('./browserLog');
14
14
  const getIframeUrl = require('./getIframeUrl');
15
15
  const createPagePool = require('./pagePool');
16
16
  const getClientAPI = require('../dist/getClientAPI');
17
- const {takeDomSnapshots} = require('@applitools/core');
18
- const {prepareTakeDomSnapshotsSettings} = require('./utils/prepare-settings');
17
+ const {mergeConfigs} = require('./utils/merge-configs');
19
18
  const {Driver} = require('@applitools/driver');
20
19
  const spec = require('@applitools/spec-driver-puppeteer');
21
20
  const {refineErrorMessage} = require('./errMessages');
22
21
  const executeRenders = require('./executeRenders');
23
22
  const {extractEnvironment} = require('./extractEnvironment');
24
23
  const {makeCore} = require('@applitools/core');
25
- const {makeUFGClient} = require('@applitools/ufg-client');
26
24
  const makeGetStoriesWithConfig = require('./getStoriesWithConfig');
27
25
 
28
26
  const MAX_RETRIES = 10;
@@ -91,7 +89,6 @@ async function eyesStorybook({
91
89
  });
92
90
 
93
91
  const getStoriesWithConfig = makeGetStoriesWithConfig({config});
94
- const client = await makeUFGClient({settings: {...account.ufgServer, ...account}, logger});
95
92
 
96
93
  const initPage = makeInitPage({
97
94
  iframeUrl,
@@ -103,35 +100,14 @@ async function eyesStorybook({
103
100
  });
104
101
  const pagePool = createPagePool({initPage, logger});
105
102
 
106
- const doTakeDomSnapshots = async ({
107
- page,
108
- environments,
109
- layoutBreakpoints,
110
- waitBeforeCapture,
111
- disableBrowserFetching,
112
- }) => {
103
+ const doTakeDomSnapshots = async ({page, ...settings}) => {
113
104
  const driver = await new Driver({spec, driver: page, logger});
114
- const skipResources = client.getCachedResourceUrls();
115
- const result = await takeDomSnapshots({
105
+ return await core.takeSnapshots({
116
106
  logger,
117
107
  driver,
118
- settings: prepareTakeDomSnapshotsSettings({
119
- config,
120
- options: {
121
- layoutBreakpoints,
122
- environments,
123
- waitBeforeCapture,
124
- skipResources,
125
- disableBrowserFetching,
126
- },
127
- }),
128
- provides: {
129
- getChromeEmulationDevices: client.getChromeEmulationDevices,
130
- getIOSDevices: client.getIOSDevices,
131
- },
132
- showLogs: config.showLogs,
108
+ settings: mergeConfigs({config, settings}),
109
+ account,
133
110
  });
134
- return result;
135
111
  };
136
112
 
137
113
  logger.log('got script for processPage');
@@ -1,4 +1,6 @@
1
1
  'use strict';
2
+
3
+ const {storyToCheckSettings} = require('./transformSettings');
2
4
  const {presult, ptimeoutWithError} = require('@applitools/functional-commons');
3
5
  const renderStoryWithClientAPI = require('../dist/renderStoryWithClientAPI');
4
6
  const runRunBeforeScript = require('../dist/runRunBeforeScript');
@@ -58,15 +60,13 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory}) {
58
60
  logger.log(`running takeDomSnapshot(s) for story ${title}`);
59
61
  const domSnapshotsPromise = takeDomSnapshots({
60
62
  page,
61
- environments: story.config.environments,
62
- layoutBreakpoints: story.config.layoutBreakpoints,
63
+ ...storyToCheckSettings({story}),
63
64
  waitBeforeCapture: wait
64
65
  ? async () => {
65
66
  logger.log(`waiting before screenshot of ${title} ${wait}`);
66
67
  await waitFor(page, wait);
67
68
  }
68
69
  : undefined,
69
- disableBrowserFetching: story.config.disableBrowserFetching,
70
70
  });
71
71
 
72
72
  const result = await ptimeoutWithError(
@@ -127,7 +127,7 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory}) {
127
127
  ? ` The detected version of storybook is ${error.version}.`
128
128
  : '';
129
129
  throw new Error(
130
- `Eyes could not render stories properly.${versionMsg} Contact support@applitools.com for troubleshooting.`,
130
+ `Eyes could not render stories properly.${versionMsg} Contact support@applitools.com for troubleshooting. Original error: ${error.message}`,
131
131
  );
132
132
  }
133
133
  };
@@ -135,8 +135,7 @@ function processResults({
135
135
  } else if (configExitCode === 'nodiffs') {
136
136
  exitCode = errors.length ? 1 : 0;
137
137
  } else {
138
- exitCode =
139
- !warnForUnsavedNewTests && passedOrNew.length && !errors.length && !unresolved.length ? 0 : 1;
138
+ exitCode = !warnForUnsavedNewTests && !errors.length && !unresolved.length ? 0 : 1;
140
139
  }
141
140
  return {
142
141
  outputStr,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
- const {deprecationWarning} = require('./errMessages');
3
2
  const throat = require('throat');
3
+ const {storyToCheckSettings, storyToOpenSettings} = require('./transformSettings');
4
4
 
5
5
  function makeRenderStory({
6
6
  logger,
@@ -14,117 +14,13 @@ function makeRenderStory({
14
14
  }) {
15
15
  const throttle = throat(storyDataGap);
16
16
  return function renderStory({story, snapshots, url}) {
17
- const config = story.config;
18
- const {name, kind, hasPlayFunction} = story;
19
17
  const baselineName = story.baselineName;
20
18
  const title = story.storyTitle;
21
- const {
22
- ignoreDisplacements,
23
- ignoreRegions,
24
- accessibilityRegions,
25
- floatingRegions,
26
- strictRegions,
27
- contentRegions,
28
- layoutRegions,
29
- scriptHooks,
30
- sizeMode,
31
- target,
32
- fully,
33
- selector,
34
- tag,
35
- properties,
36
- ignore,
37
- accessibilityValidation,
38
- sendDom,
39
- visualGridOptions,
40
- useDom,
41
- enablePatterns,
42
- environments,
43
- keepBatchOpen,
44
- batch,
45
- branchName,
46
- parentBranchName,
47
- baselineBranchName,
48
- compareWithParentBranch,
49
- ignoreGitMergeBase,
50
- baselineEnvName,
51
- envName,
52
- ignoreCaret,
53
- matchLevel,
54
- ignoreBaseline,
55
- domMapping,
56
- } = config;
57
-
58
- if (sizeMode) {
59
- console.log(deprecationWarning({deprecatedThing: "'sizeMode'", newThing: "'target'"}));
60
- }
61
-
62
- let ignoreRegionsBackCompat = ignoreRegions;
63
- if (ignore && ignoreRegions === undefined) {
64
- console.log(deprecationWarning({deprecatedThing: "'ignore'", newThing: "'ignoreRegions'"}));
65
- ignoreRegionsBackCompat = ignore;
66
- }
67
19
 
68
20
  logger.log(`running story ${title} with baseline ${baselineName}`);
69
21
 
70
- const storyProperties = [
71
- {name: 'Component name', value: kind},
72
- {name: 'State', value: name},
73
- ...(properties || []),
74
- ];
75
- if (hasPlayFunction) {
76
- storyProperties.push({name: 'Storybook play function', value: 'true'});
77
- }
78
-
79
- const openParams = {
80
- testName: baselineName,
81
- displayName: title,
82
- properties: storyProperties,
83
- appName,
84
- keepBatchOpen,
85
- batch,
86
- branchName,
87
- parentBranchName,
88
- baselineBranchName,
89
- compareWithParentBranch,
90
- ignoreGitBranching: ignoreGitMergeBase,
91
- baselineEnvName,
92
- environmentName: envName,
93
- ignoreBaseline,
94
- ...serverSettings,
95
- };
96
- const checkParams = {
97
- url,
98
- ignoreRegions: ignoreRegionsBackCompat,
99
- floatingRegions: mapFloatingRegions(floatingRegions),
100
- layoutRegions,
101
- strictRegions,
102
- contentRegions,
103
- accessibilityRegions: mapAccessibilityRegions(accessibilityRegions),
104
- environments,
105
- hooks: scriptHooks,
106
- sizeMode,
107
- region: target === 'region' ? selector : undefined,
108
- fully,
109
- tag,
110
- sendDom,
111
- ufgOptions: visualGridOptions,
112
- useDom,
113
- enablePatterns,
114
- ignoreDisplacements,
115
- fully,
116
- ignoreCaret,
117
- matchLevel,
118
- accessibilitySettings: accessibilityValidation
119
- ? {
120
- level: accessibilityValidation ? accessibilityValidation.level : undefined,
121
- version: accessibilityValidation
122
- ? accessibilityValidation.guidelinesVersion
123
- : undefined,
124
- }
125
- : undefined,
126
- domMapping,
127
- };
22
+ const openParams = storyToOpenSettings({story, appName, serverSettings});
23
+ const checkParams = storyToCheckSettings({story, url});
128
24
 
129
25
  return timeItAsync(baselineName, async () => {
130
26
  const eyes = await openEyes({settings: openParams});
@@ -139,7 +35,7 @@ function makeRenderStory({
139
35
  const results = await eyes.getResults();
140
36
  resolve(results);
141
37
  } else {
142
- await eyes.abort({settings: {environments}});
38
+ await eyes.abort({settings: {environments: checkParams.environments}});
143
39
  reject(
144
40
  new Error(`Failed to get story data for ${openParams.testName}, test was aborted`),
145
41
  );
@@ -151,68 +47,6 @@ function makeRenderStory({
151
47
  });
152
48
  }).then(onDoneStory);
153
49
 
154
- function mapAccessibilityRegions(accessabilityRegions) {
155
- if (!accessabilityRegions) return;
156
- if (!Array.isArray(accessabilityRegions)) accessabilityRegions = [accessabilityRegions];
157
- return accessabilityRegions.map(region => {
158
- const res = {
159
- type: region.accessibilityType,
160
- };
161
- if (region.selector) {
162
- res.region = region.selector;
163
- } else if (region.region && isRegion(region.region)) {
164
- res.region = {
165
- y: region.region.top,
166
- x: region.region.left,
167
- width: region.region.width,
168
- height: region.region.height,
169
- };
170
- } else {
171
- return;
172
- }
173
- return res;
174
- });
175
- }
176
-
177
- function mapFloatingRegions(floatingRegions) {
178
- if (!floatingRegions) return;
179
- if (!Array.isArray(floatingRegions)) floatingRegions = [floatingRegions];
180
- return floatingRegions.map(region => {
181
- let res = {
182
- offset: {
183
- bottom: region.maxDownOffset || 0,
184
- left: region.maxLeftOffset || 0,
185
- top: region.maxUpOffset || 0,
186
- right: region.maxRightOffset || 0,
187
- },
188
- };
189
- if (region.selector) {
190
- res.region = region.selector;
191
- } else if (region.region && isRegion(region.region)) {
192
- res.region = {
193
- y: region.region.top,
194
- x: region.region.left,
195
- width: region.region.width,
196
- height: region.region.height,
197
- };
198
- } else {
199
- return;
200
- }
201
- return res;
202
- });
203
- }
204
-
205
- function isRegion(region) {
206
- if (
207
- region.hasOwnProperty('top') &&
208
- region.hasOwnProperty('left') &&
209
- region.hasOwnProperty('width') &&
210
- region.hasOwnProperty('height')
211
- ) {
212
- return true;
213
- }
214
- }
215
-
216
50
  function onDoneStory(results) {
217
51
  logger.log('finished story', baselineName, 'in', performance[baselineName]);
218
52
  return results;
@@ -0,0 +1,186 @@
1
+ const {deprecationWarning} = require('./errMessages');
2
+
3
+ function storyToOpenSettings({story, appName, serverSettings}) {
4
+ const {name, kind, hasPlayFunction, config} = story;
5
+
6
+ const {
7
+ keepBatchOpen,
8
+ batch,
9
+ branchName,
10
+ parentBranchName,
11
+ baselineBranchName,
12
+ compareWithParentBranch,
13
+ ignoreGitMergeBase,
14
+ baselineEnvName,
15
+ envName,
16
+ ignoreBaseline,
17
+ properties,
18
+ } = config;
19
+
20
+ const storyProperties = [
21
+ {name: 'Component name', value: kind},
22
+ {name: 'State', value: name},
23
+ ...(properties || []),
24
+ ];
25
+ if (hasPlayFunction) {
26
+ storyProperties.push({name: 'Storybook play function', value: 'true'});
27
+ }
28
+
29
+ return {
30
+ testName: story.baselineName,
31
+ displayName: story.storyTitle,
32
+ properties: storyProperties,
33
+ appName,
34
+ keepBatchOpen,
35
+ batch,
36
+ branchName,
37
+ parentBranchName,
38
+ baselineBranchName,
39
+ compareWithParentBranch,
40
+ ignoreGitBranching: ignoreGitMergeBase,
41
+ baselineEnvName,
42
+ environmentName: envName,
43
+ ignoreBaseline,
44
+ ...serverSettings,
45
+ };
46
+ }
47
+
48
+ function storyToCheckSettings({story, url}) {
49
+ const {
50
+ ignoreDisplacements,
51
+ ignoreRegions,
52
+ accessibilityRegions,
53
+ floatingRegions,
54
+ strictRegions,
55
+ contentRegions,
56
+ layoutRegions,
57
+ scriptHooks,
58
+ sizeMode,
59
+ target,
60
+ fully,
61
+ selector,
62
+ tag,
63
+ ignore,
64
+ accessibilityValidation,
65
+ sendDom,
66
+ visualGridOptions,
67
+ useDom,
68
+ enablePatterns,
69
+ environments,
70
+ ignoreCaret,
71
+ matchLevel,
72
+ domMapping,
73
+ layoutBreakpoints,
74
+ disableBrowserFetching,
75
+ } = story.config;
76
+
77
+ if (sizeMode) {
78
+ console.log(deprecationWarning({deprecatedThing: "'sizeMode'", newThing: "'target'"}));
79
+ }
80
+
81
+ let ignoreRegionsBackCompat = ignoreRegions;
82
+ if (ignore && ignoreRegions === undefined) {
83
+ console.log(deprecationWarning({deprecatedThing: "'ignore'", newThing: "'ignoreRegions'"}));
84
+ ignoreRegionsBackCompat = ignore;
85
+ }
86
+
87
+ return {
88
+ url,
89
+ ignoreRegions: ignoreRegionsBackCompat,
90
+ floatingRegions: mapFloatingRegions(floatingRegions),
91
+ layoutRegions,
92
+ strictRegions,
93
+ contentRegions,
94
+ accessibilityRegions: mapAccessibilityRegions(accessibilityRegions),
95
+ environments,
96
+ hooks: scriptHooks,
97
+ sizeMode,
98
+ region: target === 'region' ? selector : undefined,
99
+ fully,
100
+ tag,
101
+ sendDom,
102
+ ufgOptions: visualGridOptions,
103
+ useDom,
104
+ enablePatterns,
105
+ ignoreDisplacements,
106
+ fully,
107
+ ignoreCaret,
108
+ matchLevel,
109
+ accessibilitySettings: accessibilityValidation
110
+ ? {
111
+ level: accessibilityValidation ? accessibilityValidation.level : undefined,
112
+ version: accessibilityValidation ? accessibilityValidation.guidelinesVersion : undefined,
113
+ }
114
+ : undefined,
115
+ domMapping,
116
+ layoutBreakpoints,
117
+ disableBrowserFetching,
118
+ };
119
+ }
120
+
121
+ function mapFloatingRegions(floatingRegions) {
122
+ if (!floatingRegions) return;
123
+ if (!Array.isArray(floatingRegions)) floatingRegions = [floatingRegions];
124
+ return floatingRegions.map(region => {
125
+ let res = {
126
+ offset: {
127
+ bottom: region.maxDownOffset || 0,
128
+ left: region.maxLeftOffset || 0,
129
+ top: region.maxUpOffset || 0,
130
+ right: region.maxRightOffset || 0,
131
+ },
132
+ };
133
+ if (region.selector) {
134
+ res.region = region.selector;
135
+ } else if (region.region && isRegion(region.region)) {
136
+ res.region = {
137
+ y: region.region.top,
138
+ x: region.region.left,
139
+ width: region.region.width,
140
+ height: region.region.height,
141
+ };
142
+ } else {
143
+ return;
144
+ }
145
+ return res;
146
+ });
147
+ }
148
+
149
+ function mapAccessibilityRegions(accessabilityRegions) {
150
+ if (!accessabilityRegions) return;
151
+ if (!Array.isArray(accessabilityRegions)) accessabilityRegions = [accessabilityRegions];
152
+ return accessabilityRegions.map(region => {
153
+ const res = {
154
+ type: region.accessibilityType,
155
+ };
156
+ if (region.selector) {
157
+ res.region = region.selector;
158
+ } else if (region.region && isRegion(region.region)) {
159
+ res.region = {
160
+ y: region.region.top,
161
+ x: region.region.left,
162
+ width: region.region.width,
163
+ height: region.region.height,
164
+ };
165
+ } else {
166
+ return;
167
+ }
168
+ return res;
169
+ });
170
+ }
171
+
172
+ function isRegion(region) {
173
+ if (
174
+ region.hasOwnProperty('top') &&
175
+ region.hasOwnProperty('left') &&
176
+ region.hasOwnProperty('width') &&
177
+ region.hasOwnProperty('height')
178
+ ) {
179
+ return true;
180
+ }
181
+ }
182
+
183
+ module.exports = {
184
+ storyToOpenSettings,
185
+ storyToCheckSettings,
186
+ };
@@ -0,0 +1,17 @@
1
+ function mergeConfigs({config, settings}) {
2
+ return {
3
+ ...settings,
4
+ layoutBreakpoints:
5
+ settings.layoutBreakpoints !== undefined
6
+ ? settings.layoutBreakpoints
7
+ : config.layoutBreakpoints,
8
+ disableBrowserFetching:
9
+ settings.disableBrowserFetching !== undefined
10
+ ? settings.disableBrowserFetching
11
+ : config.disableBrowserFetching,
12
+ };
13
+ }
14
+
15
+ module.exports = {
16
+ mergeConfigs,
17
+ };
@@ -1,14 +0,0 @@
1
- function prepareTakeDomSnapshotsSettings({config, options}) {
2
- let result = {...options};
3
- result.layoutBreakpoints =
4
- result.layoutBreakpoints !== undefined ? result.layoutBreakpoints : config.layoutBreakpoints;
5
- result.disableBrowserFetching =
6
- result.disableBrowserFetching !== undefined
7
- ? result.disableBrowserFetching
8
- : config.disableBrowserFetching;
9
- return result;
10
- }
11
-
12
- module.exports = {
13
- prepareTakeDomSnapshotsSettings,
14
- };