Skip to content

CS-553 fix: DataCollectionForm component test for the toggle-button switches - #1582

Merged
yuryyas merged 1 commit into
mainfrom
CS-553_fix_DataCollectionForm_component_test
Nov 16, 2026
Merged

yuryyas merged 1 commit into
mainfrom
CS-553_fix_DataCollectionForm_component_test

Conversation

@yuryyas

@yuryyas yuryyas commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

#1575 was merged while its client-tests were still running, and they failed. Its last commit (273b7af) replaced the labelled switches with ToogleCheckbox, whose checkbox is hidden and has no label, so the test's label lookup found nothing. main only runs server tests on push, so the failure will show up on the next onCourse PR.

 <CollectionFormField>
-  <Switch label="Mandatory">            getAllByLabelText("Mandatory")
-  <Switch label="Visible to tutors">    getAllByLabelText("Visible to tutors")
+  <ToogleCheckbox>                       getAllByText("Mandatory")
+    <input type=checkbox hidden />         → closest ButtonGroup → its checkbox
+    [Optional] [Mandatory]
+  <ToogleCheckbox>                       getAllByText("Tutor visible")
+    [Tutor hidden] [Tutor visible]

Only the test changes. It still asserts one toggle per field and that the number checked matches the mock data.

Evidence

  • Before: DataCollectionForm.Components.test.tsx fails on main (CI run on 9e4827b486, reproduced locally):
    TestingLibraryElementError: Unable to find a label with the text of: Mandatory
    After: ✓ DataCollectionForm components should render with given values (run locally, this test file only)
  • Does it catch real problems: inverting the checkbox state in ToogleCheckbox makes the test fail (Expected length: 2, Received length: 1).

Merge Danger

Door: two-way

Blast Radius: none. Test-only change, no production code touched.

🤖 Generated with Claude Code

…witches

The tutor visibility styling commit replaced the labelled Mandatory and
Visible to tutors switches with ToogleCheckbox, whose checkbox is hidden
and unlabelled. Find each toggle by its checked-side button text and read
the state from the checkbox in the same button group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Unit Test Results

258 tests   258 ✔️  8m 41s ⏱️
239 suites      0 💤
    1 files        0 ❌

Results for commit 9b5780d.

@yuryyas
yuryyas merged commit 4668e19 into main Nov 16, 2026
5 checks passed
@yuryyas
yuryyas deleted the CS-553_fix_DataCollectionForm_component_test branch November 16, 2026 12:02
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.

1 participant