Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update 'add vendor' flow #4550

Merged
merged 13 commits into from
Jan 12, 2024
178 changes: 21 additions & 157 deletions clients/admin-ui/cypress/e2e/consent-configuration.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import {
stubPlus,
stubSystemCrud,
stubSystemVendors,
stubTaxonomyEntities,
stubVendorList,
} from "cypress/support/stubs";

import { CONFIGURE_CONSENT_ROUTE } from "~/features/common/nav/v2/routes";
import {
ADD_MULTIPLE_VENDORS_ROUTE,
CONFIGURE_CONSENT_ROUTE,
} from "~/features/common/nav/v2/routes";
import { RoleRegistryEnum } from "~/types/api";

describe("Consent configuration", () => {
Expand Down Expand Up @@ -40,7 +44,7 @@ describe("Consent configuration", () => {
cluster_error: null,
},
dictionary: {
enabled: false,
enabled: true,
service_health: null,
service_error: null,
},
Expand All @@ -54,62 +58,8 @@ describe("Consent configuration", () => {
cy.intercept("GET", "/api/v1/system", {
body: [],
}).as("getEmptySystems");
cy.visit(CONFIGURE_CONSENT_ROUTE);
cy.visit(ADD_MULTIPLE_VENDORS_ROUTE);
cy.getByTestId("empty-state");
cy.get("body").click(0, 0);
});
});

describe("with existing systems", () => {
beforeEach(() => {
stubSystemCrud();
stubTaxonomyEntities();
stubPlus(
true,

{
core_fides_version: "1.9.6",
fidesplus_server: "healthy",
fidesplus_version: "1.9.6",
system_scanner: {
enabled: false,
cluster_health: null,
cluster_error: null,
},
dictionary: {
enabled: false,
service_health: null,
service_error: null,
},
tcf: {
enabled: false,
},
fides_cloud: {
enabled: false,
},
}
);
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems.json",
}).as("getSystems");
cy.visit(CONFIGURE_CONSENT_ROUTE);
});

it("can render existing systems and cookies", () => {
// One row per system and one subrow per cookie
cy.getByTestId("grouped-row-demo_analytics_system");
cy.getByTestId("grouped-row-demo_marketing_system");
cy.getByTestId("grouped-row-fidesctl_system");

// One subrow per cookie. Should have corresponding data use
cy.getByTestId("subrow-cell_0_Cookie name").contains("N/A");
cy.getByTestId("subrow-cell_0_Data use").contains("N/A");
cy.getByTestId("subrow-cell_1_Cookie name").contains("_ga");
cy.getByTestId("subrow-cell_1_Data use").contains("Marketing");
cy.getByTestId("subrow-cell_2_Cookie name").contains("cookie");
cy.getByTestId("subrow-cell_2_Data use").contains("Improve Service");
cy.getByTestId("subrow-cell_3_Cookie name").contains("cookie2");
cy.getByTestId("subrow-cell_3_Data use").contains("Improve Service");
});
});

Expand All @@ -121,6 +71,10 @@ describe("Consent configuration", () => {
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems.json",
}).as("getSystems");
cy.intercept("GET", "/api/v1/purposes", {
purposes: ["test"],
special_purposes: ["test"],
}).as("getPurposes");
});

