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

Cypress - Frontend Tests Integration [WIP] #479

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e84c286
some
pratyush1712 Dec 9, 2022
7a9d7f2
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Jan 29, 2023
b8f3211
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Feb 6, 2023
8ac410a
switched to crypto-js as crypto is a node module
pratyush1712 Feb 6, 2023
1af1aa2
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Feb 18, 2023
758bba0
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Mar 4, 2023
26220c3
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Mar 7, 2023
0bf9ccb
fixed removing aria-descibedby in production
pratyush1712 Mar 7, 2023
d2d16dc
remove console.log
pratyush1712 Mar 7, 2023
746e675
fixed notification design
pratyush1712 Mar 8, 2023
6090796
reverting back to usage of Carriage initials
pratyush1712 Mar 8, 2023
e01d2dc
delete mock test data
pratyush1712 Mar 8, 2023
5cc9d41
compress
pratyush1712 Mar 8, 2023
a6f78be
remoce unused useId
pratyush1712 Mar 8, 2023
154e934
Merge branch 'master' into pratyush/notification-design
pratyush1712 May 18, 2023
cdffcce
save
pratyush1712 Aug 16, 2023
9103855
Merge branch 'pratyush/notification-design' of https://github.com/cor…
pratyush1712 Oct 1, 2023
ee8d640
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Oct 22, 2023
6160061
Merge branch 'master' of https://github.com/cornell-dti/carriage-web
pratyush1712 Nov 1, 2023
26486bf
first step
pratyush1712 Nov 4, 2023
7810ce3
added tests for the landing page
pratyush1712 Nov 7, 2023
d94c206
resolve lint issues
pratyush1712 Nov 7, 2023
9a84046
Documentation Updates:
pratyush1712 Nov 13, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/ci-backend-test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI Test
on:
name: CI Backend Test
on:
pull_request:
paths: ['server/**']

