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

DPL-1093 - As developers we want to find out how to modify the e2e fixtures so we can re-use the factory wrapper that we are creating so we do not have to duplicate requests #1756

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ import OntRuns from './ontRuns.json'
import tractionOntLibraries from './tractionOntLibraries'
import TractionOntPool from './tractionOntPool.json'
import TractionOntPools from './tractionOntPools.json'
import TractionPacbioSmrtLinkVersions from './tractionPacbioSmrtLinkVersions'
import PacbioRunWithWellDefaults from './pacbioRunWithWellDefaults'
import StorePools from './StorePools.json'
import Printers from './printers.json'

export default {
CreateChip,
Expand Down Expand Up @@ -148,8 +146,6 @@ export default {
OntRuns,
OntTubeRequest,
OntTubesRequest,
TractionPacbioSmrtLinkVersions,
PacbioRunWithWellDefaults,
StorePools,
Printers,
}
101 changes: 0 additions & 101 deletions tests/data/printers.json

This file was deleted.

87 changes: 0 additions & 87 deletions tests/data/tractionPacbioSmrtLinkVersions.json

This file was deleted.

84 changes: 0 additions & 84 deletions tests/e2e/fixtures/tractionPacbioSmrtLinkVersions.json

This file was deleted.

8 changes: 6 additions & 2 deletions tests/e2e/specs/pacbio/pacbio_run_create.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import PacbioSmrtLinkVersionFactory from '../../../factories/PacbioSmrtLinkVersionFactory'

describe('Pacbio Run Create view', () => {
beforeEach(() => {
cy.intercept('/v1/pacbio/runs?page[size]=25&page[number]=1&include=plates', {
fixture: 'tractionPacbioRuns.json',
})
cy.intercept('/v1/pacbio/smrt_link_versions', {
fixture: 'tractionPacbioSmrtLinkVersions.json',

cy.intercept('GET', '/v1/pacbio/smrt_link_versions', {
statusCode: 200,
body: PacbioSmrtLinkVersionFactory().content,
})

// Find the pool being searched for by barcode
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/specs/pacbio/pacbio_run_edit.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import PacbioSmrtLinkVersionFactory from '../../../factories/PacbioSmrtLinkVersionFactory'

describe('Pacbio Run Edit view', () => {
beforeEach(() => {
cy.intercept('/v1/pacbio/runs?page[size]=25&page[number]=1&include=plates', {
fixture: 'tractionPacbioRuns.json',
})
cy.intercept('/v1/pacbio/smrt_link_versions', {
fixture: 'tractionPacbioSmrtLinkVersions.json',
cy.intercept('GET', '/v1/pacbio/smrt_link_versions', {
statusCode: 200,
body: PacbioSmrtLinkVersionFactory().content,
})
cy.intercept('flipper/api/actors/User', {
flipper_id: 'User',
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/specs/pacbio/pacbio_runs_view.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import PacbioSmrtLinkVersionFactory from '../../../factories/PacbioSmrtLinkVersionFactory'

describe('Pacbio Runs view', () => {
it('Visits the pacbio runs url', () => {
cy.intercept('/v1/pacbio/runs?page[size]=25&page[number]=1&include=plates', {
fixture: 'tractionPacbioRuns.json',
})
cy.intercept('/v1/pacbio/smrt_link_versions', {
fixture: 'tractionPacbioSmrtLinkVersions.json',
cy.intercept('GET', '/v1/pacbio/smrt_link_versions', {
statusCode: 200,
body: PacbioSmrtLinkVersionFactory().content,
})
cy.visit('#/pacbio/runs')
// Check filters are visible
Expand Down
27 changes: 27 additions & 0 deletions tests/factories/BaseFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
*
* @param {*} data
* @returns {Object} {content: {...data}, responses: {axios: {...}, fetch: {...} }
* A base factory that returns an object with a content key that contains the data passed in and a responses key that contains an axios and fetch key that contains the data passed in.
*/

const BaseFactory = (data) => {
return {
content: { ...data },
responses: {
axios: {
status: 200,
statusText: 'OK',
data: { ...data },
},
fetch: {
status: 200,
statusText: 'OK',
ok: true,
json: () => Promise.resolve({ ...data }),
},
},
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice abstraction 👍


export default BaseFactory
Loading