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

Initial page object implementation #1080

Merged
merged 31 commits into from
Jun 2, 2021

Conversation

asnaith
Copy link
Contributor

@asnaith asnaith commented May 31, 2021

Relates to #1079

What I changed

  • Renamed the integration folder that the tests reside in to tests
  • Created new page object classes, this will be the place where we declare selectors for a page's unique elements. It will help make tests more readable and easier to update element identifiers.
  • Added more unique element identifiers
  • Updated the settings tests to use page objects
  • Added basic tests for main navigation

Notes

  • Apologies for the "several things at once" PR. It just made sense for this initial PR to be done together
  • Did not update file-management.ts yet, can be worked on in a separate PR

@asnaith asnaith added the Testing Added to issues to signal that it is part of an epic label May 31, 2021
@asnaith asnaith requested review from tanmoyAtb, FSM1 and Tbaut May 31, 2021 22:31
@render
Copy link

render bot commented May 31, 2021

@asnaith
Copy link
Contributor Author

asnaith commented May 31, 2021

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?

@Tbaut
Copy link
Collaborator

Tbaut commented Jun 1, 2021

Renamed the integration folder that the tests reside in to tests

This seems to be a convention for Cypress, which I took the template from. I don't really mind tbh, "tests" is fine.

It might make sense to append all of our test files with with "-test"

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 new Class() at the top of each test.

Copy link
Collaborator

@Tbaut Tbaut left a 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

packages/files-ui/cypress/support/page-objects/BinPage.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,8 @@
export const landingPage = {
web3Button: () => cy.get("[data-cy=web3]"),
Copy link
Collaborator

@Tbaut Tbaut Jun 1, 2021

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.

Copy link
Contributor Author

@asnaith asnaith Jun 1, 2021

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.

Copy link
Contributor

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

Copy link
Collaborator

@Tbaut Tbaut Jun 2, 2021

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.

Copy link
Contributor Author

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 :)

@Tbaut Tbaut added Status: Changes Requested ❌ Added to PRs that require further changes from the contributor. and removed Testing Added to issues to signal that it is part of an epic labels Jun 1, 2021
@asnaith
Copy link
Contributor Author

asnaith commented Jun 1, 2021

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?

I've gone ahead and appended "spec" to the test file names.

Copy link
Contributor

@FSM1 FSM1 left a 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.

Copy link
Collaborator

@Tbaut Tbaut left a 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(() => {
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed :)

packages/files-ui/cypress/tests/main-navigation-spec.ts Outdated Show resolved Hide resolved
})

context("mobile", () => {
beforeEach(() => {
Copy link
Collaborator

@Tbaut Tbaut Jun 2, 2021

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

Copy link
Contributor Author

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.

packages/files-ui/cypress/tests/settings-spec.ts Outdated Show resolved Hide resolved
@Tbaut
Copy link
Collaborator

Tbaut commented Jun 2, 2021

FYI, I just saw the test failing for "can rename a file with error handling".. it didn't fail locally and relaunching was fine, also a hint, for anyone following this conversation, to know where to find the screenshot when a test fails:
image

screenshot:
File management -- desktop -- can rename a file with error handling (failed)

@asnaith asnaith merged commit d07af28 into dev Jun 2, 2021
@asnaith asnaith deleted the mnt/initial-page-object-implementation-1079 branch June 2, 2021 21:34
@FSM1 FSM1 mentioned this pull request Jun 15, 2021
FSM1 added a commit that referenced this pull request Jun 15, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Changes Requested ❌ Added to PRs that require further changes from the contributor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants