Split reducers into their own methods and add unit-tests

Created on 28 May 2024, about 1 month ago
Updated 12 June 2024, 16 days ago

Problem/Motivation

We're using redux to manage state
We have reducers inlined into our stores - https://git.drupalcode.org/project/experience_builder/-/blob/0.x/ui/src/...
We should consider splitting these into their own files to make it easier to manage
We have vitest baked in but with no tests - we should add tests for them

Steps to reproduce

Proposed resolution

Split reducers into their own files
Add unit tests
Wire up gitlabci for vitest

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Closed: won't fix

Component

Page builder

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @larowlan
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
  • πŸ‡ΊπŸ‡ΈUnited States hooroomoo

    From https://redux.js.org/style-guide/#structure-files-as-feature-folders-wit...

    Redux itself does not care about how your application's folders and files are structured. However, co-locating logic for a given feature in one place typically makes it easier to maintain that code.

    Because of this, we recommend that most applications should structure files using a "feature folder" approach (all files for a feature in the same folder). Within a given feature folder, the Redux logic for that feature should be written as a single "slice" file, preferably using the Redux Toolkit createSlice API. (This is also known as the "ducks" pattern). While older Redux codebases often used a "folder-by-type" approach with separate folders for "actions" and "reducers", keeping related logic together makes it easier to find and update that code.

    This was under "Strongly recommended" so maybe we should keep the feature folder approach.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Sorry for the confusion, I'm not proposing moving away from that, rather just putting the reducers out of the create slice method to keep that file manageable

    Example https://git.drupalcode.org/project/decoupled_lb/-/blob/1.x/packages/deco...

  • Assigned to hooroomoo
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡ΊπŸ‡ΈUnited States hooroomoo

    I had added my edited comment before I read #4! Speedy.

    Thinking about this again, I don't think it's necessary to split up the reducers at this stage. The two slice files we have aren't that large right now. In this early stage of development it'll be smoother to make changes when we can see all the reducers all at once and see what each one does in relation to each other without having to navigate to a different file for each one.

  • Assigned to larowlan
  • Status changed to Postponed: needs info 17 days ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    @larowlan Thoughts on #6?

  • Status changed to Closed: won't fix 16 days ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Ok, let's tackle it when it becomes an issue

Production build 0.69.0 2024