-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix(tests): Move leftover acceptance tests for users from drone to Cypress #41021
Conversation
b59766a
to
2e1b182
Compare
BTW using random users should make it also less flaky, as now every test has a defined state. |
1be69fa
to
64839ed
Compare
If random users makes it flaky, the tests or our codeis probably the issue then. |
Exactly, previously hardcoded "jane doe" was used, but that might lead to inconsistent state. It would need some more work (I do not have the time currently) to rewrite the tests, as the best way (and the best practice from Cypress) would be to ensure we have a clean state before the tests and not clean up after the tests. So e.g. removing the datadir and resetting the database before each test. Thinking about this hardcoding users might also be good if we always use the same and have something like:
But especially as our Cypress tests are also changing admin settings (we have a reset but only for theming), the golden standard would be to reset all settings by running every testsuite with the initial database. // in e2e support file
before(() => {
cy.exec('docker exec --user www-data nextcloud-cypress-tests-server rm -rf apps-cypress')
cy.exec('docker exec --user www-data nextcloud-cypress-tests-server mkdir apps-cypress')
cy.exec('docker exec --user www-data nextcloud-cypress-tests-server bash -c \'echo -e "<?php\\n\\$CONFIG = [\\n\\t\\"apps_paths\\" => [\\n\\t\\t[\\"path\\" => \\"/var/www/html/apps\\", \\"url\\" => \\"/apps\\", \\"writeable\\"=>false],\\n\\t\\t[\\"path\\" => \\"/var/www/html/apps-cypress\\", \\"url\\" => \\"/apps2\\", \\"writeable\\" => true]\\n\\t],\\n];" > config/cypress.config.php\'')
cy.exec('docker exec --user www-data nextcloud-cypress-tests-server tar -cf clean-state.tar apps-cypress config data')
})
beforeEach(() => {
cy.exec('docker exec --user www-data nextcloud-cypress-tests-server rm -rf apps-cypress config data')
cy.exec('docker exec --user www-data nextcloud-cypress-tests-server tar -xpf clean-state.tar')
}) Edit: Pushed another commit making all user modify tests less flaky as the users and groups are reset before each run. As suggested by the Cypress best practice guides. |
<template v-if="editing && user.backendCapabilities.setDisplayName"> | ||
<NcTextField ref="displayNameField" | ||
class="user-row-text-field" | ||
data-test-id="input-displayName" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we talked abut this before with various other devs. I advocated for the usage of data-cy-xxxx
and seemed that other devs agreed too after a some discussion. This allow to scope the elements.
I know what the best-practices says, but I think they do not have our overall ecosystem, so things differs a bit :)
The data attribute value should be used when it have a real changing value. Like data-cy-userslist-user="admin"
. Otherwise it makes really weird to target a specific element.
I also prefer to have more unique data attributes. The fact that you can grep all [data-cy="files-list-row"]
makes no sense imho.
But [data-cy-files-list-row]
and [data-cy-files-list-row-fileid="12345"]
does :)
Any thoughts or counter arguments?
cc @artonge @max-nextcloud @Pytal as I recall you were in that discussion before 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it makes no difference if I use data-testid
or data-cy
both a pretty common and standard, so I am fine with both.
The fact that you can grep all [data-cy="files-list-row"] makes no sense imho.
But [data-cy-files-list-row] and [data-cy-files-list-row-fileid="12345"] does :)
Well for me not that much 😅
data-cy="files-list-row"
for me this is like the id
(without its singleton limitation), so it says "Select all elements that are file list rows". While data-cy-files-list-row-fileid="12345"
says "get the file list row that for file ID 12345".
So my problem with data-cy-files-list-row
vs data-cy="files-list-row"
is that there is no consistent naming for identifying elements, you always need to use a specific attribute rather that a specific attribute ID.
This feels wrong in a HTML context.
But this is not about feels, so I have no problem to stick with one notation for all of our code and if it was decided to go with data-cy-some-identifier
as boolean attribute then I am fine with it. As there is no technical downside 😃
Need some time to adjust this PR then for data-cy
and we should probably add this to our development guides :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR: Will take some time this week to adjust the test selectors 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data-cy="files-list-row"
for me this is like theid
(without its singleton limitation), so it says "Select all elements that are file list rows". Whiledata-cy-files-list-row-fileid="12345"
says "get the file list row that for file ID 12345".
If you want all the lines, then you can also do [data-cy-files-list-row-fileid]
, without the id.
That's the benefit of scoped selectors. And with [data-cy="files-list-row"]
, you cannot select by Ids with that syntax.
Or with something like [data-cy="files-list-row-123456"]
, but I find it incredibly messy 🤷
Ah, I read it as the opposite 🙈 |
1826e93
to
9a0b9b8
Compare
9a0b9b8
to
6a8756c
Compare
✅ Deploy Preview for nextcloud-server ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
* Use common `data-testid` to identify elements rather than to depend on internal classes or properties * Force clean the state for the user tests * Move leftover acceptance tests for users from drone to cypress Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
6a8756c
to
5b0c27b
Compare
Cypress error caused by theming, so will do a follow up fixing theming tests. |
Summary
Move the tiny rest of acceptance tests for user setting to Cypress and add missing test cases:
Checklist