Skip to content
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

✨ Shadow DOM serialisation support #1165

Merged
merged 107 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
9231933
use declarative dom for serializing
samarsault Dec 6, 2022
f995642
Remove getInnerHTML polyfill
samarsault Dec 6, 2022
c432e1c
:memo: update documentation for testing cli packages
itsjwala Dec 7, 2022
3ba8de2
:bug: return document instead of fragment
itsjwala Dec 8, 2022
2e1a07c
:bug: missed let : (
itsjwala Dec 8, 2022
8fd98aa
firefox use default html without declarative
samarsault Dec 13, 2022
ed92d42
add basic tests
samarsault Dec 13, 2022
bbd3644
Serialized element tests
samarsault Dec 21, 2022
13d1b67
rename clone node file name
itsjwala Dec 19, 2022
779172b
mark dom elements in shadow dom, next steps - serialize them
itsjwala Dec 20, 2022
6d33e92
serialize inputs, cssom, video, canvas, frames
itsjwala Dec 22, 2022
3bfebf4
add comments
itsjwala Dec 22, 2022
ee4f143
add warning log for video serialization
itsjwala Dec 22, 2022
d08a988
remove line and add comment
itsjwala Dec 26, 2022
ebe9271
add extra comments
itsjwala Dec 26, 2022
5629413
added declarative shadow dom polyfill for non chromium infra browsers
itsjwala Jan 3, 2023
6e26316
serialize frame test
samarsault Jan 3, 2023
a878a4f
serialize cssom inside shadow
samarsault Jan 3, 2023
f24abfe
shadowDom global in other tests
samarsault Jan 3, 2023
ae3f89d
update id
itsjwala Jan 6, 2023
70f0f5c
karma separate shadow dom config
samarsault Jan 3, 2023
86aea78
Use shadow mode in karma
samarsault Jan 3, 2023
db609d9
refactor dom test to platform
samarsault Jan 9, 2023
a46eaa6
serialize cssom createElement fix
samarsault Jan 9, 2023
7747eda
domTransformation shadow dom unsupported
samarsault Jan 9, 2023
ebbab8b
frames tests add polyfill
samarsault Jan 9, 2023
422de93
withExample: Remove test-shadow for plain to avoid flakes
samarsault Jan 9, 2023
1e88af8
fix frame test side effect in input
samarsault Jan 9, 2023
48c10a5
refactor helper with options
samarsault Jan 9, 2023
7a55414
firefox tests limit platforms
samarsault Jan 9, 2023
49bf6cc
revert test script changes
samarsault Jan 9, 2023
44ae9a5
add tests for inject polyfill
itsjwala Jan 10, 2023
a0d6fbc
:bookmark: v1.19.0-alpha.0
itsjwala Jan 10, 2023
b80a73a
:memo: update readme for dom package
itsjwala Jan 11, 2023
77a1526
use declarative dom for serializing
samarsault Dec 6, 2022
fa4fe40
Remove getInnerHTML polyfill
samarsault Dec 6, 2022
a52b319
:bug: return document instead of fragment
itsjwala Dec 8, 2022
93ff77c
:bug: missed let : (
itsjwala Dec 8, 2022
1812f70
firefox use default html without declarative
samarsault Dec 13, 2022
340cff1
add basic tests
samarsault Dec 13, 2022
6c1fb96
Serialized element tests
samarsault Dec 21, 2022
0c6112b
rename clone node file name
itsjwala Dec 19, 2022
5055721
mark dom elements in shadow dom, next steps - serialize them
itsjwala Dec 20, 2022
5f258d4
serialize inputs, cssom, video, canvas, frames
itsjwala Dec 22, 2022
fdaddd2
add comments
itsjwala Dec 22, 2022
11d2317
add warning log for video serialization
itsjwala Dec 22, 2022
4e485ad
remove line and add comment
itsjwala Dec 26, 2022
e2e17bd
add extra comments
itsjwala Dec 26, 2022
0ee30f0
serialize frame test
samarsault Jan 3, 2023
59b4650
serialize cssom inside shadow
samarsault Jan 3, 2023
875624c
shadowDom global in other tests
samarsault Jan 3, 2023
e2daf4d
karma separate shadow dom config
samarsault Jan 3, 2023
caae096
Use shadow mode in karma
samarsault Jan 3, 2023
cef1c42
added declarative shadow dom polyfill for non chromium infra browsers
itsjwala Jan 3, 2023
cfcd554
refactor dom test to platform
samarsault Jan 9, 2023
9550ae5
domTransformation shadow dom unsupported
samarsault Jan 9, 2023
87a4c38
frames tests add polyfill
samarsault Jan 9, 2023
3d61bf0
withExample: Remove test-shadow for plain to avoid flakes
samarsault Jan 9, 2023
25c2807
fix frame test side effect in input
samarsault Jan 9, 2023
e6bfde8
refactor helper with options
samarsault Jan 9, 2023
9e7439d
firefox tests limit platforms
samarsault Jan 9, 2023
e03c3c6
revert test script changes
samarsault Jan 9, 2023
95eb3e4
frame test more specific
samarsault Jan 10, 2023
3d7fd53
many nested many flat shadow dom
samarsault Jan 10, 2023
902eb43
failing domTransformation for shadow
samarsault Jan 11, 2023
e5d43d0
adoptedStylesheet test
samarsault Jan 11, 2023
c39e29d
fix frames test
samarsault Jan 11, 2023
3e8b734
:bug: return if style id is not found
itsjwala Jan 12, 2023
9893fcc
:bookmark: v1.19.1-alpha.0
itsjwala Jan 12, 2023
f847f49
disableShadowDom option
samarsault Jan 13, 2023
3cf174d
allow disableShadowDom in storybook + cil-snapshot
samarsault Jan 16, 2023
af5714c
disable shadow dom snake case
samarsault Jan 16, 2023
f09e529
cloneNode pass ctx
samarsault Jan 16, 2023
afbfcf5
Add comment
itsjwala Jan 17, 2023
3f6d41f
adoptedStylesheet serialize dom
samarsault Jan 17, 2023
b520ee2
Add comment
itsjwala Jan 17, 2023
560c589
run polyfill as first thing
itsjwala Jan 25, 2023
f56ee1a
custom element test case
samarsault Feb 5, 2023
6969f04
frame in head
samarsault Feb 5, 2023
bc1e812
disable shadow dom naming
samarsault Feb 5, 2023
9d44bf4
use getTestBrowser
samarsault Feb 5, 2023
0f4166d
increase nesting levels
samarsault Feb 5, 2023
b1af229
remove comment
itsjwala Feb 6, 2023
285ebc4
rename argument
itsjwala Feb 6, 2023
cf04c20
inject polyfill only when not disabled
itsjwala Feb 6, 2023
096f764
fix linter
itsjwala Feb 6, 2023
2732297
fix polyfill
itsjwala Feb 6, 2023
ea63218
lint fix
samarsault Feb 6, 2023
6c51b42
Merge branch 'shadow-dom' of github.com:percy/cli into shadow-dom
itsjwala Feb 6, 2023
8bd2e73
refactor
itsjwala Feb 6, 2023
71e6b39
fix disableShadowDOM option
itsjwala Feb 7, 2023
9f3baa7
update readme
itsjwala Feb 7, 2023
ced8778
fix core test
itsjwala Feb 7, 2023
4d23277
serialize adopted styles as link
samarsault Feb 8, 2023
68eac6d
Merge remote-tracking branch 'origin/shadow-dom' into shadow-dom
samarsault Feb 8, 2023
d4ff7c7
text resource as base64
samarsault Feb 8, 2023
ff1bdff
use dataj-percy-serialized
samarsault Feb 9, 2023
36a13bf
fix tests
samarsault Feb 9, 2023
d9bf828
:bookmark: v1.19.2-alpha.0
samarsault Feb 9, 2023
4ae92f0
lerna update
samarsault Feb 10, 2023
f407380
refactor recursive serialize
samarsault Feb 14, 2023
4038cdf
invalid marking test
samarsault Feb 14, 2023
71f7eb5
adoptedStylesheet document test
samarsault Feb 14, 2023
0aa9765
fiix custom element test
samarsault Feb 14, 2023
5762162
fix recursive serialization of special elements
samarsault Feb 14, 2023
2e92ad4
refactor serialize dom
samarsault Feb 14, 2023
803e7d3
increase test coverage
itsjwala Feb 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"packages": [
"packages/*"
],
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"postinstall": "lerna run --stream postinstall",
"test": "lerna run --stream --concurrency=1 test",
"test:coverage": "lerna run --stream --concurrency=1 --no-bail test:coverage",
"test:types": "lerna run --parallel test:types"
"test:types": "lerna run --parallel test:types",
"global:link": "lerna exec -- yarn link",
"global:unlink": "lerna exec -- yarn unlink"
},
"devDependencies": {
"@babel/cli": "^7.11.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-app",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,7 +32,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.18.0",
"@percy/cli-exec": "1.18.0"
"@percy/cli-command": "1.19.2-alpha.0",
"@percy/cli-exec": "1.19.2-alpha.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli-build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-build",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,6 +32,6 @@
]
},
"dependencies": {
"@percy/cli-command": "1.18.0"
"@percy/cli-command": "1.19.2-alpha.0"
}
}
8 changes: 4 additions & 4 deletions packages/cli-command/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-command",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -35,8 +35,8 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/config": "1.18.0",
"@percy/core": "1.18.0",
"@percy/logger": "1.18.0"
"@percy/config": "1.19.2-alpha.0",
"@percy/core": "1.19.2-alpha.0",
"@percy/logger": "1.19.2-alpha.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-config",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,6 +32,6 @@
]
},
"dependencies": {
"@percy/cli-command": "1.18.0"
"@percy/cli-command": "1.19.2-alpha.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli-exec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-exec",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,7 +32,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.18.0",
"@percy/cli-command": "1.19.2-alpha.0",
"cross-spawn": "^7.0.3",
"which": "^2.0.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-snapshot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-snapshot",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,7 +32,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.18.0",
"@percy/cli-command": "1.19.2-alpha.0",
"yaml": "^2.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli-upload/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-upload",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,7 +32,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.18.0",
"@percy/cli-command": "1.19.2-alpha.0",
"fast-glob": "^3.2.11",
"image-size": "^1.0.0"
}
Expand Down
35 changes: 35 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,45 @@ use the following scripts for various development tasks:
- `yarn readme` - generate cli commands readme usage
- `yarn test` - run all tests, one package after another
- `yarn test:coverage` - run all tests with coverage, one package after another
- `yarn global:link` - links all packages being developed as global.
- requires `yarn build` to be run before
- we can then consume this package using
`[npm|yarn] link @percy/[core|cli..]`
- **Note**: linking is only required once, subsequent changes for development requires running build command.

