diff --git a/src/app/components/elements/inputs/RegistrationEmailPreference.tsx b/src/app/components/elements/inputs/RegistrationEmailPreference.tsx index 9fc300b8ff..9491bb3bd0 100644 --- a/src/app/components/elements/inputs/RegistrationEmailPreference.tsx +++ b/src/app/components/elements/inputs/RegistrationEmailPreference.tsx @@ -13,8 +13,7 @@ interface RegistrationEmailPreferenceProps { type EmailPreferenceDescriptions = { assignments: string; - news: string; - events: string; + newsAndUpdates: string; }; export const RegistrationEmailPreference = ({ @@ -26,16 +25,15 @@ export const RegistrationEmailPreference = ({ const preferences = [ { key: "assignments", + label: "Assignments", property: "ASSIGNMENTS", condition: userRole === "STUDENT", }, - { key: "news", property: "NEWS_AND_UPDATES" }, - { key: "events", property: "EVENTS" }, + { key: "newsAndUpdates", label: "News and Updates", property: "NEWS_AND_UPDATES" }, ]; const isaacEmailPreferenceDescriptions: EmailPreferenceDescriptions = { assignments: "Receive assignment notifications from your teacher.", - news: "Be the first to know about new topics, new platform features, and our fantastic competition giveaways.", - events: "Get valuable updates on our free student workshops happening near you.", + newsAndUpdates: "Be the first to know about new topics, platform features, competitions and free student events.", }; return ( @@ -50,7 +48,7 @@ export const RegistrationEmailPreference = ({ const description = isaacEmailPreferenceDescriptions[preference.key as keyof EmailPreferenceDescriptions]; return preference.condition === undefined || preference.condition ? ( - {preference.key.charAt(0).toUpperCase() + preference.key.slice(1)} + {preference.label} {description} Get important information about the Isaac {SITE_SUBJECT_TITLE} programme delivered to your inbox. These settings can be changed at any time. Expect a monthly newsletter featuring news, updates, and event announcements. - Assignment notifications will be sent as needed by your teacher.{" "} - {userIsStudent && "Assignment notifications will be sent as needed by your teacher."} + {userIsStudent && " Assignment notifications will be sent as needed by your teacher."}

diff --git a/src/app/services/validation.ts b/src/app/services/validation.ts index 610a792c27..8f8e1023f3 100644 --- a/src/app/services/validation.ts +++ b/src/app/services/validation.ts @@ -360,7 +360,7 @@ export const getPasswordInfo = (password: string) => { export const validateEmailPreferences = (emailPreferences?: UserEmailPreferences | null) => { return ( emailPreferences && - [emailPreferences.ASSIGNMENTS, emailPreferences.EVENTS, emailPreferences.NEWS_AND_UPDATES].reduce( + [emailPreferences.ASSIGNMENTS, emailPreferences.NEWS_AND_UPDATES].reduce( // Make sure all expected values are either true or false (prev, next) => prev && (next === true || next === false), true, diff --git a/src/test/components/elements/inputs/RegistrationEmailPreference.test.tsx b/src/test/components/elements/inputs/RegistrationEmailPreference.test.tsx index a50ac2ea0a..2e5d25712b 100644 --- a/src/test/components/elements/inputs/RegistrationEmailPreference.test.tsx +++ b/src/test/components/elements/inputs/RegistrationEmailPreference.test.tsx @@ -5,18 +5,16 @@ import { TestUserRole, renderTestEnvironment } from "../../../utils"; describe("RegistrationEmailPreference", () => { const mockSetEmailPreferences = jest.fn(); - const preferences = ["NEWS_AND_UPDATES", "ASSIGNMENTS", "EVENTS"]; + const preferences = ["NEWS_AND_UPDATES", "ASSIGNMENTS"]; const getOptions = { assignments: () => screen.getByText("Assignments"), - news: () => screen.getByText("News"), - events: () => screen.getByText("Events"), + newsAndUpdates: () => screen.getByText("News and Updates"), assignmentsDescription: () => screen.getByText("Receive assignment notifications from your teacher."), - newsDescription: () => + newsAndUpdatesDescription: () => screen.getByText( - "Be the first to know about new topics, new platform features, and our fantastic competition giveaways.", + "Be the first to know about new topics, platform features, competitions and free student events.", ), - eventsDescription: () => screen.getByText("Get valuable updates on our free student workshops happening near you."), }; const setupTest = (role: TestUserRole, props = {}) => { @@ -36,15 +34,8 @@ describe("RegistrationEmailPreference", () => { it("renders correct options for student registration", () => { setupTest("STUDENT"); - const { assignments, news, events, assignmentsDescription, newsDescription, eventsDescription } = getOptions; - const allOptions = [ - assignments(), - assignmentsDescription(), - news(), - newsDescription(), - events(), - eventsDescription(), - ]; + const { assignments, newsAndUpdates, assignmentsDescription, newsAndUpdatesDescription } = getOptions; + const allOptions = [assignments(), assignmentsDescription(), newsAndUpdates(), newsAndUpdatesDescription()]; allOptions.forEach((option) => { expect(option).toBeInTheDocument(); }); @@ -52,8 +43,8 @@ describe("RegistrationEmailPreference", () => { it("renders correct options for teacher registration", () => { setupTest("TEACHER"); - const { news, newsDescription, events, eventsDescription } = getOptions; - [news(), newsDescription(), events(), eventsDescription()].forEach((option) => { + const { newsAndUpdates, newsAndUpdatesDescription } = getOptions; + [newsAndUpdates(), newsAndUpdatesDescription()].forEach((option) => { expect(option).toBeInTheDocument(); }); const assignmentsOption = screen.queryByText("Assignments"); @@ -79,14 +70,14 @@ describe("RegistrationEmailPreference", () => { it("if form submission is attempted but not all preferences are selected, affected options are marked as invalid, and 'required' feedback shows", () => { setupTest("STUDENT", { submissionAttempted: true, - emailPreferences: { ASSIGNMENTS: false, EVENTS: true }, + emailPreferences: { ASSIGNMENTS: false }, }); const newsPreferenceTrueLabel = screen.getByLabelText(/Yes.*for NEWS_AND_UPDATES/); const newsPreferenceFalseLabel = screen.getByLabelText(/No.*for NEWS_AND_UPDATES/); expect(newsPreferenceTrueLabel).toBeInvalid(); expect(newsPreferenceFalseLabel).toBeInvalid(); const emailPreferenceFeedback = screen.getByText("required", { - selector: "#news-feedback", + selector: "#newsAndUpdates-feedback", }); expect(emailPreferenceFeedback).toBeInTheDocument(); }); @@ -96,7 +87,6 @@ describe("RegistrationEmailPreference", () => { submissionAttempted: true, emailPreferences: { ASSIGNMENTS: false, - EVENTS: true, NEWS_AND_UPDATES: true, }, }); diff --git a/src/test/pages/StudentRegistration.test.tsx b/src/test/pages/StudentRegistration.test.tsx index 2902b30e94..67be55ec8e 100644 --- a/src/test/pages/StudentRegistration.test.tsx +++ b/src/test/pages/StudentRegistration.test.tsx @@ -48,7 +48,7 @@ describe("Student Registration", () => { examBoard, assignmentPreferences, newsPreferences, - events, + // events, submitButton, recaptcha, } = formFields; @@ -66,7 +66,7 @@ describe("Student Registration", () => { examBoard(), assignmentPreferences(), newsPreferences(), - events(), + // events(), submitButton(), recaptcha(), ].forEach((each) => expect(each).toBeVisible()); @@ -110,7 +110,6 @@ describe("Student Registration", () => { EMAIL_PREFERENCE: { NEWS_AND_UPDATES: false, ASSIGNMENTS: true, - EVENTS: false, }, }), expect.objectContaining([ diff --git a/src/test/pages/TeacherRegistration.test.tsx b/src/test/pages/TeacherRegistration.test.tsx index 9caf205881..876a3d33c2 100644 --- a/src/test/pages/TeacherRegistration.test.tsx +++ b/src/test/pages/TeacherRegistration.test.tsx @@ -80,7 +80,6 @@ describe("Teacher Registration", () => { stage, examBoard, newsPreferences, - events, submitButton, verificationInfo, additionalInfo, @@ -103,7 +102,6 @@ describe("Teacher Registration", () => { stage(), examBoard(), newsPreferences(), - events(), submitButton(), verificationInfo(), additionalInfo(), @@ -172,7 +170,6 @@ describe("Teacher Registration", () => { EMAIL_PREFERENCE: { NEWS_AND_UPDATES: false, ASSIGNMENTS: true, - EVENTS: false, }, }), expect.objectContaining([ diff --git a/src/test/utils.tsx b/src/test/utils.tsx index e03bc42532..8ceb1c4002 100644 --- a/src/test/utils.tsx +++ b/src/test/utils.tsx @@ -182,7 +182,6 @@ export const getFormFields = () => { verificationInfo: () => screen.getByRole("textbox", { name: /url of a page/i }), assignmentPreferences: () => screen.queryByRole("cell", { name: /receive assignment/i }), newsPreferences: () => screen.getByRole("radio", { name: /no for news_and_updates/i }), - events: () => screen.getByRole("radio", { name: /no for events/i }), additionalInfo: () => screen.getByRole("textbox", { name: /any other information/i }), otherInfo: () => screen.getByRole("textbox", { name: /other information/i }), submitButton: () => screen.getByRole("button", { name: "Register my account" }), @@ -209,7 +208,6 @@ export const fillFormCorrectly = async (correctly: boolean, role: "teacher" | "s stage, verificationInfo, newsPreferences, - events, otherInfo, recaptcha, } = formFields; @@ -223,7 +221,6 @@ export const fillFormCorrectly = async (correctly: boolean, role: "teacher" | "s await fillTextField(password(), registrationUserData.password); await fillTextField(confirmPassword(), registrationUserData.password); await userEvent.click(newsPreferences()); - await userEvent.click(events()); await userEvent.click(noSchool()); await selectOption(stage(), registrationUserData.stage); await fillTextField(otherInfo(), "extra information"); @@ -249,7 +246,6 @@ export const fillFormCorrectly = async (correctly: boolean, role: "teacher" | "s password, confirmPassword, newsPreferences, - events, recaptcha, } = formFields; await fillTextField(givenName(), registrationUserData.givenName); @@ -263,7 +259,6 @@ export const fillFormCorrectly = async (correctly: boolean, role: "teacher" | "s await fillTextField(password(), registrationUserData.password); await fillTextField(confirmPassword(), registrationUserData.password); await userEvent.click(newsPreferences()); - await userEvent.click(events()); } else { await fillTextField(password(), registrationUserData.wrongPassword); await fillTextField(confirmPassword(), registrationUserData.wrongPassword);