Skip to content

Commit

Permalink
Merge branch 'DSEGOG-347-add-a-favourite-filter' into DSEGOG-348-view…
Browse files Browse the repository at this point in the history
…-favourite-filters
  • Loading branch information
joshuadkitenge committed Oct 15, 2024
2 parents 757b8f0 + 274192b commit aec7dc6
Show file tree
Hide file tree
Showing 90 changed files with 1,301 additions and 2,902 deletions.
59 changes: 0 additions & 59 deletions .eslintrc.cjs

This file was deleted.

30 changes: 15 additions & 15 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: 20
cache: 'yarn'
Expand All @@ -27,7 +27,7 @@ jobs:
run: yarn test
- name: Upload unit test coverage
if: success()
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand All @@ -36,9 +36,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: 20
cache: 'yarn'
Expand All @@ -51,16 +51,16 @@ jobs:
run: yarn e2e
- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: OperationsGateway Screenshots
path: cypress/screenshots
playwright-tests-mocked:
name: Playwright Tests (mocked)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: 20
cache: 'yarn'
Expand All @@ -72,7 +72,7 @@ jobs:
run: yarn playwright:test:mocked

- name: Upload test report
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
if: always()
with:
name: playwright-report-mocked-tests
Expand All @@ -82,10 +82,10 @@ jobs:
name: E2E Tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4

- name: Checkout OperationsGateway API
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
repository: ral-facilities/operationsgateway-api
ref: main
Expand All @@ -103,7 +103,7 @@ jobs:
with:
python-version: 3.9
- name: Load Pip cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
with:
path: ~/.cache/pip
key: ubuntu-20.04-pip-3.9-${{ env.pythonLocation }}-${{ hashFiles('operationsgateway-api/.github/ci_requirements.txt') }}
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:

# Load Poetry virtual environment dependencies and install API dependencies
- name: Load Poetry cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ubuntu-20.04-poetry-3.9-${{ env.pythonLocation }}-${{ hashFiles('poetry.lock') }}
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
run: nohup poetry run python -m operationsgateway_api.src.main > api-output.txt &
working-directory: ./operationsgateway-api

- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: 20
cache: 'yarn'
Expand All @@ -220,7 +220,7 @@ jobs:
run: yarn playwright:test:real

