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

x1139 update amplification operation #541

Merged
merged 14 commits into from
Jan 29, 2024
154 changes: 121 additions & 33 deletions cypress/e2e/pages/visiumQC.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {
FindMeasurementByBarcodeAndNameQuery,
FindMeasurementByBarcodeAndNameQueryVariables,
RecordOpWithSlotCommentsMutation,
RecordOpWithSlotCommentsMutationVariables,
RecordOpWithSlotMeasurementsMutation,
RecordOpWithSlotMeasurementsMutationVariables,
RecordVisiumQcMutation,
RecordVisiumQcMutationVariables,
SlideCosting
Expand Down Expand Up @@ -56,7 +60,7 @@ describe('Visium QC Page', () => {
cy.findAllByTestId('passIcon').then(($passIcons) => {
$passIcons.each((i, icon) => {
const classList = Array.from(icon.classList);
expect(classList).to.includes('text-green-700');
expect(classList).includes('text-green-700');
});
});
});
Expand Down Expand Up @@ -108,7 +112,7 @@ describe('Visium QC Page', () => {
cy.findAllByTestId('passIcon').then(($passIcons) => {
$passIcons.each((i, icon) => {
const classList = Array.from(icon.classList);
expect(classList).to.includes('text-green-700');
expect(classList).includes('text-green-700');
});
});
});
Expand All @@ -126,7 +130,7 @@ describe('Visium QC Page', () => {
cy.findAllByTestId('failIcon').then(($failIcons) => {
$failIcons.each((indx, failIcon) => {
const classList = Array.from(failIcon.classList);
expect(classList).to.includes('text-red-700');
expect(classList).includes('text-red-700');
});
});
});
Expand Down Expand Up @@ -285,57 +289,70 @@ describe('Visium QC Page', () => {
.then(($slot) => {
$slot.each((i, slotElement) => {
const classList = Array.from(slotElement.classList);
expect(classList).to.includes('bg-sdb-300');
expect(classList).includes('bg-sdb-300');
});
});
});
});

it('display text boxes to enter cq value for all slots with samples', () => {
cy.findByRole('table').within(() => {
cy.findAllByTestId('Cq value-input').should('have.length.above', 0);
cy.findAllByTestId('Cycles-input').should('have.length.above', 0);
});
});
it('displays scan field as disabled', () => {
cy.get('#labwareScanInput').should('be.disabled');
});
});
context('When user enters a value in CQ value text box', () => {
before(() => {
cy.findByTestId('all-Cq value').type('5');
});

it('shows cq value in all text fields in CQ column of table', () => {
cy.findAllByTestId('Cq value-input').should('have.value', 5);
cy.findByTestId('all-Cycles').type('3');
cy.findAllByTestId('Cycles-input').should('have.value', 3);
});
});
context('When user enters a value in Cycles text box', () => {

describe('When the scanned labware slots does not contain Cq values', () => {
before(() => {
cy.findByTestId('all-Cycles').type('3');
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.query<FindMeasurementByBarcodeAndNameQuery, FindMeasurementByBarcodeAndNameQueryVariables>(
'FindMeasurementByBarcodeAndName',
() => {
return HttpResponse.json({
data: {
measurementValueFromLabwareOrParent: []
}
});
}
)
);
});
cy.reload();
selectOption('qcType', 'Amplification');
cy.get('#labwareScanInput').type('STAN-5100{enter}');
});
it('shows cq value in all text fields in CQ column of table', () => {
cy.findAllByTestId('Cycles-input').should('have.value', 3);
it('displays error message', () => {
cy.findByText('No Cq values associated with the labware slots').should('be.visible');
});
it('hides Cycles table and input', () => {
cy.findByRole('table').should('not.exist');
cy.findByTestId('all-Cycles').should('not.exist');
});
it('displays the labware layout', () => {
cy.findByTestId('labware').should('be.visible');
});
});

describe('On Save', () => {
before(() => {
cy.reload();
selectOption('qcType', 'Amplification');
cy.get('#labwareScanInput').type('STAN-5100{enter}');
cy.findByTestId('all-Cycles').type('3');
});
it('Save button should be disabled when there is no SGP number', () => {
selectSGPNumber('');
cy.findByRole('button', { name: /Save/i }).should('be.disabled');
});

context('When there is no server error', () => {
before(() => {
selectSGPNumber('SGP1008');
cy.findByRole('button', { name: /Save/i }).should('not.be.disabled').click();
});

it('shows a success message', () => {
cy.findByText('Amplification complete').should('be.visible');
});
after(() => {
cy.findByRole('button', { name: /Reset/i }).click();
});
it('shows a success message', () => {
selectSGPNumber('SGP1008');
cy.findByTestId('all-Cycles').type('4');
cy.findByRole('button', { name: /Save/i }).should('not.be.disabled').click();
cy.findByText('Amplification complete').should('be.visible');
});
});
});
Expand Down Expand Up @@ -573,6 +590,77 @@ describe('Visium QC Page', () => {
});
});

describe('When selecting qPCR Results for QCType', () => {
before(() => {
cy.visit('/lab/visium_qc');
selectOption('qcType', 'qPCR results');
cy.get('#labwareScanInput').type('STAN-2100{enter}');
});

context('When a user enters a global CQ value', () => {
before(() => {
cy.findByTestId('all-Cq value').type('5');
});
it('updates all the Cq value inputs inside the table related to the slots', () => {
cy.findAllByTestId('Cq value-input').should('have.value', 5);
});
});

describe('On Save', () => {
it('Save button should be disabled when there is no SGP number', () => {
selectSGPNumber('');
cy.findByRole('button', { name: /Save/i }).should('be.disabled');
});

context('When there is no server error', () => {
before(() => {
selectSGPNumber('SGP1008');
cy.findByRole('button', { name: /Save/i }).should('not.be.disabled').click();
});

it('shows a success message', () => {
cy.findByText('qPCR results complete').should('be.visible');
});
after(() => {
cy.findByRole('button', { name: /Reset/i }).click();
});
});
context('With server failure', () => {
before(() => {
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<RecordOpWithSlotMeasurementsMutation, RecordOpWithSlotMeasurementsMutationVariables>(
'RecordOpWithSlotMeasurements',
() => {
return HttpResponse.json({
errors: [
{
message: 'Exception while fetching data : The operation could not be validated.',
extensions: {
problems: ['Labware is discarded: [STAN-2100]']
}
}
]
});
}
)
);
});
cy.reload();
selectSGPNumber('SGP1008');
selectOption('qcType', 'qPCR results');
cy.get('#labwareScanInput').type('STAN-2100{enter}');
cy.findByTestId('all-Cq value').type('5');
cy.findByRole('button', { name: /Save/i }).click();
});

it('shows an error', () => {
cy.findByText('Failed to record qPCR results').should('be.visible');
});
});
});
});

function saveButton() {
return cy.findByRole('button', { name: /Save/i });
}
Expand Down
Loading
Loading