- `yarn global:unlink` - unlinks all packages globally

Individual package scripts can be invoked using yarn's
[workspace](https://classic.yarnpkg.com/en/docs/cli/workspace/) command. For example:

```sh-session
$ yarn workspace @percy/core test
```


## Publish

Most of the repos have similar setup as CLI, steps as follows

1. bump version

```
yarn bump-version
```

2. commit with following commit message => `:bookmark: vTAG`

3. Draft a new release and publish it

This will run release.yml workflow on github actions, which publishes the NPM packages

### Publish with specific tag

Currently release workflow only support publishing with latest tag.
To publish with alpha/any other TAG.

1. follow till step 2 above and then run

```
yarn lerna publish from-package --dist-tag TAG
```
20 changes: 10 additions & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -30,14 +30,14 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/cli-app": "1.18.0",
"@percy/cli-build": "1.18.0",
"@percy/cli-command": "1.18.0",
"@percy/cli-config": "1.18.0",
"@percy/cli-exec": "1.18.0",
"@percy/cli-snapshot": "1.18.0",
"@percy/cli-upload": "1.18.0",
"@percy/client": "1.18.0",
"@percy/logger": "1.18.0"
"@percy/cli-app": "1.19.2-alpha.0",
"@percy/cli-build": "1.19.2-alpha.0",
"@percy/cli-command": "1.19.2-alpha.0",
"@percy/cli-config": "1.19.2-alpha.0",
"@percy/cli-exec": "1.19.2-alpha.0",
"@percy/cli-snapshot": "1.19.2-alpha.0",
"@percy/cli-upload": "1.19.2-alpha.0",
"@percy/client": "1.19.2-alpha.0",
"@percy/logger": "1.19.2-alpha.0"
}
}
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/client",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -31,7 +31,7 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/env": "1.18.0",
"@percy/logger": "1.18.0"
"@percy/env": "1.19.2-alpha.0",
"@percy/logger": "1.19.2-alpha.0"
}
}
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/config",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,7 +34,7 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/logger": "1.18.0",
"@percy/logger": "1.19.2-alpha.0",
"ajv": "^8.6.2",
"cosmiconfig": "^7.0.0",
"yaml": "^2.0.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/config/src/utils/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { getSchema } from '../validate.js';
// Edge case camelizations
const CAMELCASE_MAP = new Map([
['css', 'CSS'],
['javascript', 'JavaScript']
['javascript', 'JavaScript'],
['dom', 'DOM']
]);

