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

added 3-click centring tests #1258

Merged
merged 3 commits into from
Jun 21, 2024
Merged

Conversation

walesch-yan
Copy link
Contributor

This includes 3 changes to the e2e tests:

  • addition of 3-click centring tests
  • restructuring app.cy.js into multiple specs, this makes it faster to test specific components in the future
  • updating cypress to the latest version: this is necessary to fix a an issue that includees newer firefox versions and running multiple specs after another

Copy link
Contributor

@axelboc axelboc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

Comment on lines 23 to 24
.invoke('val')
/* eslint-disable-next-line promise/prefer-await-to-then */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could disable those two warnings for all Cypress specs in https://github.com/mxcube/mxcubeweb/blob/develop/ui/.eslintrc.js#L59

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment, you are right that would be a better solution!

Comment on lines 34 to 37
cy.contains('button', '3-click centring').click();
cy.get('.form-control[name="diffractometer.phi"]')
.invoke('val')
.should('equal', omegaValue.toFixed(2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to act more like a real user here (and in other places like in the takeControl command), with queries like cy.findByLabelText (to find an input field with its label) or cy.findByRole (to find headings, buttons, etc.).

It can be done later though, as it may require "fixing" the accessibility/markup of the relevant features (like labeling form inputs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you mentioned for some elements, I could not use the mentioned queries. However, I agree with you that I often did not act like a real user (especially for takeControl and clearSamples commands) and some parts can be handled differently, I will take a look at it and make the necessary changes. Thanks for the comment!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks guys !

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();
cy.findByRole('button', { name: '3-click centring' }).click();
cy.get('.form-control[name="diffractometer.phi"]')
.invoke('val')
.then((value) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I changed most of the cypress queries to act more like a real User, there are a few input forms that do not provide a corresponding label (resp. the text that should be the label is not correctly linked). This might be investigated in future steps.

@marcus-oscarsson
Copy link
Member

Really nice :), we can improve the access to some of the elements in a future PR :)

@marcus-oscarsson marcus-oscarsson merged commit 2e491ea into develop Jun 21, 2024
13 checks passed
@marcus-oscarsson marcus-oscarsson deleted the yw-test-3-click-centring branch June 21, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants