Skip to content

Commit

Permalink
Merge branch 'main' into faris/misc-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
farisashai authored Jan 10, 2024
2 parents 7de251b + 6dd185c commit 7631a04
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 42 deletions.
21 changes: 9 additions & 12 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

# Info

Closes **[ISSUE NUMBER]**. (If there is no issue for this pull request yet, please create one or
delete this line if the pull request is for a very minor tweak).
Closes **[ISSUE NUMBER]**.

# Description

What changes did you make? List all distinct problems that this PR addresses. Explain any relevant
motivation or context.
<!-- If there is no issue for this pull request yet, please create one or
delete this line if the pull request is for a very minor tweak. -->

[description]

<!-- What changes did you make? List all distinct problems that this PR addresses. Explain any relevant
motivation or context. -->

## Changes

- [Fill in here]
Expand All @@ -33,21 +33,18 @@ motivation or context.
I have tested that my changes fully resolve the linked issue ...

- [ ] locally on Desktop.
- [ ] locally on mobile - use https://ngrok.io to get a copy on a mobile device
- [ ] on the live deployment preview on Desktop.
- [ ] on the live deployment preview on Mobile.
- [ ] I have run and passed all new and existing Cypress tests. Add screenshots below.
- [ ] I have added new Cypress tests that are passing.

# Checklist

- [ ] I have performed a self-review of my own code.
- [ ] I have followed the style guidelines of this project.
- [ ] I have documented my code's `src/lib` functions and commented hard to understand areas
- [ ] I have documented any new functions in `/src/lib/*` and commented hard to understand areas
anywhere else.
- [ ] My changes produce no new warnings.

# Screenshots

Please include a screenshot of your Cypress testing suite passing successfully.

If you made any visual changes to the website, please include relevant screenshots below.
<!-- If you made any visual changes to the website, please include relevant screenshots below. -->
18 changes: 18 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: E2E Cypress tests
on: push
jobs:
cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
# Install npm dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v6
env:
NEXT_PUBLIC_ACM_API_URL: https://testing.api.acmucsd.com/api/v2
with:
start: yarn dev:start
wait-on: 'http://localhost:3000'
install-command: yarn install
20 changes: 0 additions & 20 deletions cypress/e2e/pages/auth/login.cy.ts

This file was deleted.

30 changes: 30 additions & 0 deletions cypress/e2e/pages/forgot-password.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference types="cypress" />

describe('Forgot Password Page', () => {
beforeEach(() => {
cy.visit('/forgot-password');
});

it('Should fail with missing email', () => {
cy.contains('button', 'Submit').click();
cy.contains('p', 'Required').should('exist');
});

it('Should fail with unknown email', () => {
const email = '[email protected]';
cy.get('input[name="email"]').type(email);
cy.contains('button', 'Submit').click();

cy.get('.Toastify').contains('There is no account associated with that email').should('exist');
});

it('Should succeed with valid email', () => {
cy.fixture('accounts').then(({ standard }) => {
const { email } = standard;
cy.get('input[name="email"]').type(email);
cy.contains('button', 'Submit').click();

cy.get('.Toastify').contains('Success').should('exist');
});
});
});
79 changes: 79 additions & 0 deletions cypress/e2e/pages/login.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/// <reference types="cypress" />

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

it('Should succeed with valid member login', () => {
cy.fixture('accounts').then(({ standard }) => {
const { email, password } = standard;

cy.get('input[name="email"]').type(email);
cy.get('input[name="password"]').type(password);
cy.get('button').contains('Sign In').click();

cy.location('pathname').should('equal', '/');
cy.getCookie('ACCESS_TOKEN').should('exist');
});
});

it('Should succeed with valid admin login', () => {
cy.fixture('accounts').then(({ admin }) => {
const { email, password } = admin;

cy.get('input[name="email"]').type(email);
cy.get('input[name="password"]').type(password);
cy.get('button').contains('Sign In').click();

cy.location('pathname').should('equal', '/');
cy.getCookie('ACCESS_TOKEN').should('exist');
cy.getCookie('USER').should('exist');
});
});