describe("without the dictionary", () => {
Expand Down Expand Up @@ -149,7 +103,7 @@ describe("Consent configuration", () => {
cy.visit(CONFIGURE_CONSENT_ROUTE);
});

it("can add a vendor without the dictionary", () => {
it("can add a vendor from the modal without the dictionary", () => {
cy.getByTestId("add-vendor-btn").click();
cy.getByTestId("input-name").type("test vendor");
cy.selectOption(
Expand Down Expand Up @@ -278,10 +232,17 @@ describe("Consent configuration", () => {
},
}
);
stubSystemVendors();
});

it("redirects to 'add multiple vendors' page when 'Add vendors' is clicked", () => {
cy.visit(CONFIGURE_CONSENT_ROUTE);
cy.getByTestId("add-vendor-btn").click();
cy.url().should("include", "/consent/configure/add-vendors");
});

it("can fill in dictionary suggestions", () => {
it("can add a vendor with dictionary suggestions from the modal", () => {
cy.visit(ADD_MULTIPLE_VENDORS_ROUTE);
cy.getByTestId("add-vendor-btn").click();
cy.getByTestId("input-name").type("Aniview LTD{enter}");
cy.wait("@getDictionaryDeclarations");
Expand Down Expand Up @@ -730,6 +691,7 @@ describe("Consent configuration", () => {
});

it("can create a vendor that is not in the dictionary", () => {
cy.visit(ADD_MULTIPLE_VENDORS_ROUTE);
cy.getByTestId("add-vendor-btn").click();
cy.getByTestId("input-name").type("custom vendor{enter}");
cy.selectOption(
Expand Down Expand Up @@ -764,102 +726,4 @@ describe("Consent configuration", () => {
});
});
});

describe("deleting a vendor", () => {
beforeEach(() => {
stubSystemCrud();
stubTaxonomyEntities();
stubVendorList();
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems.json",
}).as("getSystems");
stubPlus(true, {
core_fides_version: "1.9.6",
fidesplus_server: "healthy",
fidesplus_version: "1.9.6",
system_scanner: {
enabled: false,
cluster_health: null,
cluster_error: null,
},
dictionary: {
enabled: false,
service_health: null,
service_error: null,
},
tcf: {
enabled: false,
},
fides_cloud: {
enabled: false,
},
});
cy.visit(CONFIGURE_CONSENT_ROUTE);
});

it("can delete a vendor", () => {
cy.getByTestId("configure-demo_analytics_system").click();
cy.getByTestId("delete-demo_analytics_system").click();
cy.getByTestId("continue-btn").click();
cy.wait("@deleteSystem").then((interception) => {
const { url } = interception.request;
expect(url).to.contain("demo_analytics_system");
});
cy.getByTestId("toast-success-msg");
});
});

describe("editing a vendor", () => {
beforeEach(() => {
stubSystemCrud();
stubTaxonomyEntities();
stubVendorList();
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems.json",
}).as("getSystems");
stubPlus(true, {
core_fides_version: "1.9.6",
fidesplus_server: "healthy",
fidesplus_version: "1.9.6",
system_scanner: {
enabled: false,
cluster_health: null,
cluster_error: null,
},
dictionary: {
enabled: false,
service_health: null,
service_error: null,
},
tcf: {
enabled: false,
},
fides_cloud: {
enabled: false,
},
});
cy.visit(CONFIGURE_CONSENT_ROUTE);
});

it("can add cookies to a vendor", () => {
cy.getByTestId("configure-demo_marketing_system").click();
cy.getByTestId("edit-demo_marketing_system").click();
cy.getByTestId("input-privacy_declarations.0.cookieNames")
.find(".custom-creatable-select__input-container")
.type("test{enter}");
cy.getByTestId("save-btn").click();
cy.wait("@putSystem").then((interception) => {
const { body } = interception.request;
expect(body.privacy_declarations[0].cookies).to.eql([
{
name: "_ga",
},
{
name: "test",
path: "/",
},
]);
});
});
});
});
4 changes: 1 addition & 3 deletions clients/admin-ui/cypress/e2e/systems-plus.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ describe("System management with Plus features", () => {
it("can add new systems and redirects to datamap", () => {
cy.visit(ADD_SYSTEMS_MULTIPLE_ROUTE);
cy.wait("@getSystemVendors");
cy.getByTestId("row-0").within(() => {
cy.get('[type="checkbox"]').check({ force: true });
});
cy.get('[type="checkbox"').check({ force: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a workaround for some weird behavior with the previous .check() not checking the checkbox-- none of my changes should have been affecting that to my knowledge and the checkboxes works fine manually or if you select them like this.

cy.getByTestId("add-multiple-systems-btn").click();
cy.getByTestId("confirmation-modal");
cy.getByTestId("continue-btn").click();
Expand Down
Loading