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

Make Freeze Animation false by default #1309

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 33 additions & 1 deletion packages/webdriver-utils/src/providers/genericProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ export default class GenericProvider {
this.debugUrl = null;
}

addDefaultOptions() {
this.options.freezeAnimation = this.options.freezeAnimation || false;
}

defaultPercyCSS() {
itsjwala marked this conversation as resolved.
Show resolved Hide resolved
return `*, *::before, *::after {
-moz-transition: none !important;
transition: none !important;
-moz-animation: none !important;
animation: none !important;
animation-duration: 0 !important;
caret-color: transparent !important;
content-visibility: visible !important;
}
html{
scrollbar-width: auto !important;
}
svg {
shape-rendering: geometricPrecision !important;
}
scrollbar, scrollcorner, scrollbar thumb, scrollbar scrollbarbutton {
pointer-events: none !important;
-moz-appearance: none !important;
display: none !important;
}
video::-webkit-media-controls {
display: none !important;
}`;
}

async createDriver() {
this.driver = new Driver(this.sessionId, this.commandExecutorUrl);
const caps = await this.driver.getCapabilites();
Expand Down Expand Up @@ -77,7 +107,9 @@ export default class GenericProvider {
}) {
let fullscreen = false;

const percyCSS = this.options.percyCSS || '';
this.addDefaultOptions();

const percyCSS = (this.defaultPercyCSS() + (this.options.percyCSS || '')).split('\n').join('');
await this.addPercyCSS(percyCSS);
const tag = await this.getTag();

Expand Down
34 changes: 34 additions & 0 deletions packages/webdriver-utils/test/providers/genericProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ describe('GenericProvider', () => {
genericProvider = new GenericProvider('123', 'http:executorUrl', { platform: 'win' }, {}, 'local-poc-poa', 'staging-poc-poa', {});
await genericProvider.createDriver();
let res = await genericProvider.screenshot('mock-name', {});
const defaultPercyCSS = genericProvider.defaultPercyCSS().split('\n').join('');
expect(addPercyCSSSpy).toHaveBeenCalledTimes(1);
expect(addPercyCSSSpy).toHaveBeenCalledWith(defaultPercyCSS);
expect(getTagSpy).toHaveBeenCalledTimes(1);
expect(getTilesSpy).toHaveBeenCalledOnceWith(false);
expect(removePercyCSSSpy).toHaveBeenCalledTimes(1);
Expand All @@ -128,6 +130,38 @@ describe('GenericProvider', () => {
});
});

describe('defaultPercyCSS', () => {
const expectedResult = `*, *::before, *::after {
-moz-transition: none !important;
transition: none !important;
-moz-animation: none !important;
animation: none !important;
animation-duration: 0 !important;
caret-color: transparent !important;
content-visibility: visible !important;
}
html{
scrollbar-width: auto !important;
}
svg {
shape-rendering: geometricPrecision !important;
}
scrollbar, scrollcorner, scrollbar thumb, scrollbar scrollbarbutton {
pointer-events: none !important;
-moz-appearance: none !important;
display: none !important;
}
video::-webkit-media-controls {
display: none !important;
}`;

it('should return defaultPercyCSS', () => {
genericProvider = new GenericProvider('123', 'http:executorUrl', { platform: 'win' }, {}, 'local-poc-poa', 'staging-poc-poa', {});
const resp = genericProvider.defaultPercyCSS();
expect(resp).toBe(expectedResult);
});
});

describe('addPercyCSS', () => {
beforeEach(() => {
spyOn(Driver.prototype, 'executeScript').and.returnValue(Promise.resolve(true));
Expand Down
Loading