Skip to content

Commit

Permalink
Migrate toggle switches from Chakra to Ant Design (#5323)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilluminate authored Sep 26, 2024
1 parent dba1a56 commit feeeae1
Show file tree
Hide file tree
Showing 29 changed files with 196 additions and 643 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fides/compare/2.46.0...main)

### Developer Experience
- Migrate toggle switches from Chakra to Ant Design [#5323](https://github.com/ethyca/fides/pull/5323)


## [2.46.0](https://github.com/ethyca/fides/compare/2.45.2...2.46.0)

Expand Down
17 changes: 10 additions & 7 deletions clients/admin-ui/cypress/e2e/consent-settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,18 @@ describe("Consent settings", () => {
);
cy.getByTestId("input-gpp.mspa_service_provider_mode").should(
"have.attr",
"data-checked",
"aria-checked",
"true",
);
cy.getByTestId("input-gpp.mspa_opt_out_option_mode").should(
"not.have.attr",
"data-checked",
"have.attr",
"aria-checked",
"false",
);
cy.getByTestId("input-gpp.enable_tcfeu_string").should(
"have.attr",
"data-checked",
"aria-checked",
"true",
);
});
});
Expand All @@ -115,17 +118,17 @@ describe("Consent settings", () => {
cy.getByTestId("input-gpp.mspa_service_provider_mode").click();
cy.getByTestId("input-gpp.mspa_opt_out_option_mode").should(
"have.attr",
"data-disabled",
"disabled",
);
cy.getByTestId("input-gpp.mspa_service_provider_mode").click();
cy.getByTestId("input-gpp.mspa_opt_out_option_mode").should(
"not.have.attr",
"data-disabled",
"disabled",
);
cy.getByTestId("input-gpp.mspa_opt_out_option_mode").click();
cy.getByTestId("input-gpp.mspa_service_provider_mode").should(
"have.attr",
"data-disabled",
"disabled",
);
});
});
Expand Down
8 changes: 5 additions & 3 deletions clients/admin-ui/cypress/e2e/custom-fields.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,11 @@ describe("Custom Fields", () => {

it("can disable a custom field with a warning", () => {
cy.getByTestId("row-2").within(() => {
cy.getByTestId("toggle-switch").within(() => {
cy.get("span").should("have.attr", "data-checked");
});
cy.getByTestId("toggle-switch").should(
"have.attr",
"aria-checked",
"true",
);
cy.getByTestId("toggle-switch").click();
});

Expand Down
15 changes: 8 additions & 7 deletions clients/admin-ui/cypress/e2e/messaging.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ describe("Messaging", () => {
cy.visit("/messaging");
cy.wait("@getEmailTemplatesSummary");

cy.get("table")
.find("tbody")
.find("tr")
.first()
.find("td input")
.uncheck({ force: true });
cy.getByTestId("row-0-col-is_enabled").within(() => {
cy.get('[role="switch"]').click();
});

cy.wait("@patchTemplate").then((interception) => {
expect(interception.request.body).to.deep.equal({
Expand Down Expand Up @@ -115,7 +112,11 @@ describe("Messaging", () => {
"Your access request has been completed and can be downloaded at {{download_link}}. For security purposes, this secret link will expire in {{days}} days.",
);

cy.getByTestId("input-is_enabled").find("input").should("not.be.checked");
cy.getByTestId("input-is_enabled").should(
"have.attr",
"aria-checked",
"false",
);
});

it("should save template after selecting a property and clicking save", () => {
Expand Down
8 changes: 5 additions & 3 deletions clients/admin-ui/cypress/e2e/privacy-experiences.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ describe("Privacy experiences", () => {
cy.get("table")
.contains("tr", "notice enabled test")
.within(() => {
cy.getByTestId("toggle-switch").within(() => {
cy.get("span").should("have.attr", "data-checked");
});
cy.getByTestId("toggle-switch").should(
"have.attr",
"aria-checked",
"true",
);
cy.getByTestId("toggle-switch").click();
});

Expand Down
8 changes: 5 additions & 3 deletions clients/admin-ui/cypress/e2e/privacy-notices.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ describe("Privacy notices", () => {
cy.get("table")
.contains("tr", "Essential")
.within(() => {
cy.getByTestId("toggle-switch").within(() => {
cy.get("span").should("have.attr", "data-checked");
});
cy.getByTestId("toggle-switch").should(
"have.attr",
"aria-checked",
"true",
);
cy.getByTestId("toggle-switch").click();
});

Expand Down
64 changes: 40 additions & 24 deletions clients/admin-ui/cypress/e2e/user-management.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,11 @@ describe("User management", () => {
});

// the select all toggle should no longer be selected
cy.getByTestId("assign-all-systems-toggle").within(() => {
cy.get("span").should("not.have.attr", "data-checked");
});
cy.getByTestId("assign-all-systems-toggle").should(
"have.attr",
"aria-checked",
"false",
);
});
cy.getByTestId("confirm-btn").click();
cy.getByTestId("save-btn").click();
Expand All @@ -450,17 +452,21 @@ describe("User management", () => {
});

it("can use the select all toggle to unassign systems", () => {
cy.getByTestId("assign-all-systems-toggle").within(() => {
cy.get("span").should("have.attr", "data-checked");
});
cy.getByTestId("assign-all-systems-toggle").should(
"have.attr",
"aria-checked",
"true",
);
// all toggles in every row should be checked

cy.getByTestId("assign-systems-modal-body").within(() => {
systems.forEach((fidesKey) => {
cy.getByTestId(`row-${fidesKey}`).within(() => {
cy.getByTestId("assign-switch").within(() => {
cy.get("span").should("have.attr", "data-checked");
});
cy.getByTestId("assign-switch").should(
"have.attr",
"aria-checked",
"true",
);
});
});
});
Expand All @@ -470,9 +476,11 @@ describe("User management", () => {
cy.getByTestId("assign-systems-modal-body").within(() => {
systems.forEach((fidesKey) => {
cy.getByTestId(`row-${fidesKey}`).within(() => {
cy.getByTestId("assign-switch").within(() => {
cy.get("span").should("not.have.attr", "data-checked");
});
cy.getByTestId("assign-switch").should(
"have.attr",
"aria-checked",
"false",
);
});
});
});
Expand All @@ -496,23 +504,29 @@ describe("User management", () => {
["demo_marketing_system", "demo_analytics_system"].forEach(
(fidesKey) => {
cy.getByTestId(`row-${fidesKey}`).within(() => {
cy.getByTestId("assign-switch").within(() => {
cy.get("span").should("not.have.attr", "data-checked");
});
cy.getByTestId("assign-switch").should(
"have.attr",
"aria-checked",
"false",
);
});
},
);

// the one that was not in the search should not have been affected
cy.getByTestId("system-search").clear();
cy.getByTestId(`row-fidesctl_system`).within(() => {
cy.getByTestId("assign-switch").within(() => {
cy.get("span").should("have.attr", "data-checked");
});
});
cy.getByTestId("assign-all-systems-toggle").within(() => {
cy.get("span").should("not.have.attr", "data-checked");
cy.getByTestId("assign-switch").should(
"have.attr",
"aria-checked",
"true",
);
});
cy.getByTestId("assign-all-systems-toggle").should(
"have.attr",
"aria-checked",
"false",
);

// now do the reverse: toggle on while filtered
// toggle everyone off by clicking on the all toggle twice
Expand All @@ -523,9 +537,11 @@ describe("User management", () => {
cy.getByTestId("assign-all-systems-toggle").click();
cy.getByTestId("system-search").clear();
cy.getByTestId(`row-fidesctl_system`).within(() => {
cy.getByTestId("assign-switch").within(() => {
cy.get("span").should("not.have.attr", "data-checked");
});
cy.getByTestId("assign-switch").should(
"have.attr",
"aria-checked",
"false",
);
});
});
});
Expand Down
29 changes: 0 additions & 29 deletions clients/admin-ui/src/features/common/ClassifyResultsToggle.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions clients/admin-ui/src/features/common/PIIToggle.tsx

This file was deleted.

Loading

0 comments on commit feeeae1

Please sign in to comment.