jobs:
build:
run-tests:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/ci-frontend-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI Frontend Test
on:
pull_request:
paths: ['frontend/**']
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run
uses: cypress-io/github-action@v6
with:
start: npm start
wait-on: 'http://localhost:3000'
record: true
parallel: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@ Carriage documentation is located at our [Notion](https://dti-carriage.notion.si

Want to run this locally? From our [Useful Commands page](https://dti-carriage.notion.site/Useful-Commands-b20422d052b444d396b04a6df4debc07).
After cloning the repository, run:
`npm run install:server`
`npm run install:frontend`
`npm run start:server`
`npm run start:frontend`
This will start an instance running locally.
`npm run install:server`: It will install all dependencies for the backend. (Useful if you are only working on the backend).

`npm run install:frontend`: It will install all dependencies for the frontend. (Useful if you are only working on the frontend).

`npm run install`: It will install all dependencies for both the frontend and backend.

`npm run start:server`: It will start the backend server.

`npm run start:frontend`: It will start the frontend server.

`npm run start`: It will start both the backend and frontend servers.
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be tripping but I don't see this defined in /package.json?


`npm run test:server`: It will run all tests for the backend.

`npm run test:frontend`: It will run all tests for the frontend.

`npm run test`: It will run all tests for both the backend and frontend.

## About

Expand Down
10 changes: 10 additions & 0 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { defineConfig } from 'cypress';

export default defineConfig({
projectId: 'n22mn9',
video: false,
e2e: {
baseUrl: 'http://localhost:3000',
},
});
58 changes: 58 additions & 0 deletions frontend/cypress/e2e/homepage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/// <reference types="cypress" />

describe('Landing Page', () => {
beforeEach(() => {
cy.visit('/');
});

it('successfully loads', () => {
cy.get('[data-cy="home"]').should('be.visible');
});

it('has the correct title', () => {
cy.title().should('include', 'Login - Carriage');
});

it('has visible student and admin login buttons with correct text', () => {
cy.get('[data-cy="container_item_left"]')
.should('contain', 'Sign in with Google')
.and('contain', 'Students');
cy.get('[data-cy="container_item_right"]')
.should('contain', 'Sign in with Google')
.and('contain', 'Admins');
});

it('has a visible logo for both student and admin buttons', () => {
cy.get('[data-cy="badge"]').should('have.attr', 'alt', 'Carriage logo');
cy.get('[data-cy="container_item_left"] img').should(
'have.attr',
'alt',
'google logo'
);
cy.get('[data-cy="container_item_right"] img').should(
'have.attr',
'alt',
'google logo'
);
});

it('student login button triggers the correct function', () => {
// Spy on 'studentLogin' function
// const spy = cy.spy().as('studentLoginSpy');
// cy.window().then((win) => {
// // win.studentLogin = spy;
// });
// cy.get('[data-cy="container_item_left"] .btn').click();
// cy.get('@studentLoginSpy').should('have.been.calledOnce');
});

it('admin login button triggers the correct function', () => {
// Spy on 'adminLogin' function
// const spy = cy.spy().as('adminLoginSpy');
// cy.window().then((win) => {
// // win.adminLogin = spy;
// });
// cy.get('[data-cy="container_item_right"] .btn').click();
// cy.get('@adminLoginSpy').should('have.been.calledOnce');
});
});
5 changes: 5 additions & 0 deletions 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": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
5 changes: 5 additions & 0 deletions frontend/cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": 8739,
"name": "Jane",
"email": "jane@example.com"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: eof should be line break

232 changes: 232 additions & 0 deletions frontend/cypress/fixtures/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
}
},
{
"id": 3,
"name": "Clementine Bauch",
"username": "Samantha",
"email": "Nathan@yesenia.net",
"address": {
"street": "Douglas Extension",
"suite": "Suite 847",
"city": "McKenziehaven",
"zipcode": "59590-4157",
"geo": {
"lat": "-68.6102",
"lng": "-47.0653"
}
},
"phone": "1-463-123-4447",
"website": "ramiro.info",
"company": {
"name": "Romaguera-Jacobson",
"catchPhrase": "Face to face bifurcated interface",
"bs": "e-enable strategic applications"
}
},
{
"id": 4,
"name": "Patricia Lebsack",
"username": "Karianne",
"email": "Julianne.OConner@kory.org",
"address": {
"street": "Hoeger Mall",
"suite": "Apt. 692",
"city": "South Elvis",
"zipcode": "53919-4257",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "493-170-9623 x156",
"website": "kale.biz",
"company": {
"name": "Robel-Corkery",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
},
{
"id": 5,
"name": "Chelsey Dietrich",
"username": "Kamren",
"email": "Lucio_Hettinger@annie.ca",
"address": {
"street": "Skiles Walks",
"suite": "Suite 351",
"city": "Roscoeview",
"zipcode": "33263",
"geo": {
"lat": "-31.8129",
"lng": "62.5342"
}
},
"phone": "(254)954-1289",
"website": "demarco.info",
"company": {
"name": "Keebler LLC",
"catchPhrase": "User-centric fault-tolerant solution",
"bs": "revolutionize end-to-end systems"
}
},
{
"id": 6,
"name": "Mrs. Dennis Schulist",
"username": "Leopoldo_Corkery",
"email": "Karley_Dach@jasper.info",
"address": {
"street": "Norberto Crossing",
"suite": "Apt. 950",
"city": "South Christy",
"zipcode": "23505-1337",
"geo": {
"lat": "-71.4197",
"lng": "71.7478"
}
},
"phone": "1-477-935-8478 x6430",
"website": "ola.org",
"company": {
"name": "Considine-Lockman",
"catchPhrase": "Synchronised bottom-line interface",
"bs": "e-enable innovative applications"
}
},
{
"id": 7,
"name": "Kurtis Weissnat",
"username": "Elwyn.Skiles",
"email": "Telly.Hoeger@billy.biz",
"address": {
"street": "Rex Trail",
"suite": "Suite 280",
"city": "Howemouth",
"zipcode": "58804-1099",
"geo": {
"lat": "24.8918",
"lng": "21.8984"
}
},
"phone": "210.067.6132",
"website": "elvis.io",
"company": {
"name": "Johns Group",
"catchPhrase": "Configurable multimedia task-force",
"bs": "generate enterprise e-tailers"
}
},
{
"id": 8,
"name": "Nicholas Runolfsdottir V",
"username": "Maxime_Nienow",
"email": "Sherwood@rosamond.me",
"address": {
"street": "Ellsworth Summit",
"suite": "Suite 729",
"city": "Aliyaview",
"zipcode": "45169",
"geo": {
"lat": "-14.3990",
"lng": "-120.7677"
}
},
"phone": "586.493.6943 x140",
"website": "jacynthe.com",
"company": {
"name": "Abernathy Group",
"catchPhrase": "Implemented secondary concept",
"bs": "e-enable extensible e-tailers"
}
},
{
"id": 9,
"name": "Glenna Reichert",
"username": "Delphine",
"email": "Chaim_McDermott@dana.io",
"address": {
"street": "Dayna Park",
"suite": "Suite 449",
"city": "Bartholomebury",
"zipcode": "76495-3109",
"geo": {
"lat": "24.6463",
"lng": "-168.8889"
}
},
"phone": "(775)976-6794 x41206",
"website": "conrad.com",
"company": {
"name": "Yost and Sons",
"catchPhrase": "Switchable contextually-based project",
"bs": "aggregate real-time technologies"
}
},
{
"id": 10,
"name": "Clementina DuBuque",
"username": "Moriah.Stanton",
"email": "Rey.Padberg@karina.biz",
"address": {
"street": "Kattie Turnpike",
"suite": "Suite 198",
"city": "Lebsackbury",
"zipcode": "31428-2261",
"geo": {
"lat": "-38.2386",
"lng": "57.2232"
}
},
"phone": "024-648-3804",
"website": "ambrose.net",
"company": {
"name": "Hoeger LLC",
"catchPhrase": "Centralized empowering task-force",
"bs": "target end-to-end models"
}
}
]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: eof should be line break

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading