Skip to content

Commit

Permalink
Make banner title and description nullable, not optional (#4545)
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonking authored Jan 4, 2024
1 parent b15ebbe commit b24c436
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions clients/admin-ui/cypress/e2e/privacy-experiences.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,18 @@ describe("Privacy experiences", () => {
});
interface Props {
component?: "overlay" | "privacy_center";
banner_title?: string;
}
/**
* Helper function to swap out the component type in a stubbed experience
* @example stubExperience({component: "overlay"})
*/
const stubExperience = ({ component }: Props) => {
const stubExperience = (overrides: Props) => {
cy.fixture("privacy-experiences/experienceConfig.json").then(
(experience) => {
const updatedExperience = {
...experience,
component: component ?? experience.component,
...overrides,
};
cy.intercept("GET", "/api/v1/experience-config/pri*", {
body: updatedExperience,
Expand Down Expand Up @@ -285,6 +286,14 @@ describe("Privacy experiences", () => {
});
});

it("can still save when banner title is null", () => {
stubExperience({ component: "overlay", banner_title: null });
cy.visit(`${PRIVACY_EXPERIENCE_ROUTE}/${OVERLAY_EXPERIENCE_ID}`);
cy.getByTestId("save-btn").should("be.disabled");
cy.selectOption("input-banner_enabled", "Enabled where legally required");
cy.getByTestId("save-btn").should("not.be.disabled");
});

it("can submit an overlay form excluding optional values", () => {
stubExperience({ component: "overlay" });
cy.visit(`${PRIVACY_EXPERIENCE_ROUTE}/${OVERLAY_EXPERIENCE_ID}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const bannerValidationSchema = Yup.object()
privacy_preferences_link_label: Yup.string()
.required()
.label("Privacy preferences link label"),
banner_title: Yup.string().optional().label("Banner title"),
banner_description: Yup.string().optional().label("Banner description"),
banner_title: Yup.string().nullable().label("Banner title"),
banner_description: Yup.string().nullable().label("Banner description"),
privacy_policy_link_label: Yup.string()
.nullable()
.label("Privacy policy link label"),
Expand Down

0 comments on commit b24c436

Please sign in to comment.