Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectable Treatments and Stages/Elements #119

Merged
merged 18 commits into from
Feb 7, 2025
Merged

Selectable Treatments and Stages/Elements #119

merged 18 commits into from
Feb 7, 2025

Conversation

dankim444
Copy link
Contributor

@dankim444 dankim444 commented Dec 31, 2024

This PR includes several changes to improve the handling of treatments and stages in Timeline, as well as new Cypress tests to reflect these changes. The most important additions are new state variables, updates to the Cypress tests, and the introduction of a new Dropdown component for selecting different sections of a treatment object (for now, just treatments and stages).

Closes #97, #98, #102, #106, #107.

Support for dynamic selection of different treatments:

  • Added selectedTreatmentIndex and setSelectedTreatmentIndex to the app's global context to handle selection of treatments dynamically.
  • Updated logic throughout codebase to use selectedTreatmentIndex instead of hardcoded indices.

Cypress test updates:

  • Added the filterTreatment.cy.ts file to include tests for
    • dynamically populating stage and treatment options
    • testing various cases of using the dropdown component
    • ensuring consistent conditional rendering in Timeline and consistent global and localStorage variables
    • verifying the persistence of selected stages and treatments after page reloads.
    • testing edge cases, including when either the treatments array or stages array is empty.
  • Refactored the reorder.cy.ts file to use aliases for drag and drop elements and stages instead of chain of commands to (hopefully) make the tests more robust and resist failures.

New Dropdown Component:

  • Introduced a new Dropdown component in Dropdown.tsx to standardize the dropdown UI elements used for selecting treatments and stages (and in the future, introSequences and possibly templates).

Refactored Timeline:

  • Mostly reworked some logic and refactored code for better maintainability:
    • Better state management by adding default values and parsing for context/localStorage values to prevent errors during initialization
    • Synchronized index values in localStorage with values in context for consistency with app and cypress tests that use those values for validation checks.

Submodule update:

  • Updated the submodule commit reference for deliberation-empirica.

Notes

I added some logic for handling introSequences in Timeline that isn't tested. This is mostly there for future work in a separate branch or issue. This PR only focuses on treatments and stages/elements.

@dankim444 dankim444 merged commit 34e986f into main Feb 7, 2025
2 checks passed
@dankim444 dankim444 deleted the dan/selector branch February 7, 2025 16:09
Copy link

cypress bot commented Feb 7, 2025

deliberation-researcher-portal    Run #181

Run Properties:  status check passed Passed #181  •  git commit 34e986f9a6: Merge pull request #119 from Watts-Lab/dan/selector
Project deliberation-researcher-portal
Branch Review evan-sync
Run status status check passed Passed #181
Run duration 04m 52s
Commit git commit 34e986f9a6: Merge pull request #119 from Watts-Lab/dan/selector
Committer Dan Kim
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 22
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment