From 1b0e48ab21dae43a64c8cf4a2158801ea2faaf51 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:12:58 +0100 Subject: [PATCH 1/4] Created factories for ONT. Removed contracts. --- tests/factories/OntPoolFactory.js | 1788 +++++++++++++++++ tests/factories/OntRequestFactory.js | 88 + tests/factories/OntTagSetFactory.js | 5 - .../store/traction/ont/pools/actions.spec.js | 34 +- .../store/traction/ont/pools/contracts.js | 70 - .../store/traction/ont/pools/getters.spec.js | 8 +- .../traction/ont/pools/mutations.spec.js | 7 +- 7 files changed, 1898 insertions(+), 102 deletions(-) create mode 100644 tests/factories/OntPoolFactory.js create mode 100644 tests/factories/OntRequestFactory.js delete mode 100644 tests/unit/store/traction/ont/pools/contracts.js diff --git a/tests/factories/OntPoolFactory.js b/tests/factories/OntPoolFactory.js new file mode 100644 index 000000000..77303ded7 --- /dev/null +++ b/tests/factories/OntPoolFactory.js @@ -0,0 +1,1788 @@ +import BaseFactory from './BaseFactory.js' +import { groupIncludedByResource } from './../../src/api/JsonApi' + +const createIncludedData = (included) => { + const { tubes, libraries, tags, requests } = groupIncludedByResource(included) + return { + tubes, + libraries, + tags, + requests, + } +} + +const OntTagSetFactory = () => { + const data = { + data: [ + { + id: '7', + type: 'pools', + links: { + self: 'http://localhost:3100/v1/ont/pools/7', + }, + attributes: { + volume: 2.0, + kit_barcode: 'barcode-1', + concentration: 4.0, + insert_size: 1632, + created_at: '2022/12/12 14:28', + updated_at: '2022/12/12 14:28', + source_identifier: 'GEN-1670855325-1:C2, F2', + final_library_amount: 7.4, + }, + relationships: { + tube: { + links: { + self: 'http://localhost:3100/v1/ont/pools/7/relationships/tube', + related: 'http://localhost:3100/v1/ont/pools/7/tube', + }, + data: { + type: 'tubes', + id: '9', + }, + }, + libraries: { + links: { + self: 'http://localhost:3100/v1/ont/pools/7/relationships/libraries', + related: 'http://localhost:3100/v1/ont/pools/7/libraries', + }, + data: [ + { + type: 'libraries', + id: '13', + }, + { + type: 'libraries', + id: '14', + }, + { + type: 'libraries', + id: '15', + }, + { + type: 'libraries', + id: '16', + }, + { + type: 'libraries', + id: '17', + }, + ], + }, + }, + }, + { + id: '8', + type: 'pools', + links: { + self: 'http://localhost:3100/v1/ont/pools/8', + }, + attributes: { + volume: 1.0, + kit_barcode: 'barcode-2', + concentration: 3.0, + insert_size: 8271, + created_at: '2022/12/12 14:28', + updated_at: '2022/12/12 14:28', + source_identifier: 'GEN-1670855325-1:F1, H1, B2-C2, E2-F2', + final_library_amount: 0.5, + }, + relationships: { + tube: { + links: { + self: 'http://localhost:3100/v1/ont/pools/8/relationships/tube', + related: 'http://localhost:3100/v1/ont/pools/8/tube', + }, + data: { + type: 'tubes', + id: '10', + }, + }, + libraries: { + links: { + self: 'http://localhost:3100/v1/ont/pools/8/relationships/libraries', + related: 'http://localhost:3100/v1/ont/pools/8/libraries', + }, + data: [ + { + type: 'libraries', + id: '18', + }, + { + type: 'libraries', + id: '19', + }, + { + type: 'libraries', + id: '20', + }, + { + type: 'libraries', + id: '21', + }, + { + type: 'libraries', + id: '22', + }, + { + type: 'libraries', + id: '23', + }, + { + type: 'libraries', + id: '24', + }, + ], + }, + }, + }, + { + id: '9', + type: 'pools', + links: { + self: 'http://localhost:3100/v1/ont/pools/9', + }, + attributes: { + volume: 4.0, + kit_barcode: 'barcode-3', + concentration: 8.0, + insert_size: 3425, + created_at: '2022/12/12 14:28', + updated_at: '2022/12/12 14:28', + source_identifier: 'GEN-1670855325-1:F1-G1, A2, C2-E2, G2', + final_library_amount: 14.2, + }, + relationships: { + tube: { + links: { + self: 'http://localhost:3100/v1/ont/pools/9/relationships/tube', + related: 'http://localhost:3100/v1/ont/pools/9/tube', + }, + data: { + type: 'tubes', + id: '11', + }, + }, + libraries: { + links: { + self: 'http://localhost:3100/v1/ont/pools/9/relationships/libraries', + related: 'http://localhost:3100/v1/ont/pools/9/libraries', + }, + data: [ + { + type: 'libraries', + id: '25', + }, + { + type: 'libraries', + id: '26', + }, + { + type: 'libraries', + id: '27', + }, + { + type: 'libraries', + id: '28', + }, + { + type: 'libraries', + id: '29', + }, + { + type: 'libraries', + id: '30', + }, + { + type: 'libraries', + id: '31', + }, + ], + }, + }, + }, + ], + included: [ + { + id: '9', + type: 'tubes', + links: { + self: 'http://localhost:3100/v1/ont/tubes/9', + }, + attributes: { + barcode: 'TRAC-2-9', + }, + relationships: { + pools: { + links: { + self: 'http://localhost:3100/v1/ont/tubes/9/relationships/pools', + related: 'http://localhost:3100/v1/ont/tubes/9/pools', + }, + data: [ + { + type: 'pools', + id: '7', + }, + ], + }, + requests: { + links: { + self: 'http://localhost:3100/v1/ont/tubes/9/relationships/requests', + related: 'http://localhost:3100/v1/ont/tubes/9/requests', + }, + }, + }, + }, + { + id: '10', + type: 'tubes', + links: { + self: 'http://localhost:3100/v1/ont/tubes/10', + }, + attributes: { + barcode: 'TRAC-2-10', + }, + relationships: { + pools: { + links: { + self: 'http://localhost:3100/v1/ont/tubes/10/relationships/pools', + related: 'http://localhost:3100/v1/ont/tubes/10/pools', + }, + data: [ + { + type: 'pools', + id: '8', + }, + ], + }, + requests: { + links: { + self: 'http://localhost:3100/v1/ont/tubes/10/relationships/requests', + related: 'http://localhost:3100/v1/ont/tubes/10/requests', + }, + }, + }, + }, + { + id: '11', + type: 'tubes', + links: { + self: 'http://localhost:3100/v1/ont/tubes/11', + }, + attributes: { + barcode: 'TRAC-2-11', + }, + relationships: { + pools: { + links: { + self: 'http://localhost:3100/v1/ont/tubes/11/relationships/pools', + related: 'http://localhost:3100/v1/ont/tubes/11/pools', + }, + data: [ + { + type: 'pools', + id: '9', + }, + ], + }, + requests: { + links: { + self: 'http://localhost:3100/v1/ont/tubes/11/relationships/requests', + related: 'http://localhost:3100/v1/ont/tubes/11/requests', + }, + }, + }, + }, + { + id: '13', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/13', + }, + attributes: { + volume: 1.0, + kit_barcode: 'barcode-1', + concentration: 2.0, + insert_size: 1818, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/13/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/13/request', + }, + data: { + type: 'requests', + id: '11', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/13/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/13/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/13/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/13/tag', + }, + data: { + type: 'tags', + id: '385', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/13/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/13/pool', + }, + data: { + type: 'pools', + id: '7', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/13/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/13/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/13/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/13/source_plate', + }, + }, + }, + }, + { + id: '14', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/14', + }, + attributes: { + volume: 10.0, + kit_barcode: 'barcode-1', + concentration: 1.0, + insert_size: 7946, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/14/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/14/request', + }, + data: { + type: 'requests', + id: '11', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/14/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/14/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/14/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/14/tag', + }, + data: { + type: 'tags', + id: '386', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/14/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/14/pool', + }, + data: { + type: 'pools', + id: '7', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/14/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/14/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/14/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/14/source_plate', + }, + }, + }, + }, + { + id: '15', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/15', + }, + attributes: { + volume: 5.0, + kit_barcode: 'barcode-1', + concentration: 7.0, + insert_size: 2636, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/15/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/15/request', + }, + data: { + type: 'requests', + id: '14', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/15/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/15/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/15/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/15/tag', + }, + data: { + type: 'tags', + id: '387', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/15/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/15/pool', + }, + data: { + type: 'pools', + id: '7', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/15/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/15/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/15/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/15/source_plate', + }, + }, + }, + }, + { + id: '16', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/16', + }, + attributes: { + volume: 5.0, + kit_barcode: 'barcode-1', + concentration: 5.0, + insert_size: 2291, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/16/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/16/request', + }, + data: { + type: 'requests', + id: '11', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/16/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/16/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/16/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/16/tag', + }, + data: { + type: 'tags', + id: '388', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/16/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/16/pool', + }, + data: { + type: 'pools', + id: '7', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/16/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/16/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/16/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/16/source_plate', + }, + }, + }, + }, + { + id: '17', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/17', + }, + attributes: { + volume: 3.0, + kit_barcode: 'barcode-1', + concentration: 3.0, + insert_size: 4160, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/17/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/17/request', + }, + data: { + type: 'requests', + id: '14', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/17/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/17/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/17/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/17/tag', + }, + data: { + type: 'tags', + id: '389', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/17/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/17/pool', + }, + data: { + type: 'pools', + id: '7', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/17/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/17/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/17/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/17/source_plate', + }, + }, + }, + }, + { + id: '18', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/18', + }, + attributes: { + volume: 10.0, + kit_barcode: 'barcode-2', + concentration: 1.0, + insert_size: 4182, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/18/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/18/request', + }, + data: { + type: 'requests', + id: '10', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/18/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/18/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/18/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/18/tag', + }, + data: { + type: 'tags', + id: '385', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/18/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/18/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/18/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/18/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/18/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/18/source_plate', + }, + }, + }, + }, + { + id: '19', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/19', + }, + attributes: { + volume: 6.0, + kit_barcode: 'barcode-2', + concentration: 9.0, + insert_size: 9297, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/19/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/19/request', + }, + data: { + type: 'requests', + id: '6', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/19/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/19/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/19/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/19/tag', + }, + data: { + type: 'tags', + id: '386', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/19/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/19/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/19/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/19/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/19/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/19/source_plate', + }, + }, + }, + }, + { + id: '20', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/20', + }, + attributes: { + volume: 10.0, + kit_barcode: 'barcode-2', + concentration: 8.0, + insert_size: 2758, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/20/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/20/request', + }, + data: { + type: 'requests', + id: '14', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/20/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/20/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/20/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/20/tag', + }, + data: { + type: 'tags', + id: '387', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/20/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/20/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/20/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/20/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/20/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/20/source_plate', + }, + }, + }, + }, + { + id: '21', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/21', + }, + attributes: { + volume: 9.0, + kit_barcode: 'barcode-2', + concentration: 1.0, + insert_size: 6906, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/21/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/21/request', + }, + data: { + type: 'requests', + id: '13', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/21/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/21/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/21/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/21/tag', + }, + data: { + type: 'tags', + id: '388', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/21/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/21/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/21/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/21/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/21/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/21/source_plate', + }, + }, + }, + }, + { + id: '22', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/22', + }, + attributes: { + volume: 5.0, + kit_barcode: 'barcode-2', + concentration: 10.0, + insert_size: 4418, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/22/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/22/request', + }, + data: { + type: 'requests', + id: '13', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/22/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/22/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/22/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/22/tag', + }, + data: { + type: 'tags', + id: '389', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/22/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/22/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/22/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/22/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/22/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/22/source_plate', + }, + }, + }, + }, + { + id: '23', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/23', + }, + attributes: { + volume: 2.0, + kit_barcode: 'barcode-2', + concentration: 9.0, + insert_size: 5985, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/23/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/23/request', + }, + data: { + type: 'requests', + id: '11', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/23/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/23/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/23/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/23/tag', + }, + data: { + type: 'tags', + id: '390', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/23/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/23/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/23/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/23/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/23/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/23/source_plate', + }, + }, + }, + }, + { + id: '24', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/24', + }, + attributes: { + volume: 8.0, + kit_barcode: 'barcode-2', + concentration: 10.0, + insert_size: 8796, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/24/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/24/request', + }, + data: { + type: 'requests', + id: '8', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/24/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/24/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/24/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/24/tag', + }, + data: { + type: 'tags', + id: '391', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/24/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/24/pool', + }, + data: { + type: 'pools', + id: '8', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/24/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/24/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/24/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/24/source_plate', + }, + }, + }, + }, + { + id: '25', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/25', + }, + attributes: { + volume: 7.0, + kit_barcode: 'barcode-3', + concentration: 10.0, + insert_size: 4334, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/25/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/25/request', + }, + data: { + type: 'requests', + id: '12', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/25/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/25/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/25/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/25/tag', + }, + data: { + type: 'tags', + id: '385', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/25/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/25/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/25/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/25/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/25/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/25/source_plate', + }, + }, + }, + }, + { + id: '26', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/26', + }, + attributes: { + volume: 5.0, + kit_barcode: 'barcode-3', + concentration: 6.0, + insert_size: 9461, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/26/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/26/request', + }, + data: { + type: 'requests', + id: '11', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/26/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/26/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/26/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/26/tag', + }, + data: { + type: 'tags', + id: '386', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/26/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/26/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/26/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/26/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/26/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/26/source_plate', + }, + }, + }, + }, + { + id: '27', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/27', + }, + attributes: { + volume: 6.0, + kit_barcode: 'barcode-3', + concentration: 4.0, + insert_size: 4129, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/27/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/27/request', + }, + data: { + type: 'requests', + id: '9', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/27/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/27/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/27/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/27/tag', + }, + data: { + type: 'tags', + id: '387', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/27/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/27/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/27/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/27/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/27/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/27/source_plate', + }, + }, + }, + }, + { + id: '28', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/28', + }, + attributes: { + volume: 10.0, + kit_barcode: 'barcode-3', + concentration: 6.0, + insert_size: 1732, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/28/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/28/request', + }, + data: { + type: 'requests', + id: '7', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/28/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/28/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/28/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/28/tag', + }, + data: { + type: 'tags', + id: '388', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/28/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/28/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/28/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/28/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/28/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/28/source_plate', + }, + }, + }, + }, + { + id: '29', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/29', + }, + attributes: { + volume: 9.0, + kit_barcode: 'barcode-3', + concentration: 6.0, + insert_size: 7437, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/29/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/29/request', + }, + data: { + type: 'requests', + id: '13', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/29/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/29/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/29/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/29/tag', + }, + data: { + type: 'tags', + id: '389', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/29/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/29/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/29/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/29/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/29/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/29/source_plate', + }, + }, + }, + }, + { + id: '30', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/30', + }, + attributes: { + volume: 5.0, + kit_barcode: 'barcode-3', + concentration: 9.0, + insert_size: 7056, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/30/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/30/request', + }, + data: { + type: 'requests', + id: '6', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/30/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/30/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/30/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/30/tag', + }, + data: { + type: 'tags', + id: '390', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/30/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/30/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/30/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/30/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/30/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/30/source_plate', + }, + }, + }, + }, + { + id: '31', + type: 'libraries', + links: { + self: 'http://localhost:3100/v1/ont/libraries/31', + }, + attributes: { + volume: 8.0, + kit_barcode: 'barcode-3', + concentration: 4.0, + insert_size: 6947, + created_at: '2022/12/12 14:28', + deactivated_at: null, + state: 'pending', + }, + relationships: { + request: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/31/relationships/request', + related: 'http://localhost:3100/v1/ont/libraries/31/request', + }, + data: { + type: 'requests', + id: '15', + }, + }, + tube: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/31/relationships/tube', + related: 'http://localhost:3100/v1/ont/libraries/31/tube', + }, + }, + tag: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/31/relationships/tag', + related: 'http://localhost:3100/v1/ont/libraries/31/tag', + }, + data: { + type: 'tags', + id: '391', + }, + }, + pool: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/31/relationships/pool', + related: 'http://localhost:3100/v1/ont/libraries/31/pool', + }, + data: { + type: 'pools', + id: '9', + }, + }, + source_well: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/31/relationships/source_well', + related: 'http://localhost:3100/v1/ont/libraries/31/source_well', + }, + }, + source_plate: { + links: { + self: 'http://localhost:3100/v1/ont/libraries/31/relationships/source_plate', + related: 'http://localhost:3100/v1/ont/libraries/31/source_plate', + }, + }, + }, + }, + { + id: '385', + type: 'tags', + attributes: { + oligo: 'CACAAAGACACCGACAACTTTCTT', + group_id: 'NB01', + }, + }, + { + id: '386', + type: 'tags', + attributes: { + oligo: 'ACAGACGACTACAAACGGAATCGA', + group_id: 'NB02', + }, + }, + { + id: '387', + type: 'tags', + attributes: { + oligo: 'CCTGGTAACTGGGACACAAGACTC', + group_id: 'NB03', + }, + }, + { + id: '388', + type: 'tags', + attributes: { + oligo: 'TAGGGAAACACGATAGAATCCGAA', + group_id: 'NB04', + }, + }, + { + id: '389', + type: 'tags', + attributes: { + oligo: 'AAGGTTACACAAACCCTGGACAAG', + group_id: 'NB05', + }, + }, + { + id: '390', + type: 'tags', + attributes: { + oligo: 'GACTACTTTCTGCCTTTGCGAGAA', + group_id: 'NB06', + }, + }, + { + id: '391', + type: 'tags', + attributes: { + oligo: 'AAGGATTCATTCCCACGGTAACAC', + group_id: 'NB07', + }, + }, + { + id: '15', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/15', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10014', + external_study_id: '4c22e7c5-070e-4d95-9f50-b1dd8f6690d8', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-15', + source_identifier: 'GEN-1670855325-1:G2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '14', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/14', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10013', + external_study_id: 'c1113be1-7a8f-4936-84be-bdc055aaeede', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-14', + source_identifier: 'GEN-1670855325-1:F2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '13', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/13', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10012', + external_study_id: '1f6768ee-a495-40b6-bc90-1986ba09216c', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-13', + source_identifier: 'GEN-1670855325-1:E2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '12', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/12', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10011', + external_study_id: '72ca1724-9295-4343-a489-6192d3cbfe92', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-12', + source_identifier: 'GEN-1670855325-1:D2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '11', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/11', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10010', + external_study_id: '57f82ebf-410b-496d-912d-47558d0dc611', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-11', + source_identifier: 'GEN-1670855325-1:C2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '10', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/10', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10009', + external_study_id: 'b0332dd4-8313-472a-b0bf-b5b91fa3dc1f', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-10', + source_identifier: 'GEN-1670855325-1:B2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '9', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/9', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10008', + external_study_id: 'eb895777-6848-49a6-bafa-14d9e38feb67', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-9', + source_identifier: 'GEN-1670855325-1:A2', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '8', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/8', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10007', + external_study_id: 'f6dd0ac7-980f-4a60-88e4-907628a891f0', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-8', + source_identifier: 'GEN-1670855325-1:H1', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '7', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/7', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10006', + external_study_id: 'bfa7f43f-7aff-4932-9a56-240e342079c8', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-7', + source_identifier: 'GEN-1670855325-1:G1', + created_at: '2022/12/12 14:28', + }, + }, + { + id: '6', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/6', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10005', + external_study_id: '41d80ab3-11f5-4757-bb4f-7ec36c317f8a', + number_of_flowcells: 1, + sample_name: 'GENSAMPLE-1670855325-6', + source_identifier: 'GEN-1670855325-1:F1', + created_at: '2022/12/12 14:28', + }, + }, + ], + links: { + first: + 'http://localhost:3100/v1/ont/pools?include=tube%2Clibraries.tag%2Clibraries.request&page%5Bnumber%5D=1&page%5Bsize%5D=3', + prev: 'http://localhost:3100/v1/ont/pools?include=tube%2Clibraries.tag%2Clibraries.request&page%5Bnumber%5D=2&page%5Bsize%5D=3', + last: 'http://localhost:3100/v1/ont/pools?include=tube%2Clibraries.tag%2Clibraries.request&page%5Bnumber%5D=3&page%5Bsize%5D=3', + }, + } + + return { ...BaseFactory(data), includedData: createIncludedData(data.included) } +} + +export default OntTagSetFactory diff --git a/tests/factories/OntRequestFactory.js b/tests/factories/OntRequestFactory.js new file mode 100644 index 000000000..e1cfc12d5 --- /dev/null +++ b/tests/factories/OntRequestFactory.js @@ -0,0 +1,88 @@ +import BaseFactory from './BaseFactory.js' +import { dataToObjectById } from './../../src/api/JsonApi' + +const OntRequestFactory = () => { + const data = { + data: [ + { + id: '102', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/102', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10000', + external_study_id: '50ad20f6-2722-434e-b42b-83cec34147f7', + number_of_flowcells: 1, + created_at: '2022/07/26 15:01', + }, + }, + { + id: '103', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/103', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10001', + external_study_id: '170ef408-bb98-4617-95cd-b65ba6882843', + number_of_flowcells: 1, + created_at: '2022/07/26 15:01', + }, + }, + { + id: '104', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/104', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10002', + external_study_id: '494adee4-cdea-4cf3-927e-ccb3d269cd9a', + number_of_flowcells: 1, + created_at: '2022/07/26 15:01', + }, + }, + { + id: '105', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/105', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10003', + external_study_id: '3a87ab1f-7a4b-4028-a4f7-250418c3c0fc', + number_of_flowcells: 1, + created_at: '2022/07/26 15:01', + }, + }, + { + id: '106', + type: 'requests', + links: { + self: 'http://localhost:3100/v1/ont/requests/106', + }, + attributes: { + library_type: 'ONT_GridIon', + data_type: 'basecalls', + cost_code: 'S10004', + external_study_id: '4dcef3a6-1bf7-40b5-a899-1568dbf58dca', + number_of_flowcells: 1, + created_at: '2022/07/26 15:01', + }, + }, + ], + } + + return { ...BaseFactory(data), storeData: dataToObjectById(data) } +} + +export default OntRequestFactory diff --git a/tests/factories/OntTagSetFactory.js b/tests/factories/OntTagSetFactory.js index 08e74f8d5..d5f4f5b89 100644 --- a/tests/factories/OntTagSetFactory.js +++ b/tests/factories/OntTagSetFactory.js @@ -3920,11 +3920,6 @@ const OntTagSetFactory = () => { }, } - // const storeData = { - // tagSets: dataToObjectById({ data: data.data, includeRelationships: true }), - // tags: dataToObjectById({ data: data.included }), - // } - return { ...BaseFactory(data), storeData: createStoreData({ ...data }) } } diff --git a/tests/unit/store/traction/ont/pools/actions.spec.js b/tests/unit/store/traction/ont/pools/actions.spec.js index abc152d0b..c81d3340f 100644 --- a/tests/unit/store/traction/ont/pools/actions.spec.js +++ b/tests/unit/store/traction/ont/pools/actions.spec.js @@ -1,13 +1,16 @@ import { Data } from '@support/testHelper' import actions from '@/store/traction/ont/pools/actions' import { describe, expect, it } from 'vitest' -import Contracts from './contracts' import defaultState from '@/store/traction/ont/pools/state' import { payload } from '@/store/traction/ont/pools/pool' import { newResponse } from '@/api/v1/ResponseHelper' import OntTagSetFactory from '@tests/factories/OntTagSetFactory.js' +import OntRequestFactory from '@tests/factories/OntRequestFactory.js' +import OntPoolFactory from '@tests/factories/OntPoolFactory.js' const ontTagSetFactory = OntTagSetFactory() +const ontRequestFactory = OntRequestFactory() +const ontPoolFactory = OntPoolFactory() describe('actions.js', () => { const { @@ -32,14 +35,11 @@ describe('actions.js', () => { // mock dependencies const get = vi.fn() const rootState = { api: { v1: { traction: { ont: { requests: { get } } } } } } - get.mockResolvedValue(Data.TractionOntRequests) + get.mockResolvedValue(ontRequestFactory.responses.axios) // apply action const { success } = await actions.fetchOntRequests({ commit, rootState }) // assert result (Might make sense to pull these into separate tests) - expect(commit).toHaveBeenCalledWith( - 'setRequests', - Contracts.requests.populateRequestsParameters, - ) + expect(commit).toHaveBeenCalledWith('setRequests', ontRequestFactory.content.data) expect(success).toEqual(true) }) @@ -69,27 +69,19 @@ describe('actions.js', () => { // mock dependencies const get = vi.fn() const rootState = { api: { v1: { traction: { ont: { pools: { get } } } } } } - get.mockResolvedValue(Data.TractionOntPools) + get.mockResolvedValue(ontPoolFactory.responses.axios) // apply action const { success } = await actions.fetchOntPools({ commit, rootState }) // assert result (Might make sense to pull these into separate tests) - expect(commit).toHaveBeenCalledWith('setPools', Data.TractionOntPools.data.data) - expect(commit).toHaveBeenCalledWith( - 'populateTubes', - Data.TractionOntPools.data.included.slice(0, 3), - ) - expect(commit).toHaveBeenCalledWith( - 'populateTags', - Data.TractionOntPools.data.included.slice(22, 29), - ) + expect(commit).toHaveBeenCalledWith('setPools', ontPoolFactory.content.data) + + expect(commit).toHaveBeenCalledWith('populateTubes', ontPoolFactory.includedData.tubes) + expect(commit).toHaveBeenCalledWith('populateTags', ontPoolFactory.includedData.tags) expect(commit).toHaveBeenCalledWith( 'populateLibraries', - Data.TractionOntPools.data.included.slice(3, 22), - ) - expect(commit).toHaveBeenCalledWith( - 'populateRequests', - Data.TractionOntPools.data.included.slice(29, 39), + ontPoolFactory.includedData.libraries, ) + expect(commit).toHaveBeenCalledWith('populateRequests', ontPoolFactory.includedData.requests) expect(success).toEqual(true) }) diff --git a/tests/unit/store/traction/ont/pools/contracts.js b/tests/unit/store/traction/ont/pools/contracts.js deleted file mode 100644 index 69b3d1a7c..000000000 --- a/tests/unit/store/traction/ont/pools/contracts.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * In order to ensure we set up consistent expectations in our unit tests, we - * are setting up shared 'contracts'. - * There's a bit of a mix of derived values and being explicit here. - * TODO: This should be removed when we move to factories. - */ - -import { Data } from '@support/testHelper' - -const populateRequestsParameters = Data.TractionOntRequests.data.data -const storeData = { - 102: { - id: '102', - type: 'requests', - library_type: 'ONT_GridIon', - data_type: 'basecalls', - cost_code: 'S10000', - external_study_id: '50ad20f6-2722-434e-b42b-83cec34147f7', - number_of_flowcells: 1, - created_at: '2022/07/26 15:01', - }, - 103: { - id: '103', - type: 'requests', - library_type: 'ONT_GridIon', - data_type: 'basecalls', - cost_code: 'S10001', - external_study_id: '170ef408-bb98-4617-95cd-b65ba6882843', - number_of_flowcells: 1, - created_at: '2022/07/26 15:01', - }, - 104: { - id: '104', - type: 'requests', - library_type: 'ONT_GridIon', - data_type: 'basecalls', - cost_code: 'S10002', - external_study_id: '494adee4-cdea-4cf3-927e-ccb3d269cd9a', - number_of_flowcells: 1, - created_at: '2022/07/26 15:01', - }, - 105: { - id: '105', - type: 'requests', - library_type: 'ONT_GridIon', - data_type: 'basecalls', - cost_code: 'S10003', - external_study_id: '3a87ab1f-7a4b-4028-a4f7-250418c3c0fc', - number_of_flowcells: 1, - created_at: '2022/07/26 15:01', - }, - 106: { - id: '106', - type: 'requests', - library_type: 'ONT_GridIon', - data_type: 'basecalls', - cost_code: 'S10004', - external_study_id: '4dcef3a6-1bf7-40b5-a899-1568dbf58dca', - number_of_flowcells: 1, - created_at: '2022/07/26 15:01', - }, -} - -export default { - requests: { - populateRequestsParameters, - storeData, - getterRequestReturn: Object.values(storeData), - }, -} diff --git a/tests/unit/store/traction/ont/pools/getters.spec.js b/tests/unit/store/traction/ont/pools/getters.spec.js index 3612e0a7d..1794ed7a5 100644 --- a/tests/unit/store/traction/ont/pools/getters.spec.js +++ b/tests/unit/store/traction/ont/pools/getters.spec.js @@ -2,14 +2,16 @@ import getters from '@/store/traction/ont/pools/getters' import defaultState from '@/store/traction/ont/pools/state' import merge from 'lodash-es/merge' import { describe, expect, it } from 'vitest' -import Contracts from './contracts' import { Data } from '@support/testHelper' import { dataToObjectById, groupIncludedByResource } from '@/api/JsonApi' +import OntRequestFactory from '@tests/factories/OntRequestFactory.js' + +const ontRequestFactory = OntRequestFactory() describe('getters.js', () => { const state = merge(defaultState(), { resources: { - requests: Contracts.requests.storeData, + requests: ontRequestFactory.storeData, }, }) const { @@ -44,7 +46,7 @@ describe('getters.js', () => { describe('requests', () => { it('returns a list of requests', () => { - expect(getters.requests(state)).toEqual(Contracts.requests.getterRequestReturn) + expect(getters.requests(state)).toEqual(Object.values(ontRequestFactory.storeData)) }) }) diff --git a/tests/unit/store/traction/ont/pools/mutations.spec.js b/tests/unit/store/traction/ont/pools/mutations.spec.js index 05605809d..04cf4e2b8 100644 --- a/tests/unit/store/traction/ont/pools/mutations.spec.js +++ b/tests/unit/store/traction/ont/pools/mutations.spec.js @@ -1,12 +1,13 @@ import mutations from '@/store/traction/ont/pools/mutations' import defaultState from '@/store/traction/ont/pools/state' import { describe, expect, it } from 'vitest' -import Contracts from './contracts' import { Data } from '@support/testHelper' import { dataToObjectById } from '@/api/JsonApi' import OntTagSetFactory from '@tests/factories/OntTagSetFactory.js' +import OntRequestFactory from '@tests/factories/OntRequestFactory.js' const ontTagSetFactory = OntTagSetFactory() +const ontRequestFactory = OntRequestFactory() describe('mutations', () => { const { @@ -34,12 +35,12 @@ describe('mutations', () => { describe('populateRequests', () => { it('updates the state', () => { // mock state - const requests = Contracts.requests.populateRequestsParameters + const requests = ontRequestFactory.content.data const state = defaultState() // apply mutation populateRequests(state, requests) // assert result - expect(state.resources.requests).toEqual(Contracts.requests.storeData) + expect(state.resources.requests).toEqual(ontRequestFactory.storeData) }) }) From e2022e1afa8e50bd19da54864a64eb18e92c306d Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:00:27 +0100 Subject: [PATCH 2/4] refactor: Rename OntTagSetFactory to OntPoolFactory --- tests/factories/OntPoolFactory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/factories/OntPoolFactory.js b/tests/factories/OntPoolFactory.js index 77303ded7..74797b918 100644 --- a/tests/factories/OntPoolFactory.js +++ b/tests/factories/OntPoolFactory.js @@ -11,7 +11,7 @@ const createIncludedData = (included) => { } } -const OntTagSetFactory = () => { +const OntPoolFactory = () => { const data = { data: [ { @@ -1785,4 +1785,4 @@ const OntTagSetFactory = () => { return { ...BaseFactory(data), includedData: createIncludedData(data.included) } } -export default OntTagSetFactory +export default OntPoolFactory From 9e9e709f4ab8e36f43e1f8b75b45760184c2a5d7 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:01:24 +0100 Subject: [PATCH 3/4] refactor: Rename OntTagSetFactory to OntPoolFactory --- src/lib/LabelPrintingHelpers.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/lib/LabelPrintingHelpers.js b/src/lib/LabelPrintingHelpers.js index a15a3f7ca..64e585fce 100644 --- a/src/lib/LabelPrintingHelpers.js +++ b/src/lib/LabelPrintingHelpers.js @@ -3,22 +3,23 @@ * It is now in the state that it can be used ny multiple components / views * I also think we could create a composables ... but that is for another day * A bit more workand this could be a truly reusable library + * @module LabelPrintingHelpers */ -/* - * @param {Array [Object, ...]} WorkflowList +/** + * @param {Array} {[Object, ...]} WorkflowList * @param {String} the attribute to extract from each object - * @returns [Array] e.g. [attribute, attribute ...] + * @returns {Array} e.g. [attribute, attribute ...] * for each object return the named attribute */ const byAttribute = (objects, attribute) => { return objects.map((object) => object[attribute]) } -/* - * @param {Array [Object, ...]} WorkflowList +/** + * @param {Array}: {[Object, ...]} WorkflowList * @returns {Array} A list which can be used as a drop-down in the format - * example: [{ label: 'workflow', options: [{text:'text', value: 'value', ...}, ..., { text: 'No suffix', value: null }]}] + * @example: [{ label: 'workflow', options: [{text:'text', value: 'value', ...}, ..., { text: 'No suffix', value: null }]}] * The last item returned is a no suffix option */ const createWorkflowDropdownOptions = (WorkflowList) => { @@ -31,8 +32,8 @@ const createWorkflowDropdownOptions = (WorkflowList) => { })).concat([{ text: 'No suffix', value: null }]) } -/* - * @param {Array [Object, ...]} WorkflowList +/** + * @param {Array} {[Object, ...]} WorkflowList * @returns {Object} e.g. { suffix: {options}, ...} */ const workflowByOptions = (options) => { @@ -44,8 +45,8 @@ const workflowByOptions = (options) => { }, {}) } -/* - * @param {Array [Object, ...]} WorkflowList +/** + * @param {Array} {[Object, ...]} WorkflowList * @returns {Object} A list with the suffix as the key and the option as the value. * For each item Ignores the workflow and flattens all options into a single object * This allows for searching by suffix @@ -60,7 +61,9 @@ const createWorkflowOptions = (WorkflowList) => { }, {}) } -// @returns {Object} - An empty WorkflowOptions with all attributes set to null +/** + * @returns {Object} - An empty WorkflowOptions with all attributes set to null + */ const NullWorkflowItem = { stage: '', suffix: null, From da4d975858115f3a7ef2d38cfff1de270ec6dc85 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:31:26 +0100 Subject: [PATCH 4/4] chore: Remove npm audit command from lefthook.yml --- lefthook.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index d7a344c27..e4bdf9acc 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,11 +1,5 @@ # Refer for explanation to following link: # https://github.com/Arkweid/lefthook/blob/master/docs/full_guide.md -# -pre-push: - commands: - packages-audit: - tags: security - run: npm audit --audit-level=high pre-commit: parallel: true