diff --git a/client/Makefile b/client/Makefile index 308b6fc4..9ba3713c 100644 --- a/client/Makefile +++ b/client/Makefile @@ -14,7 +14,7 @@ clean: .PHONY: develop develop: .env.development node_modules/gatsby - npx gatsby develop -p 80 + npx gatsby develop -p 8000 .PHONY: format format: diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index cd9de745..c1674745 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -62,6 +62,7 @@ import { EMAIL_URL_PARAM_KEY, EVENTS_KEY, LS_EMAIL_KEY, + LS_LEFT_HOME_PAGE, LS_USER_ID_KEY, LS_X_API_EMAIL_KEY, POST_SURVEY_TIME_KEY, @@ -429,6 +430,11 @@ function IndexPage(props: { ]); useEffect(() => { + const leftHomePageData = getParamURL(LS_LEFT_HOME_PAGE); + if (leftHomePageData) { + setLocalStorage(LS_LEFT_HOME_PAGE, leftHomePageData); + removeQueryParam(LS_LEFT_HOME_PAGE); + } const chatSessionId = uuid(); dispatch(setChatSessionId(chatSessionId)); @@ -485,7 +491,6 @@ function IndexPage(props: { ) { return; } - const findMentor = async () => { // check local store= if (!mentor) { diff --git a/cypress/cypress.config.ts b/cypress/cypress.config.ts index 119ea57c..d625e54f 100644 --- a/cypress/cypress.config.ts +++ b/cypress/cypress.config.ts @@ -10,6 +10,6 @@ export default defineConfig({ setupNodeEvents(on, config) { return require("./cypress/plugins/index.js")(on, config); }, - baseUrl: "http://localhost:80/", + baseUrl: "http://localhost:8000/", }, }); diff --git a/cypress/cypress/e2e/url-params.cy.ts b/cypress/cypress/e2e/url-params.cy.ts index a9d05034..6ed1bcef 100644 --- a/cypress/cypress/e2e/url-params.cy.ts +++ b/cypress/cypress/e2e/url-params.cy.ts @@ -146,4 +146,28 @@ describe("Display Mentor Grid", () => { ); cy.get("[data-cy=username-modal-container]").should("not.exist"); }); + + it("leftHomePage data is pulled from url params", () => { + mockDefaultSetup(cy, { + config: { + displayGuestPrompt: false, + }, + }); + cy.visit( + `/?mentor=carlos&leftHomePage=${encodeURIComponent( + JSON.stringify({ + targetMentors: ["carlos"], + time: new Date().toISOString(), + }) + )}` + ); + cy.wait(1000); + cy.window().then((win) => { + const leftHomePageData = JSON.parse( + win.localStorage.getItem("leftHomePage") + ); + console.log("leftHomePageData", leftHomePageData); + cy.wrap(leftHomePageData.targetMentors).should("deep.equal", ["carlos"]); + }); + }); }); diff --git a/cypress/cypress/support/helpers.ts b/cypress/cypress/support/helpers.ts index d182e0b5..d437a9f7 100644 --- a/cypress/cypress/support/helpers.ts +++ b/cypress/cypress/support/helpers.ts @@ -378,3 +378,14 @@ export function updateLocalStorageUserData( JSON.stringify({ ...startingData, ...updatedObject }) ); } + +export function appendHomePageData(targetMentors: string[], url: string) { + const time = new Date().toISOString(); + const data = { + targetMentors, + time, + }; + const urlParams = new URLSearchParams(url); + urlParams.set("leftHomePage", JSON.stringify(data)); + return `${url}?${urlParams.toString()}`; +}