Skip to content

Commit

Permalink
✨ Introduce new config option enableLayout for enabling layout testin…
Browse files Browse the repository at this point in the history
…g. (#1378)

* ✨ Introduce new config option enableLayout for enabling layout testing

* lint fix

* test fix

* addressing comments
  • Loading branch information
prklm10 authored Oct 30, 2023
1 parent 9dc3b46 commit 5a3ee41
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/cli-upload/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe('percy upload', () => {
widths: [10],
scope: null,
'minimum-height': 10,
'enable-javascript': null
'enable-javascript': null,
'enable-layout': false
},
relationships: {
resources: {
Expand Down
4 changes: 3 additions & 1 deletion packages/client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class PercyClient {
scope,
minHeight,
enableJavaScript,
enableLayout,
clientInfo,
environmentInfo,
resources = []
Expand Down Expand Up @@ -329,7 +330,8 @@ export class PercyClient {
widths: widths || null,
scope: scope || null,
'minimum-height': minHeight || null,
'enable-javascript': enableJavaScript || null
'enable-javascript': enableJavaScript || null,
'enable-layout': enableLayout || false
},
relationships: {
resources: {
Expand Down
13 changes: 9 additions & 4 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ describe('PercyClient', () => {
scope: '#main',
minHeight: 1000,
enableJavaScript: true,
enableLayout: true,
clientInfo: 'sdk/info',
environmentInfo: 'sdk/env',
resources: [{
Expand Down Expand Up @@ -611,7 +612,8 @@ describe('PercyClient', () => {
widths: [1000],
scope: '#main',
'minimum-height': 1000,
'enable-javascript': true
'enable-javascript': true,
'enable-layout': true
},
relationships: {
resources: {
Expand Down Expand Up @@ -653,7 +655,8 @@ describe('PercyClient', () => {
widths: null,
scope: null,
'minimum-height': null,
'enable-javascript': null
'enable-javascript': null,
'enable-layout': false
},
relationships: {
resources: {
Expand Down Expand Up @@ -717,7 +720,8 @@ describe('PercyClient', () => {
scope: null,
'enable-javascript': null,
'minimum-height': null,
widths: null
widths: null,
'enable-layout': false
},
relationships: {
resources: {
Expand Down Expand Up @@ -1213,7 +1217,8 @@ describe('PercyClient', () => {
scope: null,
'enable-javascript': null,
'minimum-height': null,
widths: null
widths: null,
'enable-layout': false
},
relationships: {
resources: {
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 @@ -1201,7 +1201,8 @@ describe('PercyConfig', () => {
'enable-javascript': false,
'disable-shadow-dom': true,
'cli-enable-javascript': true,
'ignore-region-xpaths': ['']
'ignore-region-xpaths': [''],
'enable-layout': false
})).toEqual({
fooBar: 'baz',
foo: { barBaz: 'qux' },
Expand All @@ -1211,7 +1212,8 @@ describe('PercyConfig', () => {
enableJavaScript: false,
disableShadowDOM: true,
cliEnableJavaScript: true,
ignoreRegionXpaths: ['']
ignoreRegionXpaths: [''],
enableLayout: false
});
});

Expand All @@ -1224,7 +1226,8 @@ describe('PercyConfig', () => {
enableJavaScript: false,
disableShadowDOM: true,
cliEnableJavaScript: true,
ignoreRegionXpaths: ['']
ignoreRegionXpaths: [''],
enableLayout: false
}, { kebab: true })).toEqual({
'foo-bar': 'baz',
foo: { 'bar-baz': 'qux' },
Expand All @@ -1233,7 +1236,8 @@ describe('PercyConfig', () => {
'enable-javascript': false,
'disable-shadow-dom': true,
'cli-enable-javascript': true,
'ignore-region-xpaths': ['']
'ignore-region-xpaths': [''],
'enable-layout': false
});
});

Expand All @@ -1246,7 +1250,8 @@ describe('PercyConfig', () => {
enableJavaScript: false,
disableShadowDOM: true,
cliEnableJavaScript: true,
ignoreRegionXpaths: ['']
ignoreRegionXpaths: [''],
enableLayout: false
}, { snake: true })).toEqual({
foo_bar: 'baz',
foo: { bar_baz: 'qux' },
Expand All @@ -1255,7 +1260,8 @@ describe('PercyConfig', () => {
enable_javascript: false,
disable_shadow_dom: true,
cli_enable_javascript: true,
ignore_region_xpaths: ['']
ignore_region_xpaths: [''],
enable_layout: false
});
});

Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const configSchema = {
type: 'boolean',
default: false
},
enableLayout: {
type: 'boolean'
},
domTransformation: {
type: 'string'
},
Expand Down Expand Up @@ -232,6 +235,7 @@ export const snapshotSchema = {
cliEnableJavaScript: { $ref: '/config/snapshot#/properties/cliEnableJavaScript' },
disableShadowDOM: { $ref: '/config/snapshot#/properties/disableShadowDOM' },
domTransformation: { $ref: '/config/snapshot#/properties/domTransformation' },
enableLayout: { $ref: '/config/snapshot#/properties/enableLayout' },
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 @@ -36,6 +36,7 @@ function debugSnapshotOptions(snapshot) {
debugProp(snapshot, 'enableJavaScript');
debugProp(snapshot, 'cliEnableJavaScript');
debugProp(snapshot, 'disableShadowDOM');
debugProp(snapshot, 'enableLayout');
debugProp(snapshot, 'deviceScaleFactor');
debugProp(snapshot, 'waitForTimeout');
debugProp(snapshot, 'waitForSelector');
Expand Down
40 changes: 40 additions & 0 deletions packages/core/test/discovery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1930,4 +1930,44 @@ describe('Discovery', () => {
});
});
});

describe('Enable Layout =>', () => {
describe('cli-snapshot =>', () => {
it('enable when enableLayout: true', async () => {
percy.config.snapshot.enableLayout = true;
percy.loglevel('debug');

await percy.snapshot({
name: 'test snapshot',
url: 'http://localhost:8000',
domSnapshot: ''
});

await percy.idle();

expect(logger.stderr).toEqual(jasmine.arrayContaining([
'[percy:core:snapshot] - enableLayout: true'
]));
});
});

describe('percySnapshot with cli-exec =>', () => {
it('enable when enableLayout: true', async () => {
percy.config.snapshot.enableLayout = true;
percy.loglevel('debug');

await percy.snapshot({
name: 'test snapshot',
url: 'http://localhost:8000',
domSnapshot: testDOM
});

await percy.idle();

expect(logger.stderr).toEqual(jasmine.arrayContaining([
'[percy:core:snapshot] - enableLayout: true'
]));
});
});
});
});
1 change: 1 addition & 0 deletions packages/core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface CommonSnapshotOptions {
percyCSS?: string;
enableJavaScript?: boolean;
disableShadowDOM?: boolean;
enableLayout?: boolean;
devicePixelRatio?: number;
scope?: string;
}
Expand Down

0 comments on commit 5a3ee41

Please sign in to comment.