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

X1034 react router upgrade to 6.0 #400

Merged
merged 13 commits into from
Sep 15, 2023
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', () => {
describe('On load', () => {
before(() => {
cy.visit('/lab/probe_hybridisation_qc');
});
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-3111{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', () => {
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('should fail when repeated comment specified for the same section', () => {
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
}
]
}
})
);
}
)
);
});
cy.findByText('Save').click();
});

it('shows a success message', () => {
cy.findByText('Probe Hybridisation QC recorded for all labware(s)').should('be.visible');
});
});
});
});
80 changes: 76 additions & 4 deletions cypress/e2e/pages/configuration.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { AddReleaseRecipientMutation, AddReleaseRecipientMutationVariables } from '../../../src/types/sdk';
import {
AddReleaseRecipientMutation,
AddReleaseRecipientMutationVariables,
UpdateReleaseRecipientFullNameMutation,
UpdateReleaseRecipientFullNameMutationVariables
} from '../../../src/types/sdk';
import { selectOption } from '../shared/customReactSelect.cy';

describe('Configuration Spec', () => {
@@ -116,6 +121,39 @@ describe('Configuration Spec', () => {
});
});

describe('displays extra input field when specified', () => {
const config = {
name: 'Release Recipients',
tabName: 'Release Recipients',
field: 'cs41',
extraFieldValue: 'Csaba Csordas',
buttonName: '+ Add Username',
newValue: 'az99',
newExtraFieldValue: 'Arielle Zimran'
};
context('configuration table should contains extra column to display extra field values', () => {
before(() => {
cy.scrollTo(0, 0);
cy.findByText(config.name).click();
});

it('displays extra field values', () => {
cy.get(`div[data-testid="config"]:contains(${config.name})`)
.find(`tr:contains(${config.field}) `)
.find('input')
.first()
.should('have.value', config.extraFieldValue);
});

it('displays extra field input when adding new entity', () => {
clickButton(config.buttonName);
cy.findByTestId('input-field').scrollIntoView().focus().type(`${config.newValue}`);
enterNewExtraFieldValue(config.extraFieldValue);
cy.findByText('Saved').scrollIntoView().should('be.visible');
});
});
});

context('When adding a Release Recipients fails', () => {
before(() => {
cy.msw().then(({ worker, graphql }) => {
@@ -134,8 +172,6 @@ describe('Configuration Spec', () => {
)
);
});
cy.scrollTo(0, 0);
cy.findByText('Release Recipients').click();
});

it('shows an error message', () => {
@@ -147,8 +183,40 @@ describe('Configuration Spec', () => {
});
});
});

context('When Updating a Release Recipient full name successfully', () => {
before(() => {
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<UpdateReleaseRecipientFullNameMutation, UpdateReleaseRecipientFullNameMutationVariables>(
'UpdateReleaseRecipientFullName',
(req, res, ctx) => {
return res.once(
ctx.data({
updateReleaseRecipientFullName: {
username: 'et2',
fullName: 'Ethan Twin',
enabled: true
}
})
);
}
)
);
});
cy.get(`div[data-testid="config"]:contains('Release Recipients')`)
.find(`tr:contains('et2') `)
.find('input')
.first()
.focus()
.type(`Ethan Twin {enter}`, { force: true });
});
it('shows a success message', () => {
cy.findByText('Changes for "et2" saved').should('be.visible');
});
});
function selectElement(findTag: string) {
return cy.get(findTag).scrollIntoView().click({
return cy.get(findTag).last().scrollIntoView().click({
force: true
});
}
@@ -158,4 +226,8 @@ describe('Configuration Spec', () => {
function enterNewValue(value: string) {
cy.findByTestId('input-field').scrollIntoView().focus().type(`${value}{enter}`, { force: true });
}

function enterNewExtraFieldValue(value: string) {
cy.findByTestId('extra-input-field').scrollIntoView().focus().type(`${value}{enter}`, { force: true });
}
});
33 changes: 30 additions & 3 deletions cypress/e2e/pages/cytAssist.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { SlotCopyMutation, SlotCopyMutationVariables } from '../../../src/types/sdk';
import { LabwareTypeName } from '../../../src/types/stan';
import { selectOption, selectSGPNumber } from '../shared/customReactSelect.cy';
import { selectOption, selectSGPNumber, shouldDisplaySelectedValue } from '../shared/customReactSelect.cy';

describe('CytAssist Page', () => {
before(() => {
cy.visit('/lab/cytassist');
});

describe('On load', () => {
it('shows a Visium LP CytAssist slide for the output', () => {
cy.findAllByText(/Visium LP CytAssist/i).should('have.length.above', 0);
it('output labware type should be empty', () => {
shouldDisplaySelectedValue('output-labware-type', '');
});

it('disables the Save button', () => {
@@ -23,15 +23,42 @@ describe('CytAssist Page', () => {
});
});

context('When user selects Visium LP CytAssist labwareType', () => {
before(() => {
selectLabwareType(LabwareTypeName.VISIUM_LP_CYTASSIST);
});
it('should set output labware type value to Visium LP CytAssist', () => {
shouldDisplaySelectedValue('output-labware-type', 'Visium LP CytAssist');
});
it('shows a Visium LP CytAssist slide for the output', () => {
cy.findAllByText(/Visium LP CytAssist/i).should('have.length.above', 0);
});
});

context('When user selects Visium LP CytAssist XL labwareType', () => {
before(() => {
selectLabwareType(LabwareTypeName.VISIUM_LP_CYTASSIST_XL);
});
it('should set output labware type value to Visium LP CytAssist XL', () => {
shouldDisplaySelectedValue('output-labware-type', 'Visium LP CytAssist XL');
});
it('shows a Visium LP CytAssist XL slide for the output', () => {
cy.findAllByText(/Visium LP CytAssist XL/i).should('have.length.above', 0);
});
});

context('When user selects an empty option for the output labwareType', () => {
before(() => {
selectLabwareType('');
});
it('should set output labware type value to empty', () => {
shouldDisplaySelectedValue('output-labware-type', '');
});
it('hides the output labware image', () => {
cy.get('#outputLabwares').should('not.contain', '[data-testid="slot"]');
});
});

context('When a user scans in a TP Slide', () => {
before(() => {
selectLabwareType(LabwareTypeName.VISIUM_LP_CYTASSIST);
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.