Skip to content

Commit

Permalink
Fix vendor tests (#4363)
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonking authored Oct 31, 2023
1 parent a0e6f6d commit 1a8f26b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 42 deletions.
16 changes: 10 additions & 6 deletions clients/admin-ui/cypress/e2e/systems-plus.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ describe("System management with Plus features", () => {
cy.getSelectValueContainer("input-vendor_id");
});

it("contains dictionary entries", () => {
cy.selectOption("input-vendor_id", "Aniview LTD");
it("contains type ahead dictionary entries", () => {
cy.getSelectValueContainer("input-vendor_id").type("A");
cy.get("#react-select-select-vendor_id-option-0").contains("Aniview LTD");
cy.get("#react-select-select-vendor_id-option-1").contains(
"Anzu Virtual Reality LTD"
);
});

it("can switch entries", () => {
cy.selectOption("input-vendor_id", "Aniview LTD");
cy.getSelectValueContainer("input-vendor_id").type("Aniview{enter}");
cy.getSelectValueContainer("input-vendor_id").contains("Aniview LTD");

cy.selectOption("input-vendor_id", "Anzu Virtual Reality LTD");
cy.getSelectValueContainer("input-vendor_id").type("Anzu{enter}");
cy.getSelectValueContainer("input-vendor_id").contains(
"Anzu Virtual Reality LTD"
);
Expand All @@ -55,7 +59,7 @@ describe("System management with Plus features", () => {
// modal to pop up incorrectly when switching tabs
it("can switch between tabs after populating from dictionary", () => {
cy.wait("@getSystems");
cy.selectOption("input-vendor_id", "Anzu Virtual Reality LTD");
cy.getSelectValueContainer("input-vendor_id").type("Anzu{enter}");
cy.getByTestId("dict-suggestions-btn").click();
cy.getByTestId("toggle-dict-suggestions").click();
// the form fetches the system again after saving, so update the intercept with dictionary values
Expand All @@ -67,6 +71,7 @@ describe("System management with Plus features", () => {
body: {
...origSystem,
...dictSystem,
fides_key: origSystem.fides_key,
customFieldValues: undefined,
data_protection_impact_assessment: undefined,
},
Expand All @@ -83,7 +88,6 @@ describe("System management with Plus features", () => {
cy.getByTestId("input-dpo").should("have.value", "[email protected]");
cy.getByTestId("tab-Data uses").click();
cy.getByTestId("tab-System information").click();
// cy.pause();
cy.getByTestId("tab-Data uses").click();
cy.getByTestId("confirmation-modal").should("not.exist");
});
Expand Down
5 changes: 4 additions & 1 deletion clients/admin-ui/cypress/fixtures/plus_health.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"enabled": true,
"service_health": null,
"service_error": null
}
},
"fidesplus_version": "2.2.0",
"fides_cloud": { "enabled": true },
"tcf": { "enabled": true }
}
3 changes: 2 additions & 1 deletion clients/admin-ui/cypress/fixtures/systems/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"special_category_legal_basis": "Explicit Consent",
"data_shared_with_third_parties": false,
"third_parties": [],
"shared_categories": []
"shared_categories": [],
"id": "pri_ac9d4dfb-d033-4b06-bc7f-968df8d125ff"
}
],
"processes_personal_data": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"data_subjects": ["customer"],
"dataset_references": ["demo_users_dataset"],
"egress": null,
"ingress": null
"ingress": null,
"id": "pri_ac9d4dfb-d033-4b06-bc7f-968df8d125ff"
}
],
"joint_controller": null,
Expand Down Expand Up @@ -113,7 +114,8 @@
"data_subjects": ["customer"],
"dataset_references": null,
"egress": null,
"ingress": null
"ingress": null,
"id": "pri_06430a1c-1365-422e-90a7-d444ddb32181"
}
],
"joint_controller": null,
Expand Down
68 changes: 37 additions & 31 deletions clients/admin-ui/src/features/system/SystemFormTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, Button, Text, useToast } from "@fidesui/react";
import { DataFlowAccordion } from "common/system-data-flow/DataFlowAccordion";
import NextLink from "next/link";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";

import { useAppDispatch, useAppSelector } from "~/app/hooks";
import DataTabs, { type TabData } from "~/features/common/DataTabs";
Expand Down Expand Up @@ -109,30 +109,33 @@ const SystemFormTabs = ({
}
}, [activeSystem]);

const handleSuccess = (system: SystemResponse) => {
// show a save message if this is the first time the system was saved
if (activeSystem === undefined) {
setShowSaveMessage(true);
}
dispatch(setActiveSystem(system));
const toastParams = {
...DEFAULT_TOAST_PARAMS,
description: (
<ToastMessage
onViewDatamap={() => {
router.push(systemOrDatamapRoute).then(() => {
const handleSuccess = useCallback(
(system: SystemResponse) => {
// show a save message if this is the first time the system was saved
if (activeSystem === undefined) {
setShowSaveMessage(true);
}
dispatch(setActiveSystem(system));
const toastParams = {
...DEFAULT_TOAST_PARAMS,
description: (
<ToastMessage
onViewDatamap={() => {
router.push(systemOrDatamapRoute).then(() => {
toast.closeAll();
});
}}
onAddPrivacyDeclaration={() => {
setTabIndex(1);
toast.closeAll();
});
}}
onAddPrivacyDeclaration={() => {
setTabIndex(1);
toast.closeAll();
}}
/>
),
};
toast({ ...toastParams });
};
}}
/>
),
};
toast({ ...toastParams });
},
[activeSystem, dispatch, router, systemOrDatamapRoute, toast]
);

useEffect(() => {
/**
Expand All @@ -151,13 +154,16 @@ const SystemFormTabs = ({

const { attemptAction } = useIsAnyFormDirty();

const onTabChange = (index: number) => {
attemptAction().then((modalConfirmed: boolean) => {
if (modalConfirmed) {
setTabIndex(index);
}
});
};
const onTabChange = useCallback(
(index: number) => {
attemptAction().then((modalConfirmed: boolean) => {
if (modalConfirmed) {
setTabIndex(index);
}
});
},
[attemptAction]
);

const tabData: TabData[] = [
{
Expand Down
6 changes: 5 additions & 1 deletion clients/admin-ui/src/features/system/VendorSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const VendorSelector = ({ disabled, options }: Props) => {
</Label>
<QuestionTooltip label="Enter the vendor to associate with the system" />
</Flex>
<Flex position="relative" width="100%">
<Flex
position="relative"
width="100%"
data-testid={`input-${field.name}`}
>
<Select
options={suggestions}
onBlur={(e) => {
Expand Down

0 comments on commit 1a8f26b

Please sign in to comment.