Skip to content

Commit

Permalink
test(canary-react): updating visual regression test thresholds
Browse files Browse the repository at this point in the history
updating visual regression test thresholds
  • Loading branch information
MI6-286 committed Jan 31, 2025
1 parent dd39936 commit 47eab67
Show file tree
Hide file tree
Showing 16 changed files with 304 additions and 289 deletions.
Binary file modified ...e-diff-screenshots/baseline/IcCardHorizontal.cy.tsx-clickable-high-contrast.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...f-screenshots/baseline/IcCardHorizontal.cy.tsx-clickable-link-high-contrast.png
100644 → 100755
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.
Binary file modified ...ge-diff-screenshots/baseline/IcCardHorizontal.cy.tsx-disabled-high-contrast.png
100644 → 100755
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.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { setThresholdBasedOnEnv } from "@ukic/react/cypress/utils/helpers";
import { IcThemeMode } from "../../../../web-components/dist/types/utils/types";

const DEFAULT_TEST_THRESHOLD = 0.008;
const DEFAULT_TEST_THRESHOLD = 0.005;

const CARD_SELECTOR = "ic-card-horizontal";

Expand Down Expand Up @@ -122,7 +122,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-message",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.014),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.012),
});
});

Expand All @@ -136,7 +136,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-icon",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.015),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.012),
});
});

Expand All @@ -152,7 +152,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "clickable",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.002),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.004),
});
});

Expand All @@ -164,7 +164,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "clickable-link",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.005),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.004),
});
});

Expand All @@ -181,7 +181,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-image-small",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.018),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.017),
});
});

Expand All @@ -198,7 +198,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-image-default",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.027),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.025),
});
});

Expand All @@ -215,7 +215,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-image-large",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.03),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.026),
});
});

Expand All @@ -232,7 +232,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-image-extra-large",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.038),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.031),
});
});

Expand All @@ -244,7 +244,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "disabled",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.002),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});

Expand Down Expand Up @@ -288,7 +288,7 @@ describe("IcCardHorizontal", () => {
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-truncated-text",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.039),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.032),
});
});

Expand All @@ -299,7 +299,7 @@ describe("IcCardHorizontal", () => {

cy.compareSnapshot({
name: "theme",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.037),
});
});

Expand All @@ -310,7 +310,7 @@ describe("IcCardHorizontal", () => {

cy.compareSnapshot({
name: "theme-clickable",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.035),
});
});

Expand All @@ -321,72 +321,75 @@ describe("IcCardHorizontal", () => {

cy.compareSnapshot({
name: "theme-disabled",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.018),
});
});
});

describe("IcCardHorizontal visual regression tests in high contrast mode", () => {
before(() => {
cy.enableForcedColors();
cy.viewport(1024, 768);
});
describe("IcCardHorizontal visual regression tests in high contrast mode", () => {
before(() => {
cy.enableForcedColors();
});

after(() => {
cy.disableForcedColors();
});
before(() => {
cy.viewport(1024, 768);
});

afterEach(() => {
cy.task("generateReport");
});
afterEach(() => {
cy.task("generateReport");
});

after(() => {
cy.disableForcedColors();
});

it("should render", () => {
mount(<BasicCardHorizontal />);
it("should render", () => {
mount(<BasicCardHorizontal />);

cy.checkHydrated(CARD_SELECTOR);
cy.checkHydrated(CARD_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "default-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.008),
});
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "default-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.009),
});
});

it("should render clickable", () => {
mount(
<div style={{ margin: "16px" }}>
<BasicCardHorizontal clickable />
</div>
);
it("should render clickable", () => {
mount(
<div style={{ margin: "16px" }}>
<BasicCardHorizontal clickable />
</div>
);

cy.get(CARD_SELECTOR).click("topLeft").should(HAVE_FOCUS);
cy.get(CARD_SELECTOR).click("topLeft").should(HAVE_FOCUS);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "clickable-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.008),
});
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "clickable-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.02),
});
});

it("should render clickable as a link", () => {
mount(<BasicCardHorizontal clickable href="#" />);
it("should render clickable as a link", () => {
mount(<BasicCardHorizontal clickable href="#" />);

cy.get('[href="#"]').should(BE_VISIBLE);
cy.get('[href="#"]').should(BE_VISIBLE);

// cy.checkA11yWithWait();
cy.compareSnapshot({
name: "clickable-link-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.005),
});
// cy.checkA11yWithWait();
cy.compareSnapshot({
name: "clickable-link-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.015),
});
});

it("should render disabled", () => {
mount(<BasicCardHorizontal disabled clickable />);
it("should render disabled", () => {
mount(<BasicCardHorizontal disabled clickable />);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "disabled-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
cy.checkA11yWithWait();
cy.compareSnapshot({
name: "disabled-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.012),
});
});
});
Loading

0 comments on commit 47eab67

Please sign in to comment.