Skip to content

Commit

Permalink
test(react): add fix for flaky Cypress test
Browse files Browse the repository at this point in the history
add fix for flaky Cypress test
  • Loading branch information
MI6-286 authored and MI6-255 committed Aug 7, 2024
1 parent 6bd637b commit 3b9b2f9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
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.
38 changes: 37 additions & 1 deletion packages/react/src/component-tests/IcButton/IcButton.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render text-based primary buttons", () => {
mount(<TextPrimaryButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "primary",
Expand All @@ -327,6 +329,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render text-based secondary buttons", () => {
mount(<TextSecondaryButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "secondary",
Expand All @@ -337,6 +341,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render text-based tertiary buttons", () => {
mount(<TextTertiaryButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "tertiary",
Expand All @@ -347,6 +353,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render text-based destructive buttons", () => {
mount(<TextDestructiveButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "destructive",
Expand All @@ -357,6 +365,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render with-icon buttons", () => {
mount(<WithIcons />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "with-icon",
Expand All @@ -367,6 +377,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render with-icon buttons without viewbox", () => {
mount(<IconNoViewbox />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "icon-without-viewbox",
Expand All @@ -377,6 +389,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render different sized buttons", () => {
mount(<DifferentSizes />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "size",
Expand All @@ -387,6 +401,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render full width buttons", () => {
mount(<FullWidth />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.get(IC_BUTTON_SELECTOR)
.shadow()
.find("button")
Expand All @@ -404,6 +420,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render dropdown buttons", () => {
mount(<DropdownButtons />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "dropdown",
Expand Down Expand Up @@ -433,6 +451,8 @@ describe("IcButton visual regression and a11y tests", () => {
</IcButton>
);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "router-slot",
Expand All @@ -443,6 +463,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render with icon variant button group", () => {
mount(<IconButtonGroup />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.wait(500).compareSnapshot({
name: "icon-variants-button-group",
Expand Down Expand Up @@ -617,6 +639,8 @@ describe("IcButton visual regression and a11y tests", () => {
it("should render button with custom height and width", () => {
mount(<CustomHeightMinWidth />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "height-width",
Expand All @@ -641,6 +665,8 @@ describe("IcButton visual regression tests in high contrast mode", () => {
it("should render text-based primary buttons in high contrast mode", () => {
mount(<TextPrimaryButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.compareSnapshot({
name: "primary-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.031),
Expand All @@ -650,6 +676,8 @@ describe("IcButton visual regression tests in high contrast mode", () => {
it("should render text-based secondary buttons in high contrast mode", () => {
mount(<TextSecondaryButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.compareSnapshot({
name: "secondary-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.038),
Expand All @@ -659,6 +687,8 @@ describe("IcButton visual regression tests in high contrast mode", () => {
it("should render text-based tertiary buttons in high contrast mode", () => {
mount(<TextTertiaryButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.compareSnapshot({
name: "tertiary-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.031),
Expand All @@ -668,6 +698,8 @@ describe("IcButton visual regression tests in high contrast mode", () => {
it("should render text-based destructive buttons in high contrast mode", () => {
mount(<TextDestructiveButton />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.compareSnapshot({
name: "destructive-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.013),
Expand All @@ -677,6 +709,8 @@ describe("IcButton visual regression tests in high contrast mode", () => {
it("should render with-icon buttons in high contrast mode", () => {
mount(<WithIcons />);

cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.compareSnapshot({
name: "with-icon-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.071),
Expand All @@ -686,7 +720,9 @@ describe("IcButton visual regression tests in high contrast mode", () => {
it("should render icon variants in high contrast mode", () => {
mount(<IconButtonGroup />);

cy.wait(500).compareSnapshot({
cy.checkHydrated(IC_BUTTON_SELECTOR);

cy.compareSnapshot({
name: "icon-variants-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.047),
});
Expand Down

0 comments on commit 3b9b2f9

Please sign in to comment.