// Regular expression that matches words from boundaries or consecutive casing
Expand Down
18 changes: 12 additions & 6 deletions packages/config/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,14 +1100,16 @@ describe('PercyConfig', () => {
'foo_bar-baz': 'qux',
'Bar BAZ qux': 'xyzzy',
'percy-css': '',
'enable-javascript': false
'enable-javascript': false,
'disable-shadow-dom': true
})).toEqual({
fooBar: 'baz',
foo: { barBaz: 'qux' },
fooBarBaz: 'qux',
barBazQux: 'xyzzy',
percyCSS: '',
enableJavaScript: false
enableJavaScript: false,
disableShadowDOM: true
});
});

Expand All @@ -1117,13 +1119,15 @@ describe('PercyConfig', () => {
foo: { bar_baz: 'qux' },
fooBar_baz: ['qux'],
percyCSS: '',
enableJavaScript: false
enableJavaScript: false,
disableShadowDOM: true
}, { kebab: true })).toEqual({
'foo-bar': 'baz',
foo: { 'bar-baz': 'qux' },
'foo-bar-baz': ['qux'],
'percy-css': '',
'enable-javascript': false
'enable-javascript': false,
'disable-shadow-dom': true
});
});

Expand All @@ -1133,13 +1137,15 @@ describe('PercyConfig', () => {
foo: { bar_baz: 'qux' },
fooBar_baz: ['qux'],
percyCSS: '',
enableJavaScript: false
enableJavaScript: false,
disableShadowDOM: true
}, { snake: true })).toEqual({
foo_bar: 'baz',
foo: { bar_baz: 'qux' },
foo_bar_baz: ['qux'],
percy_css: '',
enable_javascript: false
enable_javascript: false,
disable_shadow_dom: true
});
});

Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/core",
"version": "1.18.0",
"version": "1.19.2-alpha.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -39,10 +39,10 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/client": "1.18.0",
"@percy/config": "1.18.0",
"@percy/dom": "1.18.0",
"@percy/logger": "1.18.0",
"@percy/client": "1.19.2-alpha.0",
"@percy/config": "1.19.2-alpha.0",
"@percy/dom": "1.19.2-alpha.0",
"@percy/logger": "1.19.2-alpha.0",
"content-disposition": "^0.5.4",
"cross-spawn": "^7.0.3",
"extract-zip": "^2.0.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const configSchema = {
enableJavaScript: {
type: 'boolean'
},
disableShadowDOM: {
type: 'boolean',
default: false
},
scope: {
type: 'string'
}
Expand Down Expand Up @@ -149,6 +153,7 @@ export const snapshotSchema = {
minHeight: { $ref: '/config/snapshot#/properties/minHeight' },
percyCSS: { $ref: '/config/snapshot#/properties/percyCSS' },
enableJavaScript: { $ref: '/config/snapshot#/properties/enableJavaScript' },
disableShadowDOM: { $ref: '/config/snapshot#/properties/disableShadowDOM' },
discovery: {
type: 'object',
additionalProperties: false,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function debugSnapshotOptions(snapshot) {
debugProp(snapshot, 'widths', v => `${v}px`);
debugProp(snapshot, 'minHeight', v => `${v}px`);
debugProp(snapshot, 'enableJavaScript');
debugProp(snapshot, 'disableShadowDOM');
debugProp(snapshot, 'deviceScaleFactor');
debugProp(snapshot, 'waitForTimeout');
debugProp(snapshot, 'waitForSelector');
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class Page {
execute,
...snapshot
}) {
let { name, width, enableJavaScript } = snapshot;
let { name, width, enableJavaScript, disableShadowDOM } = snapshot;
this.log.debug(`Taking snapshot: ${name}${width ? ` @${width}px` : ''}`, this.meta);

// wait for any specified timeout
Expand Down Expand Up @@ -181,7 +181,7 @@ export class Page {
/* eslint-disable-next-line no-undef */
domSnapshot: PercyDOM.serialize(options),
url: document.URL
}), { enableJavaScript });
}), { enableJavaScript, disableShadowDOM });

return { ...snapshot, ...capture };
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/test/discovery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ describe('Discovery', () => {
await percy.snapshot({
name: 'test event snapshot',
url: 'http://localhost:8000/events',
enableJavaScript: true
enableJavaScript: true,
disableShadowDOM: true
});

await percy.idle();
Expand Down
Loading