Skip to content

Conversation

@compwron
Copy link
Collaborator

@compwron compwron commented Nov 12, 2025

new js specs

@github-actions github-actions bot added javascript for use by Github Labeler to mark pull requests that update Javascript code Tests! 🎉💖👏 labels Nov 12, 2025
Fixes StandardJS linting errors:
- 'MouseEvent' is not defined at lines 63 and 73

Added browser to eslint-env since the test uses jsdom which simulates
a browser environment where MouseEvent is available as a global.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@compwron compwron marked this pull request as ready for review November 29, 2025 01:04
@compwron compwron requested a review from Copilot November 29, 2025 01:04
@compwron compwron merged commit 01f3fe3 into main Nov 29, 2025
16 checks passed
@compwron compwron deleted the improve-js-tests branch November 29, 2025 01:04
Copy link
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

This work-in-progress PR modernizes JavaScript test files by removing unnecessary jQuery DOM-ready callbacks and async done() patterns, adding comprehensive test coverage for previously untested modules, and improving test clarity.

Key Changes:

  • Removed jQuery $(() => {}) callbacks and async done() patterns from synchronous tests in validated_form.test.js and notifier.test.js
  • Added new test files for TypeChecker, time_zone, and read_more modules
  • Improved test assertions by replacing .toBeTruthy() with .toBe(true) for more precise boolean checks
  • Fixed misleading test description in case_emancipations.test.js
  • Enhanced test coverage for convertDateToSystemTimeZone function in case_contact.test.js

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
app/javascript/tests/validated_form.test.js Removed unnecessary jQuery callbacks and done() patterns from NonDrivingContactMediumWarning tests, making them synchronous
app/javascript/tests/type_checker.test.js Added comprehensive test coverage for TypeChecker utility with edge cases for all validation methods
app/javascript/tests/two_minute_warning_session_timeout.test.js Removed placeholder test that only verified module loading without meaningful assertions
app/javascript/tests/time_zone.test.js Added new tests for findTimeZone function covering format validation and consistency
app/javascript/tests/read_more.test.js Added comprehensive tests for read more/less toggle functionality including event handling and multiple instances
app/javascript/tests/notifier.test.js Modernized tests by removing jQuery callbacks, switching to .toBe(true/false) for boolean assertions
app/javascript/tests/case_emancipations.test.js Fixed test description to accurately reflect test behavior (expects '+' when closed, not '-')
app/javascript/tests/case_contact.test.js Enhanced test coverage with additional test cases for date conversion including edge cases and invalid inputs

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


// Timezone should be in format like "America/New_York" or "Europe/London"
// Common formats: Continent/City or UTC
expect(timezone).toMatch(/^[A-Za-z_]+\/[A-Za-z_]+$|^UTC$|^[A-Z]{3,4}$/)
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

This regex pattern may be too restrictive for all possible timezone formats returned by jstz. The pattern only matches:

  • Continent/City format (e.g., "America/New_York")
  • "UTC"
  • 3-4 uppercase letters (e.g., "EST")

However, jstz can return other formats like "GMT", "GMT+1", "GMT-5", or other variations. Consider using a more flexible pattern or testing against a known list of valid IANA timezone names, or simply verify the string is non-empty since the implementation uses jstz which should always return valid values.

Example alternative:

expect(timezone).toMatch(/^[A-Za-z_0-9+\-\/]+$/)
Suggested change
expect(timezone).toMatch(/^[A-Za-z_]+\/[A-Za-z_]+$|^UTC$|^[A-Z]{3,4}$/)
expect(timezone).toMatch(/^[A-Za-z_0-9+\-\/]+$/)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript for use by Github Labeler to mark pull requests that update Javascript code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants