Skip to content

Commit

Permalink
survey popup always shows link, scroll not locked
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshiel committed May 12, 2022
1 parent 3d7cbd0 commit 5ffaa53
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions client/src/components/disclaimer/disclaimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function Disclaimer(): JSX.Element {
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
data-cy="disclaimer-container"
disableScrollLock={true}
style={{ height: "100%", display: open ? "block" : "none" }}
>
<Box className="modal-animation">
Expand Down
26 changes: 9 additions & 17 deletions client/src/components/survey-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {

export function SurveyDialog(props: { noLabel?: boolean }): JSX.Element {
const [title, setTitle] = useState<string>("");
const [displaySurveyLink, setDisplaySurveyLink] = useState<boolean>(false);
const [pollingTimer, setPollingTimer] = useState<boolean>(false);
const [showSurveyPopup, setShowSurveyPopup] = useState<boolean>(false);
const surveyLink = `https://fullerton.qualtrics.com/jfe/form/SV_1ZzDYgNPzLE2QPI?userid=${getLocalStorage(
Expand Down Expand Up @@ -82,21 +81,16 @@ export function SurveyDialog(props: { noLabel?: boolean }): JSX.Element {
: `${timeSpentOnPage} seconds`;
let surveyPopupTitleText = "";
if (!surveyWaitTimeFromLocalStorage || !timeSpentOnPageFromLocalStorage) {
// local storage is not setup correctly, just display the survey to take at any time
setDisplaySurveyLink(true);
surveyPopupTitleText +=
"After spending some time with our site, you may click the link below to take our survey!";
} else {
// Only display the survey link if enough time has passed
surveyPopupTitleText += `You have spent ${timeSpentOnPageText} on this site.`;
const shouldDisplaySurveyLink = timeSpentOnPage >= surveyWaitTime;
if (shouldDisplaySurveyLink) {
setDisplaySurveyLink(true);
surveyPopupTitleText +=
" Please click the link below to take our survey!";
} else {
setDisplaySurveyLink(false);

const timeLeftToSpendOnPage = surveyWaitTime - timeSpentOnPage;
const timeLeftToSpendOnPageText =
timeLeftToSpendOnPage > 60
Expand Down Expand Up @@ -186,17 +180,15 @@ export function SurveyDialog(props: { noLabel?: boolean }): JSX.Element {
>
<DialogTitle data-cy="survey-dialog-title">{title}</DialogTitle>

{displaySurveyLink ? (
<a
href={surveyLink}
target="_blank"
rel="noopener noreferrer"
style={{ fontSize: "24px", paddingBottom: "16px" }}
data-cy="survey-link"
>
Careerfair Survey
</a>
) : undefined}
<a
href={surveyLink}
target="_blank"
rel="noopener noreferrer"
style={{ fontSize: "24px", paddingBottom: "16px" }}
data-cy="survey-link"
>
Careerfair Survey
</a>
<DialogContent>
<Button onClick={onClose}>Close</Button>
</DialogContent>
Expand Down
6 changes: 3 additions & 3 deletions cypress/cypress/integration/survey-popup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Disclaimer Survey Popup Button", () => {
.should("be.visible");
});

it("If just qualtrics id is set nad nothing else, make sure to display link", () => {
it("If just qualtrics id is set and nothing else", () => {
visitAsGuestWithDefaultSetup(cy, "/");
window.localStorage.setItem("qualtricsuserid", "123");
cy.get("[data-cy=header-disclimer-btn]").invoke("mouseover").click();
Expand All @@ -44,14 +44,14 @@ describe("Disclaimer Survey Popup Button", () => {
cy.get("[data-cy=survey-link]").should("be.visible");
});

it("Does not display link if local storage is setup correctly and time not passed", () => {
it("If local storage is setup correctly and time not passed", () => {
visitAsGuestWithDefaultSetup(cy, "/?postsurveytime=10&userid=123");
cy.get("[data-cy=header-disclimer-btn]").should("be.visible");
cy.get("[data-cy=header-disclimer-btn]").invoke("mouseover").click();
cy.get("[data-cy=header-survey-popup-btn]").invoke("mouseover").click();
cy.get("[data-cy=survey-dialog]").should("be.visible");
cy.get("[data-cy=survey-dialog-title]").should("be.visible");
cy.get("[data-cy=survey-link]").should("not.exist");
cy.get("[data-cy=survey-link]").should("exist");
});
});

Expand Down

0 comments on commit 5ffaa53

Please sign in to comment.