-
Notifications
You must be signed in to change notification settings - Fork 36
Frontend Cypress Test #94
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
Open
alyu201
wants to merge
45
commits into
701-T4:main
Choose a base branch
from
alyu201:cypress
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 34 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
bf23ff4
Add link sharing modal component
alyu201 fd15866
Added copy link to clipboard function
alyu201 596b620
Merge branch 'main' of https://github.com/alyu201/platform into featu…
alyu201 b7b1f76
testing adding component
akash744 dc11bcb
logic for sharing code
akash744 8986521
reminder to change expression
akash744 3457baa
Redirect user to sign in page for shared link
alyu201 1ef9dc4
Merge branch 'feature/sharing-link' of https://github.com/akash744/pl…
alyu201 6911db1
Merge branch 'main' of https://github.com/701-T4/platform
alyu201 0eaa955
Merge branch 'main' of https://github.com/701-T4/platform
alyu201 02fa0ea
Removed .vscode file
alyu201 bb5b44b
Merge branch 'main' of https://github.com/701-T4/platform
alyu201 d52695f
Cypress initial setup
alyu201 e934702
Merge branch 'main' of https://github.com/701-T4/platform into cypress
alyu201 e153b76
Add tests for routers
ywu666 6626e05
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 197142b
Remove .vscode files
alyu201 9cc1ad1
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 9b839bc
Added landing and signup page tests
alyu201 e28b61e
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
alyu201 eceb710
Added more test cases and tidied code up
alyu201 d614f69
Change the names of the file.
ywu666 5330b4e
Delete modal part.
ywu666 9b54201
Modified routing tests
alyu201 fd74e91
Add dashboard page tests and rename tests
alyu201 edea050
Adding tests to the manageaccount page.
ywu666 278dc6d
Merge branch 'main' into cypress
ywu666 785df6d
Let the branch match the main branch yarn.lock
ywu666 53d9de4
Add to frontend readme file
alyu201 787c122
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
alyu201 76fadc2
Fix bugs of account-management tests
ywu666 3f2b722
Merge main
frasermcc9 d9a897c
Remove eslint cache
frasermcc9 539bc4a
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
alyu201 43b37ee
Merge branch 'main' of https://github.com/701-T4/platform into cypress
alyu201 ab3d80d
Use data-cy to select elements
alyu201 df8a34c
Prevent redirects when house data is loading
frasermcc9 682613e
Delete the duplicate
ywu666 2e6d9b5
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 7a1f194
Merge main
frasermcc9 4812810
Increase some timings
frasermcc9 7af735d
Put the thing back, login another time to test join.
ywu666 d331a33
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 53fdd62
Merge branch 'main' into cypress
ywu666 3eba4fb
Merge branch 'main' into cypress
ywu666 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # Please add IDE and OS specific files in a global gitignore on your system | ||
|
|
||
| node_modules | ||
| .vscode | ||
| .eslintcache |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "baseUrl": "http://localhost:3000", | ||
| "video": false, | ||
| "screenshotOnRunFailure": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "Using fixtures to represent data", | ||
| "email": "[email protected]", | ||
| "body": "Fixtures are a great way to mock data for responses to routes" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //routers | ||
| describe('Routing', () => { | ||
| // On first start up, routes to / if not signed in | ||
| it('visits /', () => { | ||
| cy.visit('/'); | ||
| }); | ||
|
|
||
| // Routes to /auth if not signed in | ||
| it('visits /auth', () => { | ||
| cy.visit('/auth'); | ||
| }); | ||
|
|
||
| // On first start up, routes to /account if signed in and has no house | ||
| it('visits /account', () => { | ||
| cy.visit('/auth'); | ||
| }); | ||
|
|
||
| // On first start up, routes to /dashboard if signed in and has a house | ||
| it('visits /dashboard', () => { | ||
| cy.visit('/home'); | ||
| }); | ||
| }); |
13 changes: 13 additions & 0 deletions
13
packages/frontend/cypress/integration/2.landing_page_spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| describe('Landing page', () => { | ||
| // should route to / (landing page) | ||
| it('visits /', () => { | ||
| cy.visit('/'); | ||
| }); | ||
|
|
||
| // login button routes to login page, /auth | ||
| it('login button navigates to login page', () => { | ||
| cy.contains('Log In').click(); | ||
| cy.url().should('include', '/auth'); | ||
| cy.contains('LOGIN'); | ||
| }); | ||
| }); |
127 changes: 127 additions & 0 deletions
127
packages/frontend/cypress/integration/3.sign_in_page_spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| describe('Sign in page', () => { | ||
| const rand = Math.floor(Math.random() * (1000 - 100) + 100); | ||
| const email = `test${rand}@gmail.com`; | ||
|
|
||
| // clear all local storage before tests | ||
| // Should really perform resetting and seeding of database instead | ||
| beforeEach(() => { | ||
| indexedDB.deleteDatabase('firebaseLocalStorageDb'); | ||
| }); | ||
|
|
||
| // should route to /auth | ||
| it('should visits /auth', () => { | ||
| cy.visit('/auth'); | ||
| cy.contains('Click here to sign up').click(); | ||
| }); | ||
|
|
||
| // =============== Sign up tests ================= | ||
| // clicking on 'already have an account' should switch to the login inputs | ||
| it('switches to login content', () => { | ||
| cy.contains('Already have an account?').click(); | ||
| cy.url().should('includes', 'auth'); | ||
| cy.contains('LOGIN').should('be.visible'); | ||
| cy.contains('Click here to sign up').click(); | ||
| }); | ||
|
|
||
| // if no email given, warning | ||
| it('gives warning if no email given', () => { | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.contains('Please enter email').should('be.visible'); | ||
| }); | ||
|
|
||
| // if email does not contain @ (invalid), warning | ||
| it('gives warning if invalid email is given', () => { | ||
| cy.get('[aria-label="Email"]').type('example'); | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.contains('Please enter a valid email').should('be.visible'); | ||
| }); | ||
|
|
||
| // if no passwords given, warning | ||
| it('gives warning if no password given', () => { | ||
| cy.get('[aria-label="Email"]').clear().type(email); | ||
| cy.get('[aria-label="Password"]').clear(); | ||
| cy.get('[aria-label="Confirm password"]').clear(); | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.contains('Please enter password').should('be.visible'); | ||
| }); | ||
|
|
||
| // if password given is too weak, warning | ||
| it('gives warning if password is too weak', () => { | ||
| const win = cy.state('window'); | ||
| cy.get('[aria-label="Password"]').clear().type('test'); | ||
| cy.get('[aria-label="Confirm password"]').clear().type('test'); | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.contains('Please enter a stronger password').should('be.visible'); | ||
| }); | ||
|
|
||
| // if confirmation password does not match, warning | ||
| it('gives warning if passwords does not match', () => { | ||
| cy.get('[aria-label="Password"]').clear().type('password'); | ||
| cy.get('[aria-label="Confirm password"]').clear().type('passwrod'); | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.contains('Passwords must match').should('be.visible'); | ||
| }); | ||
|
|
||
| // if email given and passwords match, no warning | ||
| it('successfully signs up', () => { | ||
| cy.get('[aria-label="Confirm password"]').clear().type('password'); | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.wait(5000); | ||
| // check that user should be redirected to their accounts page | ||
| cy.url().should('includes', '/account'); | ||
| cy.wait(2000); | ||
| }); | ||
|
|
||
| // =============== Login tests ================= | ||
| // visit login | ||
| it('navigate back to login page', () => { | ||
| cy.visit('/auth'); | ||
| cy.wait(2000); | ||
| }); | ||
|
|
||
| // if no email given, warning | ||
| it('gives warning if no email given', () => { | ||
| cy.get('button').contains('Login').click(); | ||
| cy.contains('Please enter email').should('be.visible'); | ||
| }); | ||
|
|
||
| // if email does not contain @ (invalid), warning | ||
| it('gives warning if invalid email is given', () => { | ||
| cy.get('[aria-label="Email"]').type('example'); | ||
ywu666 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cy.get('button').contains('Login').click(); | ||
| cy.contains('Please enter a valid email').should('be.visible'); | ||
| }); | ||
|
|
||
| // if no passwords given, warning | ||
| it('gives warning if no password given', () => { | ||
| cy.get('[aria-label="Email"]').clear().type(email); | ||
| cy.get('[aria-label="Password"]'); | ||
| cy.get('button').contains('Login').click(); | ||
| cy.contains('Please enter password').should('be.visible'); | ||
| }); | ||
|
|
||
| // if not a user, warning | ||
| it('gives warning if not a user', () => { | ||
| cy.get('[aria-label="Email"]').clear().type('[email protected]'); | ||
| cy.get('[aria-label="Password"]').type('password'); | ||
| cy.get('button').contains('Login').click(); | ||
| cy.contains('No such user').should('be.visible'); | ||
| }); | ||
|
|
||
| // if incorrect password, warning | ||
| it('gives warning if incorrect password given', () => { | ||
| cy.get('[aria-label="Email"]').clear().type(email); | ||
| cy.get('[aria-label="Password"]').type('passwrod'); | ||
| cy.get('button').contains('Login').click(); | ||
| cy.contains('Wrong Password').should('be.visible'); | ||
| }); | ||
|
|
||
| // if email and password correct, no warning | ||
| it('successfully logs in', () => { | ||
| cy.get('[aria-label="Password"]').clear().type('password'); | ||
| cy.get('button').contains('Login').click(); | ||
| cy.wait(2000); | ||
| // check that user should be redirected to their accounts page | ||
| cy.url().should('includes', '/account'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| describe('Auth Page', () => { | ||
| it('move to signin page', () => { | ||
| cy.visit('/auth'); | ||
| cy.contains('Click here to sign up').click(); | ||
| cy.contains('SIGN UP'); | ||
| }); | ||
| }); |
50 changes: 50 additions & 0 deletions
50
packages/frontend/cypress/integration/5.manage_account_page_spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| describe('Manage account page', () => { | ||
| const rand = Math.floor(Math.random() * (1000 - 100) + 100); | ||
| const email = `test${rand}@gmail.com`; | ||
|
|
||
| it('initialise state - login to go to the authorised page', () => { | ||
| //clear all local storage before tests | ||
| indexedDB.deleteDatabase('firebaseLocalStorageDb'); | ||
|
|
||
| // Sign Up | ||
| cy.visit('/auth'); | ||
| cy.contains('Click here to sign up').click(); | ||
|
|
||
| cy.get('[aria-label="Email"]').type(email); | ||
| cy.get('[aria-label="Password"]').clear().type('password'); | ||
| cy.get('[aria-label="Confirm password"]').type('password'); | ||
| cy.get('button').contains('Sign Up').click(); | ||
| cy.wait(5000); | ||
|
|
||
| //direct users to the account page | ||
| cy.url().should('includes', '/account'); | ||
| }); | ||
|
|
||
| it('click create button will show the createHouse modal', () => { | ||
| cy.get('button').contains('CREATE').click(); | ||
| cy.contains('create your first flat').should('be.visible'); | ||
| }); | ||
|
|
||
| it('create house should close modal', () => { | ||
| cy.get('[aria-label="house name"]').type('test'); | ||
| cy.get('[aria-label="house address"]').type('test address'); | ||
| cy.get('[aria-label="phone number"]').type('021 123445'); | ||
|
|
||
| cy.get('button').contains('Create!').click(); | ||
| //close the modal | ||
| cy.contains('create your first flat').should('not.visible'); | ||
| }); | ||
|
|
||
| it('click join button should show the join house modal', () => { | ||
| cy.get('button').contains('JOIN').click(); | ||
| cy.contains('Enter House Code').should('be.visible'); | ||
| }); | ||
|
|
||
| it('submit house code should close the modal', () => { | ||
| cy.get('[aria-label="House Code"]').type('test'); | ||
| cy.get('button').contains('Submit').click(); | ||
|
|
||
| cy.contains('Enter House Code').should('not.visible'); | ||
| cy.contains('Joining the house...').should('be.visible'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.