Skip to content
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bf23ff4
Add link sharing modal component
alyu201 Mar 8, 2022
fd15866
Added copy link to clipboard function
alyu201 Mar 8, 2022
596b620
Merge branch 'main' of https://github.com/alyu201/platform into featu…
alyu201 Mar 9, 2022
b7b1f76
testing adding component
akash744 Mar 9, 2022
dc11bcb
logic for sharing code
akash744 Mar 9, 2022
8986521
reminder to change expression
akash744 Mar 9, 2022
3457baa
Redirect user to sign in page for shared link
alyu201 Mar 9, 2022
1ef9dc4
Merge branch 'feature/sharing-link' of https://github.com/akash744/pl…
alyu201 Mar 10, 2022
6911db1
Merge branch 'main' of https://github.com/701-T4/platform
alyu201 Mar 11, 2022
0eaa955
Merge branch 'main' of https://github.com/701-T4/platform
alyu201 Mar 13, 2022
02fa0ea
Removed .vscode file
alyu201 Mar 13, 2022
bb5b44b
Merge branch 'main' of https://github.com/701-T4/platform
alyu201 Mar 13, 2022
d52695f
Cypress initial setup
alyu201 Mar 13, 2022
e934702
Merge branch 'main' of https://github.com/701-T4/platform into cypress
alyu201 Mar 14, 2022
e153b76
Add tests for routers
ywu666 Mar 14, 2022
6626e05
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 Mar 14, 2022
197142b
Remove .vscode files
alyu201 Mar 14, 2022
9cc1ad1
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 Mar 15, 2022
9b839bc
Added landing and signup page tests
alyu201 Mar 15, 2022
e28b61e
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
alyu201 Mar 15, 2022
eceb710
Added more test cases and tidied code up
alyu201 Mar 15, 2022
d614f69
Change the names of the file.
ywu666 Mar 15, 2022
5330b4e
Delete modal part.
ywu666 Mar 15, 2022
9b54201
Modified routing tests
alyu201 Mar 16, 2022
fd74e91
Add dashboard page tests and rename tests
alyu201 Mar 16, 2022
edea050
Adding tests to the manageaccount page.
ywu666 Mar 16, 2022
278dc6d
Merge branch 'main' into cypress
ywu666 Mar 16, 2022
785df6d
Let the branch match the main branch yarn.lock
ywu666 Mar 16, 2022
53d9de4
Add to frontend readme file
alyu201 Mar 16, 2022
787c122
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
alyu201 Mar 16, 2022
76fadc2
Fix bugs of account-management tests
ywu666 Mar 16, 2022
3f2b722
Merge main
frasermcc9 Mar 16, 2022
d9a897c
Remove eslint cache
frasermcc9 Mar 16, 2022
539bc4a
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
alyu201 Mar 16, 2022
43b37ee
Merge branch 'main' of https://github.com/701-T4/platform into cypress
alyu201 Mar 17, 2022
ab3d80d
Use data-cy to select elements
alyu201 Mar 18, 2022
df8a34c
Prevent redirects when house data is loading
frasermcc9 Mar 18, 2022
682613e
Delete the duplicate
ywu666 Mar 18, 2022
2e6d9b5
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 Mar 18, 2022
7a1f194
Merge main
frasermcc9 Mar 18, 2022
4812810
Increase some timings
frasermcc9 Mar 18, 2022
7af735d
Put the thing back, login another time to test join.
ywu666 Mar 19, 2022
d331a33
Merge branch 'cypress' of https://github.com/alyu201/platform into cy…
ywu666 Mar 19, 2022
53fdd62
Merge branch 'main' into cypress
ywu666 Mar 19, 2022
3eba4fb
Merge branch 'main' into cypress
ywu666 Mar 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 29 additions & 35 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ jobs:
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: 'javascript'
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: 'javascript'
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

Backend:
runs-on: ubuntu-latest
Expand All @@ -61,13 +61,10 @@ jobs:
run: yarn install --prefer-offline --frozen-lockfile
- name: Build
working-directory: ./packages/backend
run:
yarn build
run: yarn build
- name: Test
working-directory: ./packages/backend
run:
yarn test

run: yarn test

Frontend:
runs-on: ubuntu-latest
Expand All @@ -84,10 +81,7 @@ jobs:
run: yarn install --prefer-offline --frozen-lockfile
- name: Test
working-directory: ./packages/frontend
run:
yarn test
run: yarn test
- name: Build
working-directory: ./packages/frontend
run:
yarn build

run: yarn build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Please add IDE and OS specific files in a global gitignore on your system

node_modules
.vscode
.eslintcache
6,517 changes: 3,096 additions & 3,421 deletions LICENSE-3RD-PARTY.md

Large diffs are not rendered by default.

7,511 changes: 3,741 additions & 3,770 deletions packages/backend/LICENSE-3RD-PARTY.md

Large diffs are not rendered by default.

32,099 changes: 16,415 additions & 15,684 deletions packages/frontend/LICENSE-3RD-PARTY.md

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions packages/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,33 @@ Running with Docker will ensure that users can quickly get environment up and ru
2. Ensure you have Docker running. You can set it to run on device startup in Docker Desktop so you can forget about it. If you are unable to install Docker Desktop, you can use the command `dockerd` to start Docker.
3. Build the Docker image using `docker build -f Dockerfile -t frontend .`
4. Run `docker run -it -p 80:3000 frontend` to run the frontend in a docker container.

# Testing with Cypress

To start running tests, ensure Cypress is installed locally as a dev dependency.

```bash
$ yarn add cypress --dev
```

## Running tests

There are two methods to run frontend integration tests.

1. Run tests using Cypress Test Runner

```bash
$ yarn run cypress open
```

