Skip to content

test(surveys): add unit tests for skipSurvey() function#447

Open
sannidhyaroy wants to merge 2 commits intoOneBusAway:developfrom
sannidhyaroy:test/skip-survey-unit-tests
Open

test(surveys): add unit tests for skipSurvey() function#447
sannidhyaroy wants to merge 2 commits intoOneBusAway:developfrom
sannidhyaroy:test/skip-survey-unit-tests

Conversation

@sannidhyaroy
Copy link
Copy Markdown

Summary

Adds unit tests for skipSurvey() covering the three cases outlined in #444:

  • Recurring survey skip (allows_multiple_responses: true, always_visible: true): verifies only _skipped_timestamp is set
  • One-time survey skip: verifies only _skipped is set
  • Stale flag cleanup: verifies _skipped is removed when a recurring survey is skipped again

Closes #444

Test plan

  • npm run test passes

Copilot AI review requested due to automatic review settings March 26, 2026 01:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing unit test coverage for skipSurvey() to prevent regressions in recurring vs one-time survey skip behavior (per #444 / PR #420 context).

Changes:

  • Import skipSurvey into the existing surveys utils test suite.
  • Add 3 new skipSurvey() unit tests covering recurring skip, one-time skip, and stale flag cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sannidhyaroy
Copy link
Copy Markdown
Author

@aaronbrethorst While working on this, I noticed the mock localStorage in the test setup wasn't coercing values to strings like the real browser API does. I've fixed that as part of this PR but I wanted to flag it in case you'd prefer that as a separate change...?

I didn't want to change it initially as I feared it could break existing tests that rely on its current behavior. But, Copilot is right that the toBeTruthy() makes the test weaker. I reviewed and found that all existing setItem calls pass strings ('true').

Let me know if there's anything to adjust here.

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.

Add unit tests for skipSurvey() function

2 participants