Skip to content

Commit

Permalink
Merge branch 'develop' into renovate/mui-x-date-pickers-6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kaperoo authored Oct 30, 2023
2 parents bbd9568 + 3c47734 commit ef6c107
Show file tree
Hide file tree
Showing 80 changed files with 1,887 additions and 1,158 deletions.
82 changes: 42 additions & 40 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 34 additions & 2 deletions cypress/integration/table/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,23 @@ describe('Search', () => {
});
}).as('getSettings');

cy.visit('/').wait(['@getSettings']);
cy.visit('/', {
// need these to ensure Date picker media queries pass
// ref: https://mui.com/x/react-date-pickers/getting-started/#testing-caveats
onBeforeLoad: (win) => {
cy.stub(win, 'matchMedia')
.withArgs('(pointer: fine)')
.returns({
matches: true,
addListener: () => {
// no-op
},
removeListener: () => {
// no-op
},
});
},
}).wait(['@getSettings']);

cy.findByRole('progressbar').should('be.visible');
cy.findByRole('progressbar').should('not.exist');
Expand Down Expand Up @@ -1093,7 +1109,23 @@ describe('Search', () => {
});
}).as('getSettings');

cy.visit('/').wait(['@getSettings']);
cy.visit('/', {
// need these to ensure Date picker media queries pass
// ref: https://mui.com/x/react-date-pickers/getting-started/#testing-caveats
onBeforeLoad: (win) => {
cy.stub(win, 'matchMedia')
.withArgs('(pointer: fine)')
.returns({
matches: true,
addListener: () => {
// no-op
},
removeListener: () => {
// no-op
},
});
},
}).wait(['@getSettings']);
});

it('displays appropriate tooltips', () => {
Expand Down
67 changes: 67 additions & 0 deletions cypress/integration/table/sessions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ describe('Sessions', () => {
expect(value).to.equal('2022-01-09 12:00');
});

cy.findByTestId('session-save-buttons-timestamp').should(
'have.text',
'Session last saved: 29 Jun 2023 14:45'
);

cy.findByText('Session 3').click();
// wait for search to initiate and finish
cy.findByRole('progressbar').should('exist');
Expand All @@ -109,6 +114,11 @@ describe('Sessions', () => {
const value = $input.val();
expect(value).to.equal('');
});

cy.findByTestId('session-save-buttons-timestamp').should(
'have.text',
'Session last autosaved: 30 Jun 2023 09:15'
);
});

it('sends a patch request when a user edits a session', () => {
Expand Down Expand Up @@ -154,6 +164,63 @@ describe('Sessions', () => {
});
});

it('sends a patch request when a user saves their current session', () => {
cy.findByText('Session 2').click();

cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', { name: 'Save' }).click();

cy.findBrowserMockedRequests({
method: 'PATCH',
url: '/sessions/:id',
}).should((patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
'{"table":{"columnStates":{},"selectedColumnIds":["timestamp","CHANNEL_EFGHI","CHANNEL_FGHIJ","shotnum"],"page":0,"resultsPerPage":25,"sort":{}},"search":{"searchParams":{"dateRange":{"fromDate":"2022-01-06T13:00:00","toDate":"2022-01-09T12:00:59"},"shotnumRange":{"min":7,"max":9},"maxShots":50,"experimentID":{"_id":"19210012-1","end_date":"2022-01-09T12:00:00","experiment_id":"19210012","part":1,"start_date":"2022-01-06T13:00:00"}}},"plots":{},"filter":{"appliedFilters":[[{"type":"channel","value":"shotnum","label":"Shot Number"},{"type":"compop","value":">","label":">"},{"type":"number","value":"7","label":"7"}]]},"windows":{}}'
);
expect(request.url.toString()).to.contain('2');
expect(request.url.toString()).to.contain('name=');
expect(request.url.toString()).to.contain('summary=');
expect(request.url.toString()).to.contain('auto_saved=');

const paramMap: Map<string, string> = getParamsFromUrl(
request.url.toString()
);

expect(paramMap.get('name')).equal('Session+2');
expect(paramMap.get('summary')).equal(
'This+is+the+summary+for+Session+2'
);
expect(paramMap.get('auto_saved')).equal('false');
});
});

it('opens the save session dialog if a user session is not selected and user click the save or save as button', () => {
cy.findByRole('button', { name: 'Save' }).click();
cy.findByLabelText('Save Session').should('exist');
cy.findByRole('button', { name: 'Close' }).click();
cy.findByRole('button', { name: 'Save as' }).click();
cy.findByLabelText('Save Session').should('exist');
});

it('loads in the summary and name (with _copy) when save as is clicked and a user session is selected', () => {
cy.findByText('Session 2').click();
cy.findByRole('button', { name: 'Save as' }).click();
cy.findByLabelText('Save Session').should('exist');

cy.findByLabelText('Name *').should(($input) => {
const value = $input.val();
expect(value).to.equal('Session 2_copy');
});

cy.findByLabelText('Summary').should(($input) => {
const value = $input.val();
expect(value).to.equal('This is the summary for Session 2');
});
});

it('sends a delete request when a user deletes a session', () => {
cy.findByRole('button', { name: 'delete Session 1 session' }).click();
cy.findByText('Delete Session');
Expand Down
Loading

0 comments on commit ef6c107

Please sign in to comment.