2. Run all tests from the command line

```bash
$ yarn run cypress run
```

## Configurations

Current configurations set Cypress to not take screenshots on test fails nor capture video of tests during `yarn run cypress run`.

To change or add to these configurations, modify `cypress.json`.
5 changes: 5 additions & 0 deletions packages/frontend/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:3000",
"video": false,
"screenshotOnRunFailure": false
}
5 changes: 5 additions & 0 deletions packages/frontend/cypress/fixtures/example.json
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"
}
22 changes: 22 additions & 0 deletions packages/frontend/cypress/integration/1.routes_spec.js
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 packages/frontend/cypress/integration/2.landing_page_spec.js
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.get('[data-cy="login-button"]').click();
cy.url().should('include', '/auth');
cy.contains('LOGIN');
});
});
125 changes: 125 additions & 0 deletions packages/frontend/cypress/integration/3.sign_in_page_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
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.get('[data-cy="switch-button"]').click();
});

// =============== Sign up tests =================
// clicking on 'already have an account' should switch to the login inputs
it('switches to login content', () => {
cy.get('[data-cy="switch-button"]').click();
cy.url().should('includes', 'auth');
cy.get('[data-cy="name-input"]').should('not.exist');
cy.get('[data-cy="switch-button"]').click();
});

// if no email given, warning
it('gives warning if no email given', () => {
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if email does not contain @ (invalid), warning
it('gives warning if invalid email is given', () => {
cy.get('[data-cy="email-input"]').type('example');
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if no passwords given, warning
it('gives warning if no password given', () => {
cy.get('[data-cy="email-input"]').clear().type(email);
cy.get('[data-cy="password-input"]').clear();
cy.get('[data-cy="confirm-input"]').clear();
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if password given is too weak, warning
it('gives warning if password is too weak', () => {
cy.get('[data-cy="password-input"]').clear().type('test');
cy.get('[data-cy="confirm-input"]').clear().type('test');
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if confirmation password does not match, warning
it('gives warning if passwords does not match', () => {
cy.get('[data-cy="password-input"]').clear().type('password');
cy.get('[data-cy="confirm-input"]').clear().type('passwrod');
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if email given and passwords match, no warning
it('successfully signs up', () => {
cy.get('[data-cy="confirm-input"]').clear().type('password');
cy.get('[data-cy="submit-button"]').click();
cy.wait(8000);
// 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('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if email does not contain @ (invalid), warning
it('gives warning if invalid email is given', () => {
cy.get('[data-cy="email-input"]').type('example');
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if no passwords given, warning
it('gives warning if no password given', () => {
cy.get('[data-cy="email-input"]').clear().type(email);
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if not a user, warning
it('gives warning if not a user', () => {
cy.get('[data-cy="email-input"]').clear().type('[email protected]');
cy.get('[data-cy="password-input"]').type('password');
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if incorrect password, warning
it('gives warning if incorrect password given', () => {
cy.get('[data-cy="email-input"]').clear().type(email);
cy.get('[data-cy="password-input"]').type('passwrod');
cy.get('[data-cy="submit-button"]').click();
cy.get('[data-cy="corner-alert"]').should('be.visible');
});

// if email and password correct, no warning
it('successfully logs in', () => {
cy.get('[data-cy="password-input"]').clear().type('password');
cy.get('[data-cy="submit-button"]').click();
cy.wait(8000);
// check that user should be redirected to their accounts page
cy.url().should('includes', '/account');
});
});
7 changes: 7 additions & 0 deletions packages/frontend/cypress/integration/4.login_spec.js
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.get('[data-cy="switch-button"]').click();
cy.get('[data-cy="name-input"]').should('exist');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
describe('Manage account page', () => {
const rand1 = Math.floor(Math.random() * (1000 - 0) + 0);
const rand2 = Math.floor(Math.random() * (2000 - 1000) + 1000);
const email1 = `test${rand1}@gmail.com`;
const email2 = `test${rand2}@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.get('[data-cy="switch-button"]').click();

cy.get('[data-cy="email-input"]').type(email1);
cy.get('[data-cy="password-input"]').clear().type('password');
cy.get('[data-cy="confirm-input"]').type('password');
cy.get('[data-cy="submit-button"]').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('[data-cy="create-button"]').click();
cy.get('[data-cy="create-house-modal"]').should('be.visible');
});

it('create house should close modal', () => {
cy.get('[data-cy="house-name-input"]').type(`test${rand1}`);
cy.get('[data-cy="house-address-input"]').type('test address');
cy.get('[data-cy="house-phone-input"]').type('021 123445');

cy.get('[data-cy="create-house-button"]').click();
//close the modal
cy.get('[data-cy="create-house-modal"]').should('not.be.visible');
});

it('initialise state - login to another account', () => {
//clear all local storage before tests
indexedDB.deleteDatabase('firebaseLocalStorageDb');

// Sign Up
cy.visit('/auth');
cy.get('[data-cy="switch-button"]').click();

cy.get('[data-cy="email-input"]').type(email2);
cy.get('[data-cy="password-input"]').clear().type('password');
cy.get('[data-cy="confirm-input"]').type('password');
cy.get('[data-cy="submit-button"]').click();
cy.wait(5000);

//direct users to the account page
cy.url().should('includes', '/account');
});

it('click join button should show the join house modal', () => {
cy.get('[data-cy="join-button"]').click();
cy.get('[data-cy="join-house-modal"]').should('be.visible');
});

it('submit house code should close the modal', () => {
cy.get('[data-cy="house-code-input"]').type(`test${rand1}`);
cy.get('[data-cy="join-house-button"]').click();
cy.get('[data-cy="join-house-modal"]').should('not.be.visible');
});
});
Loading