From 8724551d6ae13f512722513d7ad1b7f8d22fc97b Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 12 Feb 2025 22:20:11 +0100 Subject: [PATCH] fix(cy): Disable spell checking in the browser Signed-off-by: Max --- cypress.config.mjs | 18 ++++++++++++++++++ cypress/e2e/print.spec.js | 4 ++-- cypress/support/commands.js | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cypress.config.mjs b/cypress.config.mjs index f95dcf1e8b6..29096d7aefa 100644 --- a/cypress.config.mjs +++ b/cypress.config.mjs @@ -32,6 +32,24 @@ export default defineConfig({ cypressSplit(on, config) configureVisualRegression(on) + // Disable spell checking to prevent rendering differences + on('before:browser:launch', (browser, launchOptions) => { + if (browser.family === 'chromium' && browser.name !== 'electron') { + launchOptions.preferences.default['browser.enable_spellchecking'] = false + return launchOptions + } + + if (browser.family === 'firefox') { + launchOptions.preferences['layout.spellcheckDefault'] = 0 + return launchOptions + } + + if (browser.name === 'electron') { + launchOptions.preferences.spellcheck = false + return launchOptions + } + }) + return config }, diff --git a/cypress/e2e/print.spec.js b/cypress/e2e/print.spec.js index 664043aabbe..236f6ef899b 100644 --- a/cypress/e2e/print.spec.js +++ b/cypress/e2e/print.spec.js @@ -26,7 +26,7 @@ describe('Open print.md and compare print view', function() { .get('h1:not(.hidden-visually)').should('contain', 'Print test') .should('be.visible') - cy.compareSnapshot('print view in viewer', { capture: 'fullPage' }) + cy.compareSnapshot('print view in viewer') cy.setCssMedia('screen') }) @@ -45,7 +45,7 @@ describe('Open print.md and compare print view', function() { .get('h1:not(.hidden-visually)').should('contain', 'Print test') .should('be.visible') - cy.compareSnapshot('print view in single-file share', { capture: 'fullPage' }) + cy.compareSnapshot('print view in single-file share') cy.setCssMedia('screen') }) }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 620ecd4d958..2b3df5d4a29 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -11,7 +11,7 @@ import { addCompareSnapshotCommand } from 'cypress-visual-regression/dist/comman // eslint-disable-next-line no-unused-vars,n/no-extraneous-import import regeneratorRuntime from 'regenerator-runtime' -addCompareSnapshotCommand() +addCompareSnapshotCommand({ capture: 'fullPage' }) const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '') Cypress.env('baseUrl', url)