-
Notifications
You must be signed in to change notification settings - Fork 16
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
Initial page object implementation #1080
Conversation
Your Render PR Server URL is https://files-ui-stage-pr-1080.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-c2qm7hoirho589q1c5d0. |
It might make sense to append all of our test files with with "-test" or "-spec" too (spec is the common terminology in the cypress world). Could make it easier to distinguish the test files from others when we're searching in vscode etc. Sound good? |
This seems to be a convention for Cypress, which I took the template from. I don't really mind tbh, "tests" is fine.
Sure I'll check real quick if we can use an object rather than classes, it'd be cleaner not to have to call the |
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.
It's really cool thank you so much for that.
I left a couple comments, but other than that it looks great
@@ -0,0 +1,8 @@ | |||
export const landingPage = { | |||
web3Button: () => cy.get("[data-cy=web3]"), |
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.
I took the liberty to push a commit directly to your branch to show how we can achieve the same as the classes, but without bothering with all boilerplate and initialization.
Unless you think classes are much better for a reason that I missed, I think it'd be better to use objects like this.
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.
Hey Thibaut! Thanks, I agree that your approach here looks simpler and cleaner but doesn't this rule out the ability to use inheritance?
My idea behind the classes is mainly around re-usability and maintainability. At the moment the page classes only contain element declarations but they will eventually hold custom functions (helpers / assertions etc) that receive parameters from the test layer.
All the individual classes extend from BasePage. BasePage will eventually hold a collection of generic re-usable page agnostic helper functions that we can pass parameters to and call on any (subclassed) page.
When there's functionality on a specific page that differs from the generic behaviour we can override inherited functionality in the subclass. Similarly specific page classes will also contain non-generic functions that are exclusive to that specific page only.
Perhaps there's another option where we can keep things simple and reduce some of the boilerplate / initialization but also have the inheritance ability that I mentioned?
Really keen to hear all viewpoints and suggestions, I want to make sure we go with an approach that everyone is happy with.
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.
I think that the argument for classes makes a lot of sense here
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.
Good points, I have some answers to some, but not all.
doesn't this rule out the ability to use inheritance?
We can still have inheritance with the spread operator, like
const someNewObject = {
...someBaseObjectInherited,
newField: (param) => { usingThisParam(param) }
}
they will eventually hold custom functions (helpers / assertions etc) that receive parameters from the test layer
If I understand you correctly, this is solved by what I presented above, you can call from the test layer someNewObject.newField(someParam)
and pass someParam
from the test layer.
Similarly specific page classes will also contain non-generic functions that are exclusive to that specific page only.
This is where I start loosing you and where classes outperform objects. I think I understand what you mean, but I fear we'd be losing ourselves in complex structures. I def. do not have your experience and I don't know how complex things can get.
A rule of thumb I'd like to follow is that we want to have tests as easy to read as possible, but also easy to write. I think we should avoid complex construction as much as possible, hence trying to keep things simple.
Ultimately this is your call, I'm happy with either solution.
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.
(posting to close the loop for anyone reading this).
@Tbaut Now we have clarified we can still use inheritance I will proceed with your solution as we discussed on google hangouts :)
I've gone ahead and appended "spec" to the test file names. |
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.
This looks really great.
Co-authored-by: Michael Yankelev <[email protected]>
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.
Couple more comments, but mostly nits. Feel free to merge once you're happy with it and addressed (or not) my comments.
describe("File management", () => { | ||
|
||
context("desktop", () => { | ||
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.
This before
here is raising questions to me. If we put a .only
to the second test it.only("can add/remove files and upload"
below, then we'll be login-in twice am I right?
This before
means the tests must run exactly in this order, which is not a good practice according to cypress.
I am not 100% sure why the before
assertion was ever created by Cypress tbh, but having the before
, and then seeing in the tests some other cy.web3Login({ clearCSFBucket: true })
make me think we shouldn't use it. Also I think it just makes things harder to read.
Let me know your thoughts.
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.
Removed :)
}) | ||
|
||
context("mobile", () => { | ||
beforeEach(() => { |
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.
Do you know if the before
is fired before the breforeEach
? I see we're clicking the "hamburgerMenu" at the beginning of each test and wondering if we could have this in the beforeEach
.
edit: yup before is fired first, so we may consider having the hamburger click in the beforeEach. cf cypress Hooks doc
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.
@Tbaut Good point. I'll update.
Co-authored-by: Thibaut Sardan <[email protected]>
Co-authored-by: Thibaut Sardan <[email protected]>
…com:ChainSafe/files-ui into mnt/initial-page-object-implementation-1079
…com:ChainSafe/files-ui into mnt/initial-page-object-implementation-1079
* Updated-labels * Removed Reference dev * Update readme.md (#1083) * Update readme.md * Update readme.md * Drop the last sentence from readme.md Co-authored-by: Michael Yankelev <[email protected]> * Survey v2 for product market fit (#1082) * v2 * translatioin FR * more * lingui extract * with gradient * Update packages/files-ui/src/Components/SurveyBanner.tsx Co-authored-by: Cindy Chau <[email protected]> * lingui extract * Update packages/files-ui/src/locales/fr/messages.po * different gradient for better readability Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Cindy Chau <[email protected]> * Storage app skeleton (#1067) * remove old chainsafe x package * initial app skeleton and refactor * fix api client issues * remove old chainsafe x package * initial app skeleton and refactor * fix api client issues * remove tests * Apply suggestions from code review Co-authored-by: Tanmoy Basak Anjan <[email protected]> * Update packages/storage-ui/src/Contexts/StorageApiContext.tsx Co-authored-by: Tanmoy Basak Anjan <[email protected]> * make eslint :D again * remove unneeded login methods Co-authored-by: Tanmoy Basak Anjan <[email protected]> * Update release-drafter with the new name (#1088) * Update release-drafter.yml * Update .github/release-drafter.yml Co-authored-by: Michael Yankelev <[email protected]> * Add page object pattern for ui tests (#1080) * Add PR labeler based on the branch name (#1089) * pr labeler * with workflow * for PR * back to open Co-authored-by: Michael Yankelev <[email protected]> * passwordless login (#1072) * UI ready * UI ready and trans ready * work in progress * lingui extract * passwordless login * code and login * loaders on passwordless login * wallet names * lingui extract * Delete package.json * feedback * lingui extract * Cleanup InitialScreen (#1092) * cleanup * spaces * compile update * fr translation and ternarry nits Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Michael Yankelev <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> * Fix Bin Preview (#1093) * update to new api client and wire up download * cypress bump to avoid having 2 packages Co-authored-by: Thibaut Sardan <[email protected]> * Update pr-labeler.yml (#1099) * Update pr-labeler.yml * Update pr-labeler.yml * Update pr-labeler.yml * Update pr-labeler.yml * Update pr-labeler.yml * Apply suggestions from code review * Update .github/workflows/pr-labeler.yml Co-authored-by: Michael Yankelev <[email protected]> * removed redundant stage & prod release which is replaced by release drafter; updated readme (#1102) Co-authored-by: Thibaut Sardan <[email protected]> * Fix InitialScreen.tsx Error messages (#1100) * Update InitialScreen.tsx * Update packages/files-ui/src/Components/Modules/LoginModule/InitialScreen.tsx Co-authored-by: Michael Yankelev <[email protected]> * Deprecate all `files/` endpoints (#1095) * deprecate all `files/` endpoints * clean up remaining todos * Update packages/files-ui/src/Components/Modules/FileBrowsers/BinFileBrowser.tsx Co-authored-by: Tanmoy Basak Anjan <[email protected]> * fix lint * update to latest api client Co-authored-by: Tanmoy Basak Anjan <[email protected]> * Files API Client in Tests (#1097) * use api client in tests * fix detached from the Dom (#1096) Co-authored-by: Thibaut Sardan <[email protected]> * make eslint :D * update yarn lock * update commands Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> * Recover files with move file modal (#1094) * recover files in modal * move file restructure * lingui extract * deprecate all `files/` endpoints * clean up remaining todos * Update packages/files-ui/src/Components/Modules/FileBrowsers/BinFileBrowser.tsx Co-authored-by: Tanmoy Basak Anjan <[email protected]> * fix lint * move file update * lint and installs * Update packages/files-ui/src/Components/Modules/FileBrowsers/MoveFileModal.tsx Co-authored-by: Thibaut Sardan <[email protected]> * Update packages/files-ui/src/Components/Modules/FileBrowsers/MoveFileModal.tsx Co-authored-by: Thibaut Sardan <[email protected]> * Update packages/files-ui/src/locales/fr/messages.po Co-authored-by: Thibaut Sardan <[email protected]> * Update packages/files-ui/src/Components/Modules/FileBrowsers/MoveFileModal.tsx Co-authored-by: Thibaut Sardan <[email protected]> * Update packages/files-ui/src/locales/fr/messages.po Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Michael Yankelev <[email protected]> Co-authored-by: Michael Yankelev <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> * Update file management ui tests (#1113) * Fix mistake * Update homepage page object and file management tests * Fix typo in test identifier * update homePage object * use api client in tests * fix detached from the Dom (#1096) Co-authored-by: Thibaut Sardan <[email protected]> * wip * Increase cypress page load timeout * Rename element and update page object * Update file management ui tests * Remove white space Co-authored-by: Thibaut Sardan <[email protected]> * Revert to default page load timeout Co-authored-by: Michael Yankelev <[email protected]> Co-authored-by: Michael Yankelev <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> * Wording for backup **secret** phrase (#1116) * wording for secret phrase * lingui extract * Update packages/files-ui/src/locales/fr/messages.po Co-authored-by: GitHub Actions <[email protected]> * CIDs overview (#1117) * wip * v1.14 * v1.15-rc1 * show Cids * buckets in nav bar * cleanup * cid instead of pin * in menus * login on refresh - storage ui (#1109) * with local storage * local or session * v2 api spec * v2.1 Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Tanmoy Basak Anjan <[email protected]> * Put eslint at top level since it's shared by all packages (#1115) * eslint at top level * fix lint Co-authored-by: Michael Yankelev <[email protected]> * Allow to unpin a Cid (#1110) * wip * v1.14 * v1.15-rc1 * show Cids * buckets in nav bar * cleanup * cid instead of pin * in menus * unpin and styling * lint * eslint 6.8 to make react-script happy (#1121) * Add identifier for the upload status box (#1122) Co-authored-by: Thibaut Sardan <[email protected]> * tkey address in settings (#1112) * key address added * lingui extract * Update packages/files-ui/src/Components/Modules/Settings/Profile.tsx Co-authored-by: Thibaut Sardan <[email protected]> * Update packages/files-ui/src/Components/Modules/Settings/Profile.tsx Co-authored-by: Michael Yankelev <[email protected]> * Update packages/files-ui/src/Components/Modules/Settings/Profile.tsx Co-authored-by: Michael Yankelev <[email protected]> * lingui extract * renames Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Michael Yankelev <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> * Force refresh on buckets when deleting from bin (#1127) * Force refresh * Liniting * Linting * Added to upload * Copied across styling (#1125) Co-authored-by: Thibaut Sardan <[email protected]> * Dnd Fix destination path (#1118) * fix destination path * Implement suggestion Co-authored-by: Thibaut Sardan <[email protected]> * Handle walletconnect signature request (#1124) * handle walletconnect signature request * Update packages/files-ui/src/Contexts/ThresholdKeyContext.tsx Co-authored-by: Ryan Noble <[email protected]> * fix lint Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Ryan Noble <[email protected]> * Remove Facebook login (#1136) * hide facebook login * lingui extract Co-authored-by: GitHub Actions <[email protected]> * email button disabled like others (#1137) Co-authored-by: Shiva <[email protected]> Co-authored-by: Cindy Chau <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Tanmoy Basak Anjan <[email protected]> Co-authored-by: Andrew Snaith <[email protected]> Co-authored-by: Thibaut Sardan <[email protected]> Co-authored-by: Priom Chowdhury <[email protected]> Co-authored-by: Ryan Noble <[email protected]>
Relates to #1079
What I changed
tests
Notes