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

X1062 probe hybridisation qc #377

Merged
merged 13 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
186 changes: 186 additions & 0 deletions cypress/e2e/pages/ProbeHybridisationQC.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import { selectOption, selectSGPNumber } from '../shared/customReactSelect.cy';
import {
FindLatestOperationQuery,
FindLatestOperationQueryVariables,
RecordCompletionMutation,
RecordCompletionMutationVariables
} from '../../../src/types/sdk';

describe('Probe Hybridisation QC', () => {
before(() => {
cy.visit('/lab/probe_hybridisation_qc');
});
describe('On load', () => {
it('displays the correct title', () => {
cy.get('h1').should('have.text', 'Probe Hybridisation QC');
});
it('displays the SGP number select box', () => {
cy.findByText('SGP Number').should('be.visible');
});
it('displays the labware scanner', () => {
cy.findByTestId('input').should('be.visible');
});
it('save button should be hidden', () => {
cy.findByText('Save').should('not.exist');
});
});
describe('When a labware is scanned', () => {
describe('labware has no Probe Hybridisation Xenium operation recorded', () => {
before(() => {
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.query<FindLatestOperationQuery, FindLatestOperationQueryVariables>(
'FindLatestOperation',
(req, res, ctx) => {
return res.once(ctx.data({ findLatestOp: null }));
}
)
);
});
cy.get('#labwareScanInput').type('STAN-3111{enter}');
});
it('shows an error message', () => {
cy.findByText(
'No Probe Hybridisation Xenium operation has been recorded on the following labware: STAN-3111'
).should('be.visible');
});
it('should not render the labware image', () => {
cy.findByTestId('labware').should('not.exist');
});
it('should not show the save button', () => {
cy.findByText('Save').should('not.exist');
});
});
describe('labware has a Probe Hybridisation Xenium operation recorded', () => {
before(() => {
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.query<FindLatestOperationQuery, FindLatestOperationQueryVariables>(
'FindLatestOperation',
(req, res, ctx) => {
return res.once(ctx.data({ findLatestOp: { id: 1 } }));
}
)
);
});
cy.get('#labwareScanInput').type('STAN-3112{enter}');
});
it('shows the labware image', () => {
cy.findByTestId('labware').should('be.visible');
});
it('shows the completion Date time select box', () => {
cy.findByLabelText('Completion Time').should('be.visible');
});
it('should init completed time to the current time', () => {
cy.findByLabelText('Completion Time').should('contain.value', new Date().toISOString().split('T')[0]);
});
it('shows the global comments select box', () => {
cy.findByTestId('globalComment').should('be.visible');
});
it('shows the save button', () => {
cy.findByText('Save').should('be.visible');
});
describe('When a selecting a comment from the global comment select box', () => {
before(() => {
selectOption('globalComment', 'Issue with thermal cycler');
});
it('populates table rows comment column automatically with the selected value(s)', () => {
cy.get('tbody tr').eq(0).find('td').eq(6).should('have.text', 'Issue with thermal cycler');
});
});
});
});
describe('Validation', () => {
describe('When the SCP number is not selected', () => {
before(() => {
cy.findByText('Save').click();
});
it('should display an error message requires SGP number', () => {
cy.findByText('SGP Number is required').should('be.visible');
});
});
describe('When completion time is selected in the future', () => {
const currentDate = new Date().toLocaleString('en-GB', { hour12: false }).split(' ');

Check warning on line 103 in cypress/e2e/pages/ProbeHybridisationQC.cy.ts

View workflow job for this annotation

GitHub Actions / Lint with ESLint

'currentDate' is assigned a value but never used
before(() => {
cy.findByLabelText('Completion Time').clear().type('2075-01-01T10:00');
cy.findByText('Save').click();
});
it('should display an error message', () => {
cy.findByText('Please select a time on or before current time').should('be.visible');
});
});
});

describe('Submission', () => {
context('when repeated comment specified for the same section', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The context name doesn't match with what it does

before(() => {
cy.visit('/lab/probe_hybridisation_qc');
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.query<FindLatestOperationQuery, FindLatestOperationQueryVariables>(
'FindLatestOperation',
(req, res, ctx) => {
return res.once(ctx.data({ findLatestOp: { id: 1 } }));
}
)
);
});

cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<RecordCompletionMutation, RecordCompletionMutationVariables>(
'RecordCompletion',
(req, res, ctx) => {
return res.once(
ctx.errors([
{
message: 'The request could not be validated.',
extensions: {
problems: ['Repeated comment specified in: [STAN-0EB01]']
}
}
])
);
}
)
);
});
selectSGPNumber('SGP1008');
cy.get('#labwareScanInput').type('STAN-0EB01{enter}');
cy.findByText('Save').click();
});
it('shows an error message', () => {
cy.findByText('Repeated comment specified in: [STAN-0EB01]').should('be.visible');
});
});
context('When there is no server error', () => {
before(() => {
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<RecordCompletionMutation, RecordCompletionMutationVariables>(
'RecordCompletion',
(req, res, ctx) => {
return res.once(
ctx.data({
recordCompletion: {
operations: [
{
id: 10426
}
]
}
})
);
}
)
);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a global mock handler for this as we do with all other operations in stan-client

cy.findByText('Save').click();
});

it('shows a success message', () => {
cy.findByText('Probe Hybridisation QC recorded for all labware(s)').should('be.visible');
});
});
});
});
Loading
Loading