Skip to content

Commit

Permalink
Update default layout cypress snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Nov 12, 2024
1 parent 5fb151c commit 794a26a
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
with:
component: true
install-command: npm i
browser: chrome
# build job
build:
needs: [install]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ yalc.lock
cypress/**/*.diff.png
cypress/videos
cypress/screenshots
cypress/downloads

# cache
.cache
Expand Down
19 changes: 17 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,32 @@ export default defineConfig({
addMatchImageSnapshotPlugin(on, config);
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push('--window-size=1280,720');
launchOptions.args = launchOptions.args.map((arg) => {
if (arg === '--headless=new') {
return '--headless';
}

return arg;
});
// Needs the extra 139 because of the cypress toolbar, this is the size of the window! not size of the viewport
launchOptions.args.push(`--window-size=1280,${720 + 139}`);
// force screen to be non-retina
launchOptions.args.push('--force-device-scale-factor=1');
// force screen to be retina (2800x2400 size)
// launchOptions.args.push('--force-device-scale-factor=2')
}

if (browser.name === 'electron' && browser.isHeadless) {
// fullPage screenshot size is 1280x720
launchOptions.preferences.width = 1280;
launchOptions.preferences.height = 720;
}

if (browser.name === 'firefox' && browser.isHeadless) {
launchOptions.args.push('--width=1280');
launchOptions.args.push('--height=720');
}

return launchOptions;
});
require('@cypress/code-coverage/task')(on, config);
return config;
Expand Down
2 changes: 2 additions & 0 deletions cypress/component/NotEntitledModal/NotEntitledModal.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ describe('NonEntitledModal', () => {
if (image) {
cy.get(`[src="${image}"]`).should('be.visible');
}
// make sure the scrollbar is hidden to ensure valid snapshot
cy.get('.pf-v5-c-modal-box__body').invoke('attr', 'style', 'overflow: hidden');
elem.matchImageSnapshot();
});
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const defaultOptions = {
updateSnapshots: false,
};

const defaultCommand = 'npm run cypress run -- --component --browser electron';
const defaultCommand = 'npm run cypress run -- --component --browser chrome';

if (argv.u || argv.update) {
defaultOptions.updateSnapshots = true;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ declare global {
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(<MyComponent />)

0 comments on commit 794a26a

Please sign in to comment.