- name: Upload test report
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
if: always()
with:
name: playwright-report-real-tests
Expand Down
324 changes: 162 additions & 162 deletions .yarn/releases/yarn-4.4.1.cjs → .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.4.1.cjs
yarnPath: .yarn/releases/yarn-4.5.0.cjs
4 changes: 3 additions & 1 deletion cypress/e2e/channels.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ describe('Data Channels Component', () => {
.should('be.visible')
.should(($imgs) =>
// natural width means the img is a real image
$imgs.map((i, img) => expect(img.naturalWidth).to.be.greaterThan(0))
$imgs.map((_i, img) =>
expect((img as HTMLImageElement).naturalWidth).to.be.greaterThan(0)
)
);

cy.findByRole('button', { name: 'Channel_ABCDE' }).click();
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/filtering.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ describe('Filtering Component', () => {

it('add a new favourite filter', () => {
cy.findByRole('button', { name: 'Add new favourite filter' }).click();
cy.findByLabelText('Name').type('test');
cy.findAllByLabelText('Name').last().type('test');
cy.findByRole('combobox', { name: 'Filter' }).type(
'sh{enter}={enter}1{enter}'
);
Expand Down Expand Up @@ -560,7 +560,7 @@ describe('Filtering Component', () => {
cy.findByRole('button', { name: 'Add new favourite filter' }).click();
cy.findByText('Add Favourite filter').should('exist');

cy.findByLabelText('Name').type('test');
cy.findAllByLabelText('Name').last().type('test');

cy.findByRole('button', { name: 'Save' }).should('be.disabled');
});
Expand All @@ -569,7 +569,7 @@ describe('Filtering Component', () => {
cy.findByRole('button', { name: 'Add new favourite filter' }).click();
cy.findByText('Add Favourite filter').should('exist');

cy.findByLabelText('Name').type('test');
cy.findAllByLabelText('Name').last().type('test');

cy.findByRole('combobox', { name: 'Filter' }).type('sh{enter}={enter}');
cy.findByRole('combobox', { name: 'Filter' }).blur();
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ describe('Search', () => {
.findByRole('spinbutton', {
name: 'Min',
})
.type(14);
.type('14');
cy.findByLabelText('close shot number search box').click();

cy.findByLabelText('open experiment search box')
Expand All @@ -1019,7 +1019,7 @@ describe('Search', () => {
.findByRole('spinbutton', {
name: 'Max',
})
.type(14);
.type('14');
cy.findByLabelText('close shot number search box').click();

cy.findByLabelText('open experiment search box')
Expand Down Expand Up @@ -1048,7 +1048,7 @@ describe('Search', () => {
.findByRole('spinbutton', {
name: 'Min',
})
.type(12);
.type('12');
cy.findByLabelText('close shot number search box').click();

cy.findByLabelText('open experiment search box')
Expand All @@ -1075,7 +1075,7 @@ describe('Search', () => {
.findByRole('spinbutton', {
name: 'Max',
})
.type(16);
.type('16');
cy.findByLabelText('close shot number search box').click();

cy.findByLabelText('open experiment search box')
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/table.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('Table Component', () => {
addInitialSystemChannels(['Shot Number']);
cy.get('[role="columnheader"]').should('be.visible');

cy.get('[role="table-container"]').scrollTo('bottom');
cy.get('[data-testid="table-container"]').scrollTo('bottom');
cy.get('[role="columnheader"]').should('be.visible');
});

Expand Down Expand Up @@ -168,7 +168,7 @@ describe('Table Component', () => {

cy.contains('Add Channels').click();

cy.get('[role="table-container"]').scrollTo('right');
cy.get('[data-testid="table-container"]').scrollTo('right');
cy.findByRole('columnheader', { name: 'Time' }).should('be.visible');
// double check that we have scrolled far enough to test sticky column
cy.findByRole('columnheader', { name: 'Shot Number' }).should(
Expand Down Expand Up @@ -339,7 +339,7 @@ describe('Table Component', () => {

// click on all checkboxes
cy.get('tbody').within(() => {
cy.get('tr.MuiTableRow-root').each(($tr, index) => {
cy.get('tr.MuiTableRow-root').each(($tr) => {
cy.wrap($tr).within(() => {
cy.get('td').first().click();
});
Expand Down
52 changes: 51 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Cypress.Commands.add('dragAndDrop', (subject, target) => {
});
});

let mockedRequests = [];
let mockedRequests: Request[] = [];

Cypress.Commands.add('clearMocks', () => {
mockedRequests = [];
Expand Down Expand Up @@ -136,3 +136,53 @@ Cypress.Commands.add('findBrowserMockedRequests', ({ method, url }) => {
}
});
});

declare global {
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
msw: { worker: any; http: any; matchRequestUrl: any; HttpResponse: any };
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
dragAndDrop(subject: string, target: string): Chainable<unknown>;
/**
* Clear all mocks
* @example cy.clearMocks()
*/
clearMocks(): Chainable<unknown>;
/**
* Use before findBrowserMockedRequests for checking specific requests were sent
* @example cy.startSnoopingBrowserMockedRequest()
*/
startSnoopingBrowserMockedRequest(): Chainable<unknown>;
/**
* Returns a request that was recorded after 'startSnoopingBrowserMockedRequest' was called
*
* URL is a pattern matching URL that uses the same behavior as handlers URL matching
* e.g. '* /events/groups/:groupId' without the space
* @example cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-categories',
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"name":"test","is_leaf":false}'
);
});
*/
findBrowserMockedRequests({
method,
url,
}: {
method: string;
url: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}): Chainable<any>;
}
}
}
14 changes: 0 additions & 14 deletions cypress/support/index.d.ts

This file was deleted.

15 changes: 13 additions & 2 deletions e2e/real/images.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.beforeEach(async ({ page }) => {
await page.keyboard.press('ArrowDown');
await page.keyboard.press('Enter');

await page.getByRole('button', { name: 'Add this channel' }).click();
for (const row of await page.getByRole('checkbox').all()) await row.check();

await page.getByRole('button', { name: 'Add Channels' }).click();
});
Expand Down Expand Up @@ -232,6 +232,16 @@ test('user can set their default colourmap', async ({ page }) => {
expect(defaultColourMapDropdown).toHaveText('');

await defaultColourMapDropdown.click();

// Start waiting for record request triggered by changing colourmap
// need to wait for responses with more than 2 projection parameters to select
// the table query and not the image window thumbnail picker query
const recordsPromise = page.waitForResponse(
(response) =>
response.url().includes('records') &&
(response.url().match(/projection/g) || []).length > 2
);

await page
.getByRole('option', {
name: 'inferno',
Expand All @@ -240,7 +250,8 @@ test('user can set their default colourmap', async ({ page }) => {

expect(defaultColourMapDropdown).toHaveText('inferno');

// TODO - could the assert below be flaky if the screenshot is taken before the invalidated query comes back?
// wait for records response to come back before taking screenshot
const response = await recordsPromise;

await expect(tableThumbnail).toBeAttached();
expect(
Expand Down
Loading

0 comments on commit aec7dc6

Please sign in to comment.