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

Msw update from 1.2.1 to 2.0.1 #521

Merged
merged 26 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ README.md
.github
.storybook
.prettierignore
jest.polyfills.js
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout
- name: Export node version
id: node_version
Expand All @@ -28,7 +28,7 @@ jobs:
id: yarn-cache-dir-path
run: >-
echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout
- name: Export node version
id: node_version
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ steps.node_version.outputs.NODE_VERSION }}
- name: Build storybook
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
image: cypress/browsers:node18.12.0-chrome106-ff106
options: --user 1001
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout
- name: Setup node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
name: Run snyk tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master #Pre-created container
continue-on-error: true #To make sure that SARIF upload gets called and also not to block CI run on snyk test failure
Expand All @@ -66,7 +66,7 @@ jobs:
name: Run snyk monitor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master #Pre-created container
with:
Expand All @@ -78,9 +78,9 @@ jobs:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -95,9 +95,9 @@ jobs:
name: Check format with prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -112,9 +112,9 @@ jobs:
name: Lint with ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.15.1
v20.11.0
67 changes: 34 additions & 33 deletions cypress/e2e/pages/aliquoting.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AliquotMutation, AliquotMutationVariables } from '../../../src/types/sdk';
import { selectSGPNumber } from '../shared/customReactSelect.cy';
import { HttpResponse } from 'msw';

function scanInLabware() {
cy.get('#labwareScanInput').type('STAN-011{enter}');
Expand Down Expand Up @@ -42,39 +43,6 @@ describe('Aliquoting', () => {
});
});

context('when aliquoting fails', () => {
before(() => {
cy.visit('/lab/aliquoting');

cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<AliquotMutation, AliquotMutationVariables>('Aliquot', (req, res, ctx) => {
return res.once(
ctx.errors([
{
message: 'Exception while fetching data (/aliquot) : Failed to aliquot'
}
])
);
})
);
});

scanInLabware();
selectSGPNumber('SGP1008');
enterNumberOfDestinationTubes('4');
cy.findByText('Aliquot').click();
});

it("doesn't disable the Aliquot button", () => {
cy.findByRole('button', { name: 'Aliquot' }).should('not.be.disabled');
});

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

context('when aliquoting is successful', () => {
before(() => {
cy.visit('/lab/aliquoting');
Expand Down Expand Up @@ -133,4 +101,37 @@ describe('Aliquoting', () => {
cy.url().should('be.equal', 'http://localhost:3000/store');
});
});

context('when aliquoting fails', () => {
before(() => {
cy.visit('/lab/aliquoting');
cy.msw().then(({ worker, graphql }) => {
worker.use(
graphql.mutation<AliquotMutation, AliquotMutationVariables>('Aliquot', () => {
return HttpResponse.json({
errors: [
{
message: 'Exception while fetching data (/aliquot) : Failed to aliquot'
}
]
});
})
);
});

scanInLabware();
selectSGPNumber('SGP1008');
enterNumberOfDestinationTubes('4');
cy.findByText('Aliquot').click();
});

it("doesn't disable the Aliquot button", () => {
cy.findByRole('button', { name: 'Aliquot' }).should('not.be.disabled');
});

it('shows an error message', () => {
cy.findByText('Failed to aliquot').should('be.visible');
});
after(() => {});
});
});
21 changes: 11 additions & 10 deletions cypress/e2e/pages/blockProcessing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { selectOption, selectSGPNumber } from '../shared/customReactSelect.cy';
import { sampleFactory, tissueFactory } from '../../../src/lib/factories/sampleFactory';
import { slotFactory } from '../../../src/lib/factories/slotFactory';
import { createLabwareFromParams } from '../../../src/mocks/handlers/labwareHandlers';
import { HttpResponse } from 'msw';

describe('Block Processing', () => {
shouldDisplyProjectAndUserNameForWorkNumber('/lab/original_sample_processing?type=block');
Expand Down Expand Up @@ -255,15 +256,15 @@ describe('Block Processing', () => {
worker.use(
graphql.mutation<PerformTissueBlockMutation, PerformTissueBlockMutationVariables>(
'PerformTissueBlock',
(req, res, ctx) => {
return res(
ctx.data({
() => {
return HttpResponse.json({
data: {
performTissueBlock: {
labware: newLabware,
operations: []
}
})
);
}
});
}
)
);
Expand Down Expand Up @@ -323,16 +324,16 @@ describe('Block Processing', () => {
worker.use(
graphql.mutation<PerformTissueBlockMutation, PerformTissueBlockMutationVariables>(
'PerformTissueBlock',
(req, res, ctx) => {
return res.once(
ctx.errors([
() => {
return HttpResponse.json({
errors: [
{
extensions: {
problems: ['This thing went wrong', 'This other thing went wrong']
}
}
])
);
]
});
}
)
);
Expand Down
Loading
Loading