Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 6, 2025

Overview

This PR adds comprehensive unit tests for TypeScript utility functions and feature flags helper methods as requested. All tests have been organized in a new test/ folder that is a sibling to the src/ folder, following best practices for test organization.

Changes

Test Organization

  • Created new frontend/test/ directory structure with subdirectories for utils/ and constants/
  • Moved existing test files (sample.test.ts, setupTests.ts) from src/ to test/ folder
  • Updated jest.config.js configuration to reference the new test folder location

Test Coverage

Utils Tests (100% coverage for targeted files)

storage.ts - 16 tests covering:

  • Value storage with various data types (strings, numbers, booleans, objects, arrays)
  • Value retrieval with type safety
  • Default value handling when keys don't exist
  • Error handling for malformed JSON data
  • Integration tests for store/retrieve workflows

colors.ts - 13 tests covering:

  • Text color computation based on background luminance
  • Color option lookups from predefined color palette
  • Edge cases near the luminance threshold
  • Undefined/invalid color handling

date.ts - 13 tests covering:

  • Ordinal suffix generation for all day numbers (1st, 2nd, 3rd, 4th, etc.)
  • Special cases for numbers 11-13 (always "th")
  • Edge cases including 0 and numbers greater than 31

dom.ts - 11 tests covering:

  • Mobile device detection based on viewport width
  • Document title setting with application prefix
  • Theme application via data attributes

grouping.ts - 9 tests covering:

  • Default expanded state generation for due date grouping
  • Default expanded state generation for label grouping
  • Multiple label handling with different IDs

Feature Flags Tests (100% coverage)

featureFlags.ts - 16 tests covering:

  • Feature flag storage with proper prefixing
  • Feature flag retrieval with default values
  • Multiple independent feature flags
  • Flag updates and toggles
  • Integration tests for get/set operations

Test Quality

  • 78 tests total, all passing ✅
  • Tests use Jest with jsdom environment for DOM testing
  • Proper test isolation with beforeEach hooks for cleanup
  • Comprehensive edge case coverage
  • No linting issues
  • All tests follow existing conventions

Notes

  • Did not test Redux state or React components as specified in requirements
  • The useRoot() function in dom.ts was intentionally not tested due to module-level state caching between test runs
  • All existing functionality remains unchanged
  • Test infrastructure properly configured and validated
Original prompt

Write some unit tests to test the typescript code, under the utils folder as well as the feature flags helper methods. Do not test the redux state or the react components. Make sure all the tests are in a test/ folder sibling to the src/ folder. Move any existing test related sources under that test folder.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 6, 2025 00:32
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for utils and feature flags helper Add comprehensive unit tests for utils and feature flags Oct 6, 2025
Copilot AI requested a review from dkhalife October 6, 2025 00:42
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dkhalife dkhalife marked this pull request as ready for review October 6, 2025 00:55
Copilot AI review requested due to automatic review settings October 6, 2025 00:55
@dkhalife dkhalife merged commit 8938f1c into main Oct 6, 2025
14 checks passed
@dkhalife dkhalife deleted the copilot/add-unit-tests-for-utils branch October 6, 2025 00:55
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 PR adds comprehensive unit tests for TypeScript utility functions and feature flags, restructuring the test organization by moving all test files to a dedicated test/ folder at the project root.

  • Created 78 unit tests covering all utility functions and feature flags with 100% coverage
  • Reorganized test structure by moving test files from src/ to test/ folder
  • Updated Jest configuration to reference the new test folder location

Reviewed Changes

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

Show a summary per file
File Description
frontend/test/utils/storage.test.ts Tests for localStorage storage/retrieval functions with type safety and error handling
frontend/test/utils/grouping.test.ts Tests for default expanded state generation for due date and label grouping
frontend/test/utils/dom.test.ts Tests for mobile detection, document title setting, and theme application
frontend/test/utils/date.test.ts Tests for ordinal suffix generation covering all day numbers and edge cases
frontend/test/utils/colors.test.ts Tests for text color computation and color option lookups from predefined palette
frontend/test/constants/featureFlags.test.ts Tests for feature flag storage/retrieval with proper prefixing and default values
frontend/jest.config.js Updated Jest configuration to reference new test folder structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +78 to +79


Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

[nitpick] Remove the empty lines between test blocks to maintain consistent spacing throughout the file.

Suggested change

Copilot uses AI. Check for mistakes.
dkhalife added a commit that referenced this pull request Oct 9, 2025
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
dkhalife added a commit that referenced this pull request Oct 11, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

2 participants