Skip to content

Commit

Permalink
added 3-click centring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
walesch-yan committed Jun 20, 2024
1 parent cdc425d commit d23d8df
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 31 deletions.
13 changes: 0 additions & 13 deletions ui/cypress/e2e/app.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,3 @@ describe('app', () => {
cy.findByRole('button', { name: /Beamline Actions/u }).should('be.visible');
});
});

describe('queue', () => {
beforeEach(() => {
cy.login();
cy.findByRole('link', { name: 'MXCuBE-Web (OSC)' }).should('be.visible');
cy.takeControl();
});

it('mount a test sample', () => {
cy.mountSample('test', 'test');
cy.findByText('Sample: test - test').should('be.visible');
});
});
14 changes: 14 additions & 0 deletions ui/cypress/e2e/queue.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global cy, it, describe, beforeEach */

describe('queue', () => {
beforeEach(() => {
cy.login();
cy.findByRole('link', { name: 'MXCuBE-Web (OSC)' }).should('be.visible');
cy.takeControl();
});

it('mount a test sample', () => {
cy.mountSample('test', 'test');
cy.findByText('Sample: test - test').should('be.visible');
});
});
41 changes: 41 additions & 0 deletions ui/cypress/e2e/sampleControls.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* global cy, it, describe, beforeEach, Cypress */

describe('3-click centring', () => {
beforeEach(() => {
cy.login();
cy.findByRole('link', { name: 'MXCuBE-Web (OSC)' }).should('be.visible');
cy.takeControl();
});

it('3-click centring should not work without sample', () => {
cy.clearSamples();
cy.contains('button', '3-click centring').click();
cy.findByRole('alert', 'Error: There is no sample mounted').should(
'be.visible',
);
});

it('Each click is rotating the sample by 90 degrees', () => {
cy.mountSample();
cy.contains('button', '3-click centring').click();
/* eslint-disable-next-line promise/catch-or-return */
cy.get('.form-control[name="diffractometer.phi"]')
.invoke('val')
/* eslint-disable-next-line promise/prefer-await-to-then */
.then((value) => {
let omegaValue = Number.parseFloat(value);
Cypress._.times(2, () => {
omegaValue += 90;
cy.get('.canvas-container').click();
// to update the omega value, a small amount of time must be waited and the page reloaded
cy.wait(1000);
cy.reload();
// press the centring button again after reload to stay in the correct mode
cy.contains('button', '3-click centring').click();
cy.get('.form-control[name="diffractometer.phi"]')
.invoke('val')
.should('equal', omegaValue.toFixed(2));
});
});
});
});
12 changes: 9 additions & 3 deletions ui/cypress/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Cypress.Commands.add('takeControl', () => {

// ensure to click away the observer mode dialog box if present
/* eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then */
cy.findByRole('dialog').then(($dialog) => {
if ($dialog.text().includes('Observer mode')) {
cy.wrap($dialog.find('.form-control')).type('test');
cy.get('body').then(($body) => {
if ($body.text().includes('Observer mode')) {
cy.wrap($body.find('.modal-dialog').find('.form-control')).type('test');
cy.findByText('OK').click();
}
});
Expand All @@ -31,6 +31,7 @@ Cypress.Commands.add('takeControl', () => {
Cypress.on('uncaught:exception', (err, runnable) => {
return true;
});
cy.reload();
});

Cypress.Commands.add('mountSample', (sample = 'test', protein = 'test') => {
Expand All @@ -43,3 +44,8 @@ Cypress.Commands.add('mountSample', (sample = 'test', protein = 'test') => {
// reload for button changes to take effect
cy.reload();
});

Cypress.Commands.add('clearSamples', () => {
cy.request('PUT', '/mxcube/api/v0.1/queue/clear');
cy.reload();
});
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@testing-library/user-event": "^13.5.0",
"babel-preset-react-app": "10.0.1",
"concurrently": "^7.0.0",
"cypress": "13.1.0",
"cypress": "13.12.0",
"eslint": "8.42.0",
"eslint-config-galex": "4.5.2",
"eslint-plugin-import": "2.27.5",
Expand Down
22 changes: 8 additions & 14 deletions ui/pnpm-lock.yaml

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

0 comments on commit d23d8df

Please sign in to comment.