Skip to content
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
68 changes: 68 additions & 0 deletions cypress/e2e/pages/addExternalId.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { AddExternalIdsMutation, AddExternalIdsMutationVariables } from '../../../src/types/sdk';
import { HttpResponse } from 'msw';

describe('Add External ID page', () => {
before(() => {
cy.visit('/lab/add_external_id');
});

context('when form is submitted without filling in any fields', () => {
before(() => {
cy.findByRole('button', { name: 'Submit' }).click();
});

it('has the correct properties for the Submit button', () => {
cy.findByRole('button', { name: 'Submit' }).should('be.visible');
cy.findByRole('button', { name: 'Submit' }).should('not.be.disabled');
});

it('shows an error about labwares', () => {
cy.findByText('A labware must be scanned in').should('be.visible');
});

it('shows an error about external name', () => {
cy.findByText('At least one external id must be provided').should('be.visible');
});
});

context('when form is submitted with valid inputs', () => {
before(() => {
fillInTheForm();
});

it('displays a success message', () => {
cy.findByText('External ID(s) successfully added').should('be.visible');
});
});

context('when there is server errors', () => {
before(() => {
cy.reload();
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<AddExternalIdsMutation, AddExternalIdsMutationVariables>('AddExternalIds', () => {
return HttpResponse.json({
errors: [
{
message: "The request could not be validated. 'Tissue already has an external name, in slot: [A1]'"
}
]
});
})
);
});
fillInTheForm();
});
it('shows an error', () => {
cy.findByText("The request could not be validated. 'Tissue already has an external name, in slot: [A1]'").should(
'be.visible'
);
});
});
});

const fillInTheForm = () => {
cy.get('#labwareScanInput').type('STAN-011{enter}');
cy.get("input[name='addressNames[0].externalName']").type('ExternalID1');
cy.findByRole('button', { name: 'Submit' }).click();
};
30 changes: 0 additions & 30 deletions cypress/e2e/pages/addExternalIdSpec.cy.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/graphql/mutations/AddExternalIds.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mutation AddExternalIds($request: AddExternalIdsRequest!) {
addExternalIds(request: $request) {
operations {
operationType {
name
}
user {
username
}
performed
}
}
}
7 changes: 6 additions & 1 deletion src/mocks/handlers/originalSampleProcessingHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { graphql, HttpResponse } from 'msw';
import {
AddExternalIdsMutation,
AddExternalIdsMutationVariables,
GetBlockProcessingInfoQuery,
GetBlockProcessingInfoQueryVariables,
GetNextReplicateNumberQuery,
Expand Down Expand Up @@ -126,7 +128,10 @@ const originalSampleProcessingHandlers = [
}
});
}
)
),
graphql.mutation<AddExternalIdsMutation, AddExternalIdsMutationVariables>('AddExternalIds', () => {
return HttpResponse.json({ data: { addExternalIds: { operations: [] } } }, { status: 200 });
})
];

export default originalSampleProcessingHandlers;
Loading