Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mntor 1564 - Add Survey Recruitment Link #3030

Merged
merged 6 commits into from
May 16, 2023
Merged

Conversation

maxxcrawford
Copy link
Contributor

Summary

This PR adds a survey recruitment link to the top of the page for logged-in/English speaking users.

Acceptance Criteria

  • Show to en-us only
  • Show only on the signed in dashboard page
  • Banner is dismissable

References:

Jira: MNTOR-1564
Figma: N/A

Testing

To show the recruitment link, three items must be true:

  • Set the following variables in .env:
    • RECRUITMENT_BANNER_LINK=https://survey.alchemer.com/s3/6785097/9ee8eccacd7b
    • RECRUITMENT_BANNER_TEXT=Tell us about your experience with Firefox Monitor and receive a $100 Amazon gift card.
  • Set your primary browser language to an English variant (en, en-us, etc).

To "reset" this banner, you'll need to delete a cookie. You can do that by:

  • Open Web Developer Tools on http://localhost:6060 page
  • Click on "Storage" tab
  • Click "Cookies"
  • Click http://localhost:6060
  • Remove the recruited cookie

Please reset your app between each test.

Test: Click Survey Link

  • Run app locally, open homepage in logged out state
  • Expected: No banner should be visible
  • Log in. Go to dashboard.
  • Expected: Banner should be visible
  • Click on text link "Tell us about…"
  • Expected: New tab should open to survey link set in ENV
  • Return to dashboard tab, refresh page
  • Expected: Banner should no longer be visible

Test: Click Dismiss Link on Survey

  • Run app locally, open homepage in logged out state
  • Expected: No banner should be visible
  • Log in. Go to dashboard.
  • Expected: Banner should be visible
  • Click on X/dismiss button on the banner
  • Expected: Banner should no longer be visible
  • Refresh page
  • Expected: Banner should still not be visible

Test: Set Browser to non-English language

  • Run app locally, open homepage in logged out state
  • Expected: No banner should be visible
  • Log in. Go to dashboard.
  • Expected: Banner should be visible
  • Set browser to German (de)
  • Refresh page
  • Expected: Banner should no longer be visible

Checklist (Definition of Done)

  • Localization strings (if needed) have been added.
  • Commits in this PR are minimal and have descriptive commit messages.
  • I've added or updated the relevant sections in readme and/or code comments
  • I've added a unit test to test for potential regressions of this bug.
  • Product Owner accepted the User Story (demo of functionality completed) or waived the privilege.
  • All acceptance criteria are met.
  • Jira ticket has been updated (if needed) to match changes made during the development process.
  • Jira ticket has been updated (if needed) with suggestions for QA when this PR is deployed to stage.

Screenshots

image

image

@maxxcrawford maxxcrawford force-pushed the MNTOR-1564-survey-link branch from b778f5a to fc957ce Compare May 10, 2023 17:30
src/client/js/recruitmentSurvey.js Outdated Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
}

const recruitmentBanner = () => `
<div role="banner" class="recruitment-banner" hidden>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a11y note: Added "banner" type aria role to the element

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looking at that page, that doesn't seem appropriate for this use case? Our site already has a <header>, which has the same role, and:

each page should generally be limited to a single element with the role of banner.

It also says:

The banner typically includes things such as a logo or corporate identity, or possibly a site-specific search tool, and is generally what your marketing team would call the "header" or "top banner" of the site.

Which I don't think it is.

That said, always 👏 for giving a11y some thought!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, and since it's within that <header> it would even be a banner inside a banner 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in ad11567

src/views/mainLayout.js Outdated Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
src/client/css/surveyBanner.css Show resolved Hide resolved
src/client/css/surveyBanner.css Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@Vinnl Vinnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, not much to add to Kaitlyn and Peter's comments.

src/client/js/recruitmentSurvey.js Outdated Show resolved Hide resolved
src/client/css/surveyBanner.css Show resolved Hide resolved
src/views/mainLayout.js Outdated Show resolved Hide resolved
}

const recruitmentBanner = () => `
<div role="banner" class="recruitment-banner" hidden>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looking at that page, that doesn't seem appropriate for this use case? Our site already has a <header>, which has the same role, and:

