Skip to content

Commit

Permalink
fix a bunch of files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1618 committed Jan 20, 2024
1 parent af33c8f commit e5abdb6
Show file tree
Hide file tree
Showing 14 changed files with 220 additions and 49 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"plugins": ["prettier", "node", "@typescript-eslint", "import", "jsdoc"],
"rules": {
"prettier/prettier": "error",
"no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_$" }],
"no-console": "error",
"func-names": "off",
"no-process-exit": "off",
Expand Down Expand Up @@ -38,5 +38,10 @@
}
]
},
"ignorePatterns": "src/**/*.d.ts"
"ignorePatterns": [
"src/**/*.d.ts",
"**/public/sw.js",
"**/public/workbox-*.js",
"**/public/worker-*.js"
]
}
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @farisashai @raymosun @trevorkw7 @sheeptester
* @farisashai @raymosun @trevorkw7 @sheeptester @alexzhang1618
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
13 changes: 0 additions & 13 deletions .github/workflows/label_ready_pr_to_merge.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
20 changes: 0 additions & 20 deletions cypress/e2e/pages/auth/login.cy.ts

This file was deleted.

Empty file.
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"
}
}
7 changes: 7 additions & 0 deletions cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"first": "John",
"last": "Doe",
"bio": "I am a testing account.",
"major": "Computer Engineering",
"year": "2026"
}
49 changes: 49 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
declare global {
namespace Cypress {
interface Chainable {
/**
* Log in as the specified user, pulling details from accounts.json
* @example cy.login('standard')
*/
login(account: string): Chainable<void>;

/**
* Type text into a form input or textarea under specified label
* @param label - text of label that the input is a child of
* @param value - text to be typed into input
*/
typeInForm(label: string, value: string): Chainable<void>;

/**
* Select the given option in a select under specified label
* @param label - text of label that the select is a child of
* @param value - option to be selected
*/
selectInForm(label: string, value: string): Chainable<void>;
}
}
}

Cypress.Commands.add('login', (account: string) => {
cy.fixture('accounts.json').then(accs => {
if (!(account in accs))
throw new Error(`Account '${account}' isn't specified in \`accounts.json\``);
const { email, password } = accs[account];

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

Cypress.Commands.add('typeInForm', (label: string, value: string) => {
cy.get(`label:contains("${label}") input, label:contains("${label}") textarea`).as('input');
cy.get('@input').clear();
cy.get('@input').type(value as string);
});

Cypress.Commands.add('selectInForm', (label: string, value: string | number) => {
cy.get(`label:contains("${label}") select`).select(value);
});

export {};

0 comments on commit e5abdb6

Please sign in to comment.