Skip to content

Refactor repository-tests to simplify the test case #4249

@agnes512

Description

@agnes512

Suggestion

follow up issue of #4148.

Currently, the acceptance tests in repository-tests are using shared fixtures to run tests on different databases.
A model might have several relations.
But then the test cases have to contain a lots of relevant attribute to make all databases pass.

Examples

For example, a expected test result in belongsTo-inclusion test file:

      const expected = [
        {
          ...thorOrder,
          isShipped: features.emptyValue,
          // eslint-disable-next-line @typescript-eslint/camelcase
          shipment_id: features.emptyValue,
          customer: {
            ...thor,
            parentId: features.emptyValue,
          },
        },
        {
          ...odinOrder,
          isShipped: features.emptyValue,
          // eslint-disable-next-line @typescript-eslint/camelcase
          shipment_id: features.emptyValue,
          customer: {
            ...odin,
            parentId: features.emptyValue,
          },
        },
      ];

parentId and is_shipped are redundant here.

Acceptance criteria

  • Clean up the fixtures. Remove those not being used properties ( such as is_shipped)
  • Should find a way that model classes were created dynamically by a factory function.

Stretch goal

  • Separate the relations in each models so that we only need the necessary properties when we test a certain relation. For example, now Customer hasMany Orders, hasMany Customers, belongsTo a Customer, and hasOne Address. These should be de-centered.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions