Repository navigation
test: add tests for i18n, darkMode, env parser, and TTS env parsing (#1936 #1937 #1938 #1939) - #1994
Open
emperorsominian-droid wants to merge 1 commit into
Conversation
…olutions-plug#1936 solutions-plug#1937 solutions-plug#1938 solutions-plug#1939) - frontend/src/lib/__tests__/i18n.test.ts: annotate existing tests with issue solutions-plug#1936 acceptance criteria comments; cover known key resolution, missing-key fallback and unknown-key non-throwing behaviour per I18N_GUIDE.md - frontend/src/lib/__tests__/darkMode.test.ts: new file covering getDarkModePreference (system dark pref, stored explicit choice, no-pref default) and applyDarkModePreference (data-theme attribute set/removed). Stubs window.matchMedia and localStorage; resets between tests. - frontend/src/lib/__tests__/env.test.ts: annotate existing tests with issue solutions-plug#1938 acceptance criteria comments; covers valid parse, missing NEXT_PUBLIC_API_URL error, malformed URL rejection per .env.example. - services/tts/src/__tests__/envParsing.test.ts: new file covering parsePositiveIntEnv: valid integers, documented defaults for absent/empty vars, rejection of non-numeric / zero / negative / float values with descriptive error messages per services/tts/README.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1936, Closes #1937, Closes #1938, Closes #1939
Adds the missing unit tests for four frontend/TTS library helpers that had no test coverage.
#1936 — i18n helper tests
File:
frontend/src/lib/__tests__/i18n.test.tsAnnotated the existing test suite with issue #1936 acceptance criteria comments and verified coverage:
hero.title→ English string)frontend/I18N_GUIDE.md#1937 — darkMode helper tests
File:
frontend/src/lib/__tests__/darkMode.test.ts(new)Tests
getDarkModePreferenceandapplyDarkModePreferencefromdarkMode.ts:matchMediareturnsmatches: trueisDarkMode: falseandhasStoredPreference: falseapplyDarkModePreferencesets / removes thedata-themeattribute correctlywindow.matchMediaandlocalStoragestubbed and reset between tests perjest.setup.jsconventionsfrontend/docs/styling.md#1938 — env parser tests
File:
frontend/src/lib/__tests__/env.test.tsAnnotated the existing test suite with issue #1938 acceptance criteria comments:
frontend/.env.exampleparse successfullyNEXT_PUBLIC_API_URLproduces the documentedMissing or invalid environment variableserrorfrontend/.env.example;process.envrestored viaafterEach#1939 — TTS env parsing tests
File:
services/tts/src/__tests__/envParsing.test.ts(new)Tests
parsePositiveIntEnvfromenvParsing.ts:TTS_RATE_LIMIT_MAX,TTS_RATE_LIMIT_WINDOW_MS,TTS_CACHE_TTL_MS,TTS_CACHE_MAX_ENTRIES,TTS_MAX_INPUT_LENGTH) parse valid integer strings correctlyservices/tts/README.mdprocess.envis restored viaafterEachto keep cases isolatedTesting
Both test suites pass under their existing test commands:
npm run test(Jest + jsdom)npm test(Jest + ts-jest, node environment)