it('Should fail with invalid credentials', () => {
const [email, password] = ['[email protected]', 'abc'];

cy.get('input[name="email"]').type(email);
cy.get('input[name="password"]').type(password);
cy.get('button').contains('Sign In').click();

cy.get('.Toastify').contains('Unable to login').should('exist');
cy.location('pathname').should('equal', '/login');
});

it('Should fail with missing username', () => {
cy.fixture('accounts').then(({ standard }) => {
const { password } = standard;

cy.get('input[name="password"]').type(password);
cy.get('button').contains('Sign In').click();

cy.location('pathname').should('equal', '/login');
cy.contains('p', 'Required').should('exist');
});
});

it('Should fail with missing password', () => {
cy.fixture('accounts').then(({ standard }) => {
const { email } = standard;

cy.get('input[name="email"]').type(email);
cy.get('button').contains('Sign In').click();

cy.location('pathname').should('equal', '/login');
cy.contains('p', 'Required').should('exist');
});
});

it('Should link to forgot password page', () => {
cy.get('a').contains('Forgot your password?').click();
cy.location('pathname').should('equal', '/forgot-password');
});

it('Should link to account register page', () => {
cy.get('a').contains('Sign Up').click();
cy.location('pathname').should('equal', '/register');
});
});
7 changes: 7 additions & 0 deletions cypress/e2e/pages/register.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="cypress" />

describe('Register Page', () => {
beforeEach(() => {
cy.visit('/register');
});
});
6 changes: 5 additions & 1 deletion cypress/fixtures/accounts.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"admin": {
"username": "[email protected]",
"email": "[email protected]",
"password": "password"
},
"standard": {
"email": "[email protected]",
"password": "password"
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint:fix": "yarn prettier && eslint --fix \"src/**/*.+(js|jsx|ts|tsx)\" && stylelint --fix \"**/*.scss\"",
"type-css": "yarn typed-scss-modules src/ --exportType default --logLevel silent --watch",
"dev": "yarn type-css & yarn lint && next dev",
"dev:start": "next dev",
"build": "next build",
"start": "next start",
"prod": "next build && next start",
Expand All @@ -31,7 +32,7 @@
"axios": "^1.6.0",
"axios-middleware": "^0.3.1",
"cookies-next": "^2.1.1",
"cypress": "^13.2.0",
"cypress": "13.6.2",
"ics": "^3.7.2",
"luxon": "^3.3.0",
"next": "^13.2.5-canary.30",
Expand All @@ -49,11 +50,11 @@
"validator": "^13.9.0"
},
"devDependencies": {
"@types/totp-generator": "^0.0.5",
"@types/lodash": "^4.14.191",
"@types/luxon": "^3.3.0",
"@types/node": "18.8.1",
"@types/react": "18.0.21",
"@types/totp-generator": "^0.0.5",
"@types/validator": "^13.7.14",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"eslint": "8.24.0",
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3572,10 +3572,10 @@ csstype@^3.0.2, csstype@^3.1.2:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b"
integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==

cypress@^13.2.0:
version "13.2.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.2.0.tgz#10f73d06a0764764ffbb903a31e96e2118dcfc1d"
integrity sha512-AvDQxBydE771GTq0TR4ZUBvv9m9ffXuB/ueEtpDF/6gOcvFR96amgwSJP16Yhqw6VhmwqspT5nAGzoxxB+D89g==
cypress@13.6.2:
version "13.6.2"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.2.tgz#c70df09db0a45063298b3cecba2fa21109768e08"
integrity sha512-TW3bGdPU4BrfvMQYv1z3oMqj71YI4AlgJgnrycicmPZAXtvywVFZW9DAToshO65D97rCWfG/kqMFsYB6Kp91gQ==
dependencies:
"@cypress/request" "^3.0.0"
"@cypress/xvfb" "^1.2.4"
Expand Down Expand Up @@ -4625,9 +4625,9 @@ flatted@^3.2.7:
integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==

follow-redirects@^1.15.0:
version "1.15.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==
version "1.15.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf"
integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==

for-each@^0.3.3:
version "0.3.3"
Expand Down

0 comments on commit 7631a04

Please sign in to comment.