Update unit tests to use a mock category_list.json fixure

Created on 9 May 2024, 7 months ago
Updated 2 June 2024, 7 months ago

Problem/Motivation

Currently our tests are dependent upon :nth-child(x) selectors when interacting with categories. This opens us up to future issues as when we eventually update the categories that we use multiple tests will have to be rewritten to use the new list of categories.

We already use a mock list of projects, we should use a mock list of categories as well

Steps to reproduce

Change the facets/category_list.json file (add an item, rename the items, etc...) and unit tests begin failing.

Proposed resolution

Update the unit testing to use a mock list of categories. For ease of use I recommend using the current list of categories so tests will not require any additional rewriting.

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States MrMason

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

Comments & Activities

  • Issue created by @MrMason
  • First commit to issue fork.
  • πŸ‡¦πŸ‡ΊAustralia sime Melbourne

    sime β†’ changed the visibility of the branch 3446161-update-unit-tests to hidden.

  • πŸ‡¦πŸ‡ΊAustralia sime Melbourne

    We already use a mock list of projects, we should use a mock list of categories as well

    I am not confident I know what you want to change. Looking at the existing fixtures there is a) no facets/categories.json b) as many project fixtures as there are categories fixtures . Was mocking the projects supposed to remove some of these project json fixtures?

    fixtures/categories.json
    fixtures/category_list.json
    fixtures/project_data.json
    tests/fixtures/drupalorg_jsonapi/module_categories1.json
    tests/fixtures/drupalorg_jsonapi/module_categories2.json
    tests/fixtures/drupalorg_jsonapi/project_modules1.json
    tests/fixtures/drupalorg_jsonapi/project_modules2.json
    tests/fixtures/projects.json
    tests/fixtures/projects_fixture.json
    
    Change the facets/category_list.json file (add an item, rename the items, etc...) and unit tests begin failing.

    I created the branch 3446161-mock-categories so if you want kick it off by making the above change to get the tests failing, I'll have another look.

  • πŸ‡ΊπŸ‡ΈUnited States chrisfromredfin Portland, Maine

    I question if this is necessary because... are we really not mocking the Categories for tests? Could someone confirm that first?

Production build 0.71.5 2024