@applitools/eyes-storybook 3.49.0 → 3.50.2

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,105 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.50.2](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.50.1...js/eyes-storybook@3.50.2) (2024-05-01)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * @applitools/dom-snapshot bumped to 4.11.1
9
+ #### Bug Fixes
10
+
11
+ * support for using unicode and just using escape with numbers ([#2241](https://github.com/Applitools-Dev/sdk/issues/2241)) ([c59f47f](https://github.com/Applitools-Dev/sdk/commit/c59f47f73585d7f308c43c9ee1845e097a2111a3))
12
+ * @applitools/driver bumped to 1.17.2
13
+ #### Bug Fixes
14
+
15
+ * cache nml client per driver ([#2336](https://github.com/Applitools-Dev/sdk/issues/2336)) ([02c09a5](https://github.com/Applitools-Dev/sdk/commit/02c09a53eb6ca6340c93365908f4c485ab389c21))
16
+ * @applitools/core-base bumped to 1.13.0
17
+ #### Features
18
+
19
+ * `matchTimeout` ([#2309](https://github.com/Applitools-Dev/sdk/issues/2309)) ([626529e](https://github.com/Applitools-Dev/sdk/commit/626529e839fd2a96ac0de98332f42873c0f387a4))
20
+ * @applitools/spec-driver-webdriver bumped to 1.1.7
21
+
22
+ * @applitools/spec-driver-selenium bumped to 1.5.78
23
+
24
+ * @applitools/spec-driver-puppeteer bumped to 1.4.7
25
+
26
+ * @applitools/screenshoter bumped to 3.8.31
27
+
28
+ * @applitools/nml-client bumped to 1.8.4
29
+
30
+ * @applitools/ec-client bumped to 1.8.4
31
+
32
+ * @applitools/core bumped to 4.14.0
33
+ #### Features
34
+
35
+ * `matchTimeout` ([#2309](https://github.com/Applitools-Dev/sdk/issues/2309)) ([626529e](https://github.com/Applitools-Dev/sdk/commit/626529e839fd2a96ac0de98332f42873c0f387a4))
36
+
37
+
38
+ #### Bug Fixes
39
+
40
+ * cache nml client per driver ([#2336](https://github.com/Applitools-Dev/sdk/issues/2336)) ([02c09a5](https://github.com/Applitools-Dev/sdk/commit/02c09a53eb6ca6340c93365908f4c485ab389c21))
41
+ * support for using unicode and just using escape with numbers ([#2241](https://github.com/Applitools-Dev/sdk/issues/2241)) ([c59f47f](https://github.com/Applitools-Dev/sdk/commit/c59f47f73585d7f308c43c9ee1845e097a2111a3))
42
+
43
+
44
+
45
+
46
+ ## [3.50.1](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.50.0...js/eyes-storybook@3.50.1) (2024-04-22)
47
+
48
+
49
+ ### Dependencies
50
+
51
+ * @applitools/dom-snapshot bumped to 4.11.0
52
+ #### Features
53
+
54
+ * extract url from embed element ([#2285](https://github.com/Applitools-Dev/sdk/issues/2285)) ([3c4da0d](https://github.com/Applitools-Dev/sdk/commit/3c4da0dbd061cb2fc4313392196012ffd4601d0e))
55
+ * @applitools/driver bumped to 1.17.0
56
+ #### Features
57
+
58
+ * report batchId and batchUrl to kobiton ([#2329](https://github.com/Applitools-Dev/sdk/issues/2329)) ([5be4356](https://github.com/Applitools-Dev/sdk/commit/5be4356d7f3cd96b70491325d4a788202c06720a))
59
+ * @applitools/core-base bumped to 1.12.0
60
+ #### Features
61
+
62
+ * ability to override baseline parameters per environment ([#2332](https://github.com/Applitools-Dev/sdk/issues/2332)) ([43b8b18](https://github.com/Applitools-Dev/sdk/commit/43b8b189fb3c9dd19aa3be372e8fcc0fe8edfa50))
63
+ * @applitools/spec-driver-webdriver bumped to 1.1.5
64
+
65
+ * @applitools/spec-driver-selenium bumped to 1.5.76
66
+
67
+ * @applitools/spec-driver-puppeteer bumped to 1.4.5
68
+
69
+ * @applitools/screenshoter bumped to 3.8.29
70
+
71
+ * @applitools/nml-client bumped to 1.8.2
72
+
73
+ * @applitools/ec-client bumped to 1.8.2
74
+
75
+ * @applitools/core bumped to 4.13.0
76
+ #### Features
77
+
78
+ * ability to override baseline parameters per environment ([#2332](https://github.com/Applitools-Dev/sdk/issues/2332)) ([43b8b18](https://github.com/Applitools-Dev/sdk/commit/43b8b189fb3c9dd19aa3be372e8fcc0fe8edfa50))
79
+ * report batchId and batchUrl to kobiton ([#2329](https://github.com/Applitools-Dev/sdk/issues/2329)) ([5be4356](https://github.com/Applitools-Dev/sdk/commit/5be4356d7f3cd96b70491325d4a788202c06720a))
80
+
81
+
82
+
83
+
84
+ ## [3.50.0](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook-v3.49.1...js/eyes-storybook@3.50.0) (2024-04-17)
85
+
86
+
87
+ ### Features
88
+
89
+ * added notification about outdated sdk version ([#2012](https://github.com/Applitools-Dev/sdk/issues/2012)) ([0f0a646](https://github.com/Applitools-Dev/sdk/commit/0f0a6462a56e7c97f9a22173c3b63af91e220adb))
90
+
91
+
92
+ ### Bug Fixes
93
+
94
+ * lodash.pick vulnerability ([#2169](https://github.com/Applitools-Dev/sdk/issues/2169)) ([7354088](https://github.com/Applitools-Dev/sdk/commit/735408874e4917f5e9b086e1796f84101fd1f304))
95
+ * storybook upgrade puppeteer ([#2260](https://github.com/Applitools-Dev/sdk/issues/2260)) ([cb419a5](https://github.com/Applitools-Dev/sdk/commit/cb419a541cdfefaf7ab01727647ee40a002cb78a))
96
+ * support storybook 8 ([#2293](https://github.com/Applitools-Dev/sdk/issues/2293)) ([3611510](https://github.com/Applitools-Dev/sdk/commit/3611510cb7fa56f6930f0a66f9bab41a3acf0f7a))
97
+
98
+
99
+ ### Code Refactoring
100
+
101
+ * fix safe selector generation ([#2072](https://github.com/Applitools-Dev/sdk/issues/2072)) ([373f11b](https://github.com/Applitools-Dev/sdk/commit/373f11b0dfea6eab417eb7077e0cfec79877dc1b))
102
+
3
103
  ## [3.49.0](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook-v3.48.2...js/eyes-storybook@3.49.0) (2024-04-15)
4
104
 
5
105
 
@@ -8,6 +8,7 @@ function __getClientAPI(...args) {
8
8
  v5: 'v5',
9
9
  v5_2: 'v5_2',
10
10
  v6_4: 'v6_4',
11
+ v8: 'v8',
11
12
  };
12
13
 
13
14
  function getClientAPI() {
@@ -20,7 +21,9 @@ function __getClientAPI(...args) {
20
21
  function getStorybookVersion() {
21
22
  const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
23
 
23
- if (frameWindow.__STORYBOOK_PREVIEW__) {
24
+ if (!clientAPI && frameWindow.__STORYBOOK_PREVIEW__) {
25
+ return API_VERSIONS.v8;
26
+ } else if (frameWindow.__STORYBOOK_PREVIEW__) {
24
27
  return API_VERSIONS.v6_4;
25
28
  } else if (frameWindow.__STORYBOOK_STORY_STORE__) {
26
29
  return API_VERSIONS.v5_2;
@@ -39,17 +42,18 @@ function __getClientAPI(...args) {
39
42
  }
40
43
  }
41
44
  function onStoryRendered(callback) {
42
- if (addons && addons.channel && addons.channel.once) {
43
- addons.channel.once('storyRendered', () => {
45
+ const channel = addons?.getChannel?.();
46
+ if (channel) {
47
+ channel.once('storyRendered', () => {
44
48
  setTimeout(callback, 0);
45
49
  });
46
- addons.channel.once('playFunctionThrewException', () => {
50
+ channel.once('playFunctionThrewException', () => {
47
51
  setTimeout(callback, 0);
48
52
  });
49
- addons.channel.once('storyErrored', () => {
53
+ channel.once('storyErrored', () => {
50
54
  setTimeout(callback, 0);
51
55
  });
52
- addons.channel.once('storyThrewException', () => {
56
+ channel.once('storyThrewException', () => {
53
57
  setTimeout(callback, 0);
54
58
  });
55
59
  } else {
@@ -134,6 +138,20 @@ function __getClientAPI(...args) {
134
138
  };
135
139
  break;
136
140
  }
141
+
142
+ case API_VERSIONS.v8: {
143
+ api = {
144
+ getStories: async () => {
145
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
146
+ return Object.values(await frameWindow.__STORYBOOK_PREVIEW__.extract());
147
+ },
148
+ selectStory: async (_i, id) => {
149
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
150
+ frameWindow.__STORYBOOK_ADDONS_PREVIEW.channel.emit('setCurrentStory', {storyId: id});
151
+ },
152
+ onStoryRendered,
153
+ };
154
+ }
137
155
  }
138
156
 
139
157
  return {version, ...api};
@@ -8,6 +8,7 @@ function __getStories(...args) {
8
8
  v5: 'v5',
9
9
  v5_2: 'v5_2',
10
10
  v6_4: 'v6_4',
11
+ v8: 'v8',
11
12
  };
12
13
 
13
14
  function getClientAPI() {
@@ -20,7 +21,9 @@ function __getStories(...args) {
20
21
  function getStorybookVersion() {
21
22
  const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
23
 
23
- if (frameWindow.__STORYBOOK_PREVIEW__) {
24
+ if (!clientAPI && frameWindow.__STORYBOOK_PREVIEW__) {
25
+ return API_VERSIONS.v8;
26
+ } else if (frameWindow.__STORYBOOK_PREVIEW__) {
24
27
  return API_VERSIONS.v6_4;
25
28
  } else if (frameWindow.__STORYBOOK_STORY_STORE__) {
26
29
  return API_VERSIONS.v5_2;
@@ -39,17 +42,18 @@ function __getStories(...args) {
39
42
  }
40
43
  }
41
44
  function onStoryRendered(callback) {
42
- if (addons && addons.channel && addons.channel.once) {
43
- addons.channel.once('storyRendered', () => {
45
+ const channel = addons?.getChannel?.();
46
+ if (channel) {
47
+ channel.once('storyRendered', () => {
44
48
  setTimeout(callback, 0);
45
49
  });
46
- addons.channel.once('playFunctionThrewException', () => {
50
+ channel.once('playFunctionThrewException', () => {
47
51
  setTimeout(callback, 0);
48
52
  });
49
- addons.channel.once('storyErrored', () => {
53
+ channel.once('storyErrored', () => {
50
54
  setTimeout(callback, 0);
51
55
  });
52
- addons.channel.once('storyThrewException', () => {
56
+ channel.once('storyThrewException', () => {
53
57
  setTimeout(callback, 0);
54
58
  });
55
59
  } else {
@@ -134,6 +138,20 @@ function __getStories(...args) {
134
138
  };
135
139
  break;
136
140
  }
141
+
142
+ case API_VERSIONS.v8: {
143
+ api = {
144
+ getStories: async () => {
145
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
146
+ return Object.values(await frameWindow.__STORYBOOK_PREVIEW__.extract());
147
+ },
148
+ selectStory: async (_i, id) => {
149
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
150
+ frameWindow.__STORYBOOK_ADDONS_PREVIEW.channel.emit('setCurrentStory', {storyId: id});
151
+ },
152
+ onStoryRendered,
153
+ };
154
+ }
137
155
  }
138
156
 
139
157
  return {version, ...api};
@@ -8,6 +8,7 @@ function __renderStoryWithClientAPI(...args) {
8
8
  v5: 'v5',
9
9
  v5_2: 'v5_2',
10
10
  v6_4: 'v6_4',
11
+ v8: 'v8',
11
12
  };
12
13
 
13
14
  function getClientAPI() {
@@ -20,7 +21,9 @@ function __renderStoryWithClientAPI(...args) {
20
21
  function getStorybookVersion() {
21
22
  const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
23
 
23
- if (frameWindow.__STORYBOOK_PREVIEW__) {
24
+ if (!clientAPI && frameWindow.__STORYBOOK_PREVIEW__) {
25
+ return API_VERSIONS.v8;
26
+ } else if (frameWindow.__STORYBOOK_PREVIEW__) {
24
27
  return API_VERSIONS.v6_4;
25
28
  } else if (frameWindow.__STORYBOOK_STORY_STORE__) {
26
29
  return API_VERSIONS.v5_2;
@@ -39,17 +42,18 @@ function __renderStoryWithClientAPI(...args) {
39
42
  }
40
43
  }
41
44
  function onStoryRendered(callback) {
42
- if (addons && addons.channel && addons.channel.once) {
43
- addons.channel.once('storyRendered', () => {
45
+ const channel = addons?.getChannel?.();
46
+ if (channel) {
47
+ channel.once('storyRendered', () => {
44
48
  setTimeout(callback, 0);
45
49
  });
46
- addons.channel.once('playFunctionThrewException', () => {
50
+ channel.once('playFunctionThrewException', () => {
47
51
  setTimeout(callback, 0);
48
52
  });
49
- addons.channel.once('storyErrored', () => {
53
+ channel.once('storyErrored', () => {
50
54
  setTimeout(callback, 0);
51
55
  });
52
- addons.channel.once('storyThrewException', () => {
56
+ channel.once('storyThrewException', () => {
53
57
  setTimeout(callback, 0);
54
58
  });
55
59
  } else {
@@ -134,6 +138,20 @@ function __renderStoryWithClientAPI(...args) {
134
138
  };
135
139
  break;
136
140
  }
141
+
142
+ case API_VERSIONS.v8: {
143
+ api = {
144
+ getStories: async () => {
145
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
146
+ return Object.values(await frameWindow.__STORYBOOK_PREVIEW__.extract());
147
+ },
148
+ selectStory: async (_i, id) => {
149
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
150
+ frameWindow.__STORYBOOK_ADDONS_PREVIEW.channel.emit('setCurrentStory', {storyId: id});
151
+ },
152
+ onStoryRendered,
153
+ };
154
+ }
137
155
  }
138
156
 
139
157
  return {version, ...api};
@@ -166,11 +184,11 @@ function __renderStoryWithClientAPI(...args) {
166
184
  var getClientAPI_1 = getClientAPI;
167
185
 
168
186
  function renderStoryWithClientAPI(index, id) {
169
- return new Promise(resolve => {
187
+ return new Promise(async resolve => {
170
188
  let api;
171
189
  try {
172
190
  api = getClientAPI_1();
173
- api.selectStory(index, id);
191
+ await api.selectStory(index, id);
174
192
  api.onStoryRendered(resolve);
175
193
  } catch (ex) {
176
194
  resolve({message: ex.message, version: api ? api.version : undefined});
@@ -8,6 +8,7 @@ function __runRunAfterScript(...args) {
8
8
  v5: 'v5',
9
9
  v5_2: 'v5_2',
10
10
  v6_4: 'v6_4',
11
+ v8: 'v8',
11
12
  };
12
13
 
13
14
  function getClientAPI() {
@@ -20,7 +21,9 @@ function __runRunAfterScript(...args) {
20
21
  function getStorybookVersion() {
21
22
  const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
23
 
23
- if (frameWindow.__STORYBOOK_PREVIEW__) {
24
+ if (!clientAPI && frameWindow.__STORYBOOK_PREVIEW__) {
25
+ return API_VERSIONS.v8;
26
+ } else if (frameWindow.__STORYBOOK_PREVIEW__) {
24
27
  return API_VERSIONS.v6_4;
25
28
  } else if (frameWindow.__STORYBOOK_STORY_STORE__) {
26
29
  return API_VERSIONS.v5_2;
@@ -39,17 +42,18 @@ function __runRunAfterScript(...args) {
39
42
  }
40
43
  }
41
44
  function onStoryRendered(callback) {
42
- if (addons && addons.channel && addons.channel.once) {
43
- addons.channel.once('storyRendered', () => {
45
+ const channel = addons?.getChannel?.();
46
+ if (channel) {
47
+ channel.once('storyRendered', () => {
44
48
  setTimeout(callback, 0);
45
49
  });
46
- addons.channel.once('playFunctionThrewException', () => {
50
+ channel.once('playFunctionThrewException', () => {
47
51
  setTimeout(callback, 0);
48
52
  });
49
- addons.channel.once('storyErrored', () => {
53
+ channel.once('storyErrored', () => {
50
54
  setTimeout(callback, 0);
51
55
  });
52
- addons.channel.once('storyThrewException', () => {
56
+ channel.once('storyThrewException', () => {
53
57
  setTimeout(callback, 0);
54
58
  });
55
59
  } else {
@@ -134,6 +138,20 @@ function __runRunAfterScript(...args) {
134
138
  };
135
139
  break;
136
140
  }
141
+
142
+ case API_VERSIONS.v8: {
143
+ api = {
144
+ getStories: async () => {
145
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
146
+ return Object.values(await frameWindow.__STORYBOOK_PREVIEW__.extract());
147
+ },
148
+ selectStory: async (_i, id) => {
149
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
150
+ frameWindow.__STORYBOOK_ADDONS_PREVIEW.channel.emit('setCurrentStory', {storyId: id});
151
+ },
152
+ onStoryRendered,
153
+ };
154
+ }
137
155
  }
138
156
 
139
157
  return {version, ...api};
@@ -8,6 +8,7 @@ function __runRunBeforeScript(...args) {
8
8
  v5: 'v5',
9
9
  v5_2: 'v5_2',
10
10
  v6_4: 'v6_4',
11
+ v8: 'v8',
11
12
  };
12
13
 
13
14
  function getClientAPI() {
@@ -20,7 +21,9 @@ function __runRunBeforeScript(...args) {
20
21
  function getStorybookVersion() {
21
22
  const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
23
 
23
- if (frameWindow.__STORYBOOK_PREVIEW__) {
24
+ if (!clientAPI && frameWindow.__STORYBOOK_PREVIEW__) {
25
+ return API_VERSIONS.v8;
26
+ } else if (frameWindow.__STORYBOOK_PREVIEW__) {
24
27
  return API_VERSIONS.v6_4;
25
28
  } else if (frameWindow.__STORYBOOK_STORY_STORE__) {
26
29
  return API_VERSIONS.v5_2;
@@ -39,17 +42,18 @@ function __runRunBeforeScript(...args) {
39
42
  }
40
43
  }
41
44
  function onStoryRendered(callback) {
42
- if (addons && addons.channel && addons.channel.once) {
43
- addons.channel.once('storyRendered', () => {
45
+ const channel = addons?.getChannel?.();
46
+ if (channel) {
47
+ channel.once('storyRendered', () => {
44
48
  setTimeout(callback, 0);
45
49
  });
46
- addons.channel.once('playFunctionThrewException', () => {
50
+ channel.once('playFunctionThrewException', () => {
47
51
  setTimeout(callback, 0);
48
52
  });
49
- addons.channel.once('storyErrored', () => {
53
+ channel.once('storyErrored', () => {
50
54
  setTimeout(callback, 0);
51
55
  });
52
- addons.channel.once('storyThrewException', () => {
56
+ channel.once('storyThrewException', () => {
53
57
  setTimeout(callback, 0);
54
58
  });
55
59
  } else {
@@ -134,6 +138,20 @@ function __runRunBeforeScript(...args) {
134
138
  };
135
139
  break;
136
140
  }
141
+
142
+ case API_VERSIONS.v8: {
143
+ api = {
144
+ getStories: async () => {
145
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
146
+ return Object.values(await frameWindow.__STORYBOOK_PREVIEW__.extract());
147
+ },
148
+ selectStory: async (_i, id) => {
149
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
150
+ frameWindow.__STORYBOOK_ADDONS_PREVIEW.channel.emit('setCurrentStory', {storyId: id});
151
+ },
152
+ onStoryRendered,
153
+ };
154
+ }
137
155
  }
138
156
 
139
157
  return {version, ...api};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-storybook",
3
- "version": "3.49.0",
3
+ "version": "3.50.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "applitools",
@@ -54,20 +54,21 @@
54
54
  "up:framework": "cd test/fixtures/storybook-versions/${APPLITOOLS_FRAMEWORK_VERSION} && npm ci"
55
55
  },
56
56
  "dependencies": {
57
- "@applitools/core": "4.12.2",
58
- "@applitools/driver": "1.16.6",
57
+ "@applitools/core": "4.14.0",
58
+ "@applitools/driver": "1.17.2",
59
59
  "@applitools/functional-commons": "1.6.0",
60
- "@applitools/logger": "2.0.15",
60
+ "@applitools/logger": "2.0.16",
61
61
  "@applitools/monitoring-commons": "1.0.19",
62
- "@applitools/spec-driver-puppeteer": "1.4.4",
63
- "@applitools/ufg-client": "1.11.1",
64
- "@applitools/utils": "1.7.1",
62
+ "@applitools/spec-driver-puppeteer": "1.4.7",
63
+ "@applitools/ufg-client": "1.11.2",
64
+ "@applitools/utils": "1.7.2",
65
65
  "boxen": "4.2.0",
66
66
  "chalk": "3.0.0",
67
67
  "detect-port": "1.3.0",
68
68
  "lodash": "4.17.21",
69
69
  "ora": "3.4.0",
70
70
  "puppeteer": "21.11.0",
71
+ "semver": "7.5.4",
71
72
  "strip-ansi": "6.0.0",
72
73
  "throat": "6.0.2",
73
74
  "yargs": "17.7.2"
@@ -6,7 +6,7 @@
6
6
  "browser": true
7
7
  },
8
8
  "parserOptions": {
9
- "ecmaVersion": 2018
9
+ "ecmaVersion": 2022
10
10
  },
11
11
  "plugins": [
12
12
  "prettier"
@@ -5,6 +5,7 @@ const API_VERSIONS = {
5
5
  v5: 'v5',
6
6
  v5_2: 'v5_2',
7
7
  v6_4: 'v6_4',
8
+ v8: 'v8',
8
9
  };
9
10
 
10
11
  function getClientAPI() {
@@ -17,7 +18,9 @@ function getClientAPI() {
17
18
  function getStorybookVersion() {
18
19
  const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
19
20
 
20
- if (frameWindow.__STORYBOOK_PREVIEW__) {
21
+ if (!clientAPI && frameWindow.__STORYBOOK_PREVIEW__) {
22
+ return API_VERSIONS.v8;
23
+ } else if (frameWindow.__STORYBOOK_PREVIEW__) {
21
24
  return API_VERSIONS.v6_4;
22
25
  } else if (frameWindow.__STORYBOOK_STORY_STORE__) {
23
26
  return API_VERSIONS.v5_2;
@@ -36,17 +39,18 @@ function getClientAPI() {
36
39
  }
37
40
  }
38
41
  function onStoryRendered(callback) {
39
- if (addons && addons.channel && addons.channel.once) {
40
- addons.channel.once('storyRendered', () => {
42
+ const channel = addons?.getChannel?.();
43
+ if (channel) {
44
+ channel.once('storyRendered', () => {
41
45
  setTimeout(callback, 0);
42
46
  });
43
- addons.channel.once('playFunctionThrewException', () => {
47
+ channel.once('playFunctionThrewException', () => {
44
48
  setTimeout(callback, 0);
45
49
  });
46
- addons.channel.once('storyErrored', () => {
50
+ channel.once('storyErrored', () => {
47
51
  setTimeout(callback, 0);
48
52
  });
49
- addons.channel.once('storyThrewException', () => {
53
+ channel.once('storyThrewException', () => {
50
54
  setTimeout(callback, 0);
51
55
  });
52
56
  } else {
@@ -131,6 +135,20 @@ function getClientAPI() {
131
135
  };
132
136
  break;
133
137
  }
138
+
139
+ case API_VERSIONS.v8: {
140
+ api = {
141
+ getStories: async () => {
142
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
143
+ return Object.values(await frameWindow.__STORYBOOK_PREVIEW__.extract());
144
+ },
145
+ selectStory: async (_i, id) => {
146
+ await frameWindow.__STORYBOOK_PREVIEW__.ready();
147
+ frameWindow.__STORYBOOK_ADDONS_PREVIEW.channel.emit('setCurrentStory', {storyId: id});
148
+ },
149
+ onStoryRendered,
150
+ };
151
+ }
134
152
  }
135
153
 
136
154
  return {version, ...api};
@@ -1,11 +1,11 @@
1
1
  const getClientAPI = require('./getClientAPI');
2
2
 
3
3
  function renderStoryWithClientAPI(index, id) {
4
- return new Promise(resolve => {
4
+ return new Promise(async resolve => {
5
5
  let api;
6
6
  try {
7
7
  api = getClientAPI();
8
- api.selectStory(index, id);
8
+ await api.selectStory(index, id);
9
9
  api.onStoryRendered(resolve);
10
10
  } catch (ex) {
11
11
  resolve({message: ex.message, version: api ? api.version : undefined});
package/src/cli.js CHANGED
@@ -32,16 +32,14 @@ const {performance, timeItAsync} = makeTiming();
32
32
  console.log(`Using @applitools/eyes-storybook version ${VERSION}.\n`);
33
33
  const config = generateConfig({argv, defaultConfig, externalConfigParams});
34
34
  const logger = makeLogger({level: config.showLogs ? 'info' : 'silent', label: 'eyes'});
35
- const isVersion7 = await validateAndPopulateConfig({
35
+ await validateAndPopulateConfig({
36
36
  config,
37
37
  logger,
38
38
  packagePath: process.cwd(),
39
39
  });
40
40
  logger.log(`Running with the following config:\n${configDigest(config)}`);
41
41
  const [err, results] = await presult(
42
- timeItAsync('eyesStorybook', () =>
43
- eyesStorybook({config, logger, performance, timeItAsync, isVersion7}),
44
- ),
42
+ timeItAsync('eyesStorybook', () => eyesStorybook({config, logger, performance, timeItAsync})),
45
43
  );
46
44
  if (err) {
47
45
  console.log(chalk.red(err.message));
@@ -34,7 +34,6 @@ async function eyesStorybook({
34
34
  performance,
35
35
  timeItAsync,
36
36
  outputStream = process.stderr,
37
- isVersion7,
38
37
  }) {
39
38
  let renderIE = false;
40
39
  let transitioning = false;
@@ -199,7 +198,6 @@ async function eyesStorybook({
199
198
  logger,
200
199
  stream: outputStream,
201
200
  pagePool,
202
- isVersion7,
203
201
  });
204
202
 
205
203
  logger.log('finished creating functions');
@@ -38,6 +38,7 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory}) {
38
38
  }
39
39
  } else {
40
40
  await renderStoryLegacy();
41
+ await waitFor(page, 'body.sb-show-main');
41
42
  }
42
43
  } else {
43
44
  await renderStoryLegacy();
@@ -1,14 +1,8 @@
1
1
  'use strict';
2
2
  const getIframeUrl = require('./getIframeUrl');
3
3
 
4
- function getStoryUrl({name, kind, parameters, id}, baseUrl, isVersion7) {
5
- let storyUrl = getIframeUrl(baseUrl);
6
- if (!isVersion7) {
7
- storyUrl += `&selectedKind=${encodeURIComponent(kind)}`;
8
- storyUrl += `&selectedStory=${encodeURIComponent(name)}`;
9
- } else {
10
- storyUrl += `&path=/story/${encodeURIComponent(id)}`;
11
- }
4
+ function getStoryUrl({parameters, id}, baseUrl) {
5
+ let storyUrl = `${getIframeUrl(baseUrl)}&path=/story/${encodeURIComponent(id)}`;
12
6
 
13
7
  const queryParams = parameters && parameters.eyes && parameters.eyes.queryParams;
14
8
  if (queryParams) {
@@ -13,7 +13,6 @@ function makeRenderStories({
13
13
  stream,
14
14
  getClientAPI,
15
15
  maxPageTTL = 60000,
16
- isVersion7,
17
16
  }) {
18
17
  let newPageIdToAdd;
19
18
 
@@ -57,7 +56,7 @@ function makeRenderStories({
57
56
 
58
57
  async function processStory() {
59
58
  const story = stories[currIndex++];
60
- const storyUrl = getStoryUrl(story, storybookUrl, isVersion7);
59
+ const storyUrl = getStoryUrl(story, storybookUrl);
61
60
  const title = getStoryBaselineName(story);
62
61
  try {
63
62
  let [error, storyData] = await presult(
@@ -70,7 +69,7 @@ function makeRenderStories({
70
69
 
71
70
  if (
72
71
  error &&
73
- /(Protocol error|Execution context was destroyed|timeout reached when trying to take DOM for story)/.test(
72
+ /(Runtime.callFunctionOn timed out|Protocol error|Execution context was destroyed|timeout reached when trying to take DOM for story)/.test(
74
73
  error.message,
75
74
  )
76
75
  ) {
@@ -12,6 +12,7 @@ async function startStorybookServer({
12
12
  startStorybookServerTimeout,
13
13
  storybookPath,
14
14
  sbArg,
15
+ sbVersion,
15
16
  }) {
16
17
  const isWindows = process.platform.startsWith('win');
17
18
 
@@ -24,6 +25,7 @@ async function startStorybookServer({
24
25
  isWindows,
25
26
  logger,
26
27
  sbArg,
28
+ sbVersion,
27
29
  });
28
30
 
29
31
  if (showStorybookOutput) {
@@ -2,6 +2,7 @@
2
2
  const {spawn} = require('child_process');
3
3
  const EventEmitter = require('events');
4
4
  const stripAnsi = require('strip-ansi');
5
+ const {lt} = require('semver');
5
6
 
6
7
  class StorybookConnector extends EventEmitter {
7
8
  constructor({
@@ -13,6 +14,7 @@ class StorybookConnector extends EventEmitter {
13
14
  isWindows,
14
15
  logger,
15
16
  sbArg,
17
+ sbVersion,
16
18
  }) {
17
19
  super();
18
20
  this._storybookPath = storybookPath;
@@ -23,6 +25,7 @@ class StorybookConnector extends EventEmitter {
23
25
  this._isWindows = isWindows;
24
26
  this._logger = logger;
25
27
  this._sbArg = sbArg;
28
+ this._sbVersion = sbVersion;
26
29
 
27
30
  this._childProcess = null;
28
31
  this._version = 5;
@@ -103,6 +106,10 @@ class StorybookConnector extends EventEmitter {
103
106
  }
104
107
 
105
108
  _doSpawan(version) {
109
+ let isLt8;
110
+ try {
111
+ isLt8 = lt(this._sbVersion, '8.0.0');
112
+ } catch (err) {}
106
113
  const args = [
107
114
  '-p',
108
115
  this._storybookPort,
@@ -111,7 +118,7 @@ class StorybookConnector extends EventEmitter {
111
118
  '-c',
112
119
  this._storybookConfigDir,
113
120
  ];
114
- if (this._storybookStaticDir) {
121
+ if (this._storybookStaticDir && isLt8) {
115
122
  args.push('-s');
116
123
  args.push(this._storybookStaticDir);
117
124
  }
@@ -1,11 +1,10 @@
1
1
  const {resolve} = require('path');
2
+ const {execSync} = require('child_process');
2
3
  const fs = require('fs');
3
4
  const findNpmModuleCommandPath = require('../findNpmModuleCommandPath');
4
5
 
5
6
  async function determineStorybookVersion({packagePath, isWindows}) {
6
- let sbArg,
7
- storybookPath,
8
- isVersion7 = false;
7
+ let sbArg, storybookPath;
9
8
 
10
9
  const commandV6 = 'start-storybook' + (isWindows ? '.cmd' : '');
11
10
  const commandV7 = 'sb' + (isWindows ? '.cmd' : '');
@@ -17,18 +16,18 @@ async function determineStorybookVersion({packagePath, isWindows}) {
17
16
  storybookPath = storybookPathV6;
18
17
  } else if (fs.existsSync(storybookPathV7)) {
19
18
  storybookPath = storybookPathV7;
20
- isVersion7 = true;
21
19
  sbArg = 'dev';
22
20
  } else {
23
21
  // the binary is not in the local node_modules/.bin folder, so we need to find it
24
22
  storybookPath = await findNpmModuleCommandPath(commandV6, packagePath);
25
23
  if (!storybookPath) {
26
24
  storybookPath = await findNpmModuleCommandPath(commandV7, packagePath);
27
- isVersion7 = true;
28
25
  sbArg = 'dev';
29
26
  }
30
27
  }
31
28
 
32
- return {storybookPath, isVersion7, sbArg};
29
+ const sbVersion = execSync(`${storybookPath} ${sbArg ?? ''} --version`).toString();
30
+
31
+ return {storybookPath, sbVersion, sbArg};
33
32
  }
34
33
  module.exports = determineStorybookVersion;
@@ -21,12 +21,12 @@ async function validateAndPopulateConfig({config, packagePath = '', logger = mak
21
21
 
22
22
  const packageJsonPath = `${packagePath}/package.json`;
23
23
  const packageJson = fs.existsSync(packageJsonPath) ? require(packageJsonPath) : undefined;
24
- const {storybookPath, isVersion7, sbArg} = await determineStorybookVersion({
24
+ const {storybookPath, sbVersion, sbArg} = await determineStorybookVersion({
25
25
  packagePath,
26
26
  isWindows: process.platform.startsWith('win'),
27
27
  });
28
28
  logger.log(
29
- `[validateAndPopulateConfig] storybookPath=${storybookPath} isVersion7=${isVersion7} sbArg=${sbArg}`,
29
+ `[validateAndPopulateConfig] storybookPath=${storybookPath} sbVersion=${sbVersion} sbArg=${sbArg}`,
30
30
  );
31
31
 
32
32
  if (!config.appName) {
@@ -49,7 +49,7 @@ async function validateAndPopulateConfig({config, packagePath = '', logger = mak
49
49
  }
50
50
 
51
51
  config.storybookUrl = await startStorybookServer(
52
- Object.assign({packagePath, logger, storybookPath, sbArg}, config),
52
+ Object.assign({packagePath, logger, storybookPath, sbArg, sbVersion}, config),
53
53
  );
54
54
 
55
55
  // NOTE (Amit): I don't understand why this condition is here. It shouldn't happen. I might have been the one to put it here, but it seems like a mistake. We should take a thorough look and remove it.
@@ -76,6 +76,5 @@ async function validateAndPopulateConfig({config, packagePath = '', logger = mak
76
76
  ),
77
77
  );
78
78
  }
79
- return isVersion7;
80
79
  }
81
80
  module.exports = validateAndPopulateConfig;