each page should generally be limited to a single element with the role of banner.

It also says:

The banner typically includes things such as a logo or corporate identity, or possibly a site-specific search tool, and is generally what your marketing team would call the "header" or "top banner" of the site.

Which I don't think it is.

That said, always 👏 for giving a11y some thought!

Comment on lines 32 to 36
<button id="recruitment-dismiss" class="dismiss-btn">
<svg class="x-close-icon" role="button" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z"/></svg>
</button>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This button doesn't currently have a text equivalent (e.g. "Close" or "Dismiss"). Alt text for embedded SVGs are a bit of a hassle (I think you need both an aria-label and a <title> element, although the latter will also make the alt text visible on hover), but perhaps you could add an aria-label to the button?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added aria-label="Close" to the SVG in ad11567

Copy link
Collaborator

@Vinnl Vinnl May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads-up that that will need to be localised as well :)

Edit: stole Peter's genius it seems like :)

src/views/mainLayout.js Outdated Show resolved Hide resolved
}

const recruitmentBanner = () => `
<div role="banner" class="recruitment-banner" hidden>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, and since it's within that <header> it would even be a banner inside a banner 😅


switch (true) {
case e.target.matches('#recruitment-banner-dimiss'):
document.getElementById('recruitment-banner-link').parentElement.remove()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Do we need to remove the link/button event listeners here as well?

Copy link
Contributor Author

@maxxcrawford maxxcrawford May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same question myself here: #3030 (comment) I'll ask UX and follow-up!

Nevermind. I misread your question. Looking into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, I'm quoting StackOverflow here:

In modern browsers, you do not need to remove event listeners before removing elements from the DOM. If there are no direct references to that particular DOM element elsewhere in your javascript (e.g. the DOM element reference stored in a JS variable), then the DOM element will be garbage collected after removal. The DOM garbage collector is smart enough to know that an event listener does not count as a reference to that DOM element once it's been removed from the DOM (because DOM events cannot happen when it is removed from the DOM).

I think it's parents' removal is enough to break the references.

Unless the references on L16/L17 are still "references" in memory. I was gonna let QA see what breaks from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other thing I could do is directly remove the entire banner, rather than the .parentElement bit.

Suggested change
document.getElementById('recruitment-banner-link').parentElement.remove()
recruitmentBanner.remove()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vinnl @pdehaan LMK if that is enough answer for y'all. 😅

Copy link
Collaborator

@Vinnl Vinnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you address Peter's comments I think this is good to go by now :)

src/client/css/surveyBanner.css Outdated Show resolved Hide resolved
@maxxcrawford maxxcrawford force-pushed the MNTOR-1564-survey-link branch from f42f37e to 1813bc7 Compare May 16, 2023 14:57
@maxxcrawford maxxcrawford merged commit a3b927e into main May 16, 2023
@maxxcrawford maxxcrawford deleted the MNTOR-1564-survey-link branch May 16, 2023 15:35
mansaj added a commit that referenced this pull request May 22, 2023
* main: (25 commits)
  fix: use new error classes from cloud function (#3064)
  Rename cloud-functions dir, and make missing required env vars warning not error (#3059)
  Mntor 1539/separate data ingestion (#3034)
  Merge `main` into `localization` (#3052)
  Fix MNTOR-1598 - Add wrapper to input form on homepage breach scan (#3045)
  Mntor 1564 - Add Survey Recruitment Link (#3030)
  ADR Proposal: Add React Framework (#3019)
  chore: Remove FluentError
  chore: Set default error message
  Delete styleGuide.js
  add localized text
  add more descriptive alt attribute for mainlayout
  MNTOR-1471 - Add missing alt/aria-label attributes on img elements
  chore: Use enum for the toast type
  chore: Throw errors with new
  chore: Omit redundant error message
  fix: FluentError test
  chore: Add tests for error classes
  fix: ClientError import path
  chore: Remove option to redirect from ClientError
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants