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

v1.0.7 Release #39

Merged
merged 29 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0d3598b
Merge pull request #26 from Codespice1/staging
D-Antonelli Aug 12, 2024
e82a46a
Update bug_report.md
D-Antonelli Aug 12, 2024
c6df3b9
Update bug_report.md
D-Antonelli Aug 12, 2024
499d48e
Update bug_report.md
D-Antonelli Aug 12, 2024
acc5827
Update bug_report.md
D-Antonelli Aug 12, 2024
edcd875
Update bug_report.md
D-Antonelli Aug 12, 2024
bee2d6f
Update feature_request.md
D-Antonelli Aug 12, 2024
37c4d26
configures e2e tests, redirection
D-Antonelli Aug 14, 2024
f76b3c1
installs cypress
D-Antonelli Aug 14, 2024
74cc91b
fixes ts type error
D-Antonelli Aug 14, 2024
226279b
configures spec access for CI
D-Antonelli Aug 14, 2024
bb87edd
updates url path
D-Antonelli Aug 14, 2024
b2dc21f
removes commented lines
D-Antonelli Aug 14, 2024
b8c8c48
Merge pull request #31 from Codespice1/D-Antonelli/feature/#25-Run-an…
D-Antonelli Aug 19, 2024
863a9bc
writes first playwright test
D-Antonelli Aug 19, 2024
cace934
updates playwright CI
D-Antonelli Aug 19, 2024
d7ba897
removes demo test
D-Antonelli Aug 19, 2024
791e879
starts localhost on test run
D-Antonelli Aug 19, 2024
add50c1
updates CI
D-Antonelli Aug 19, 2024
10b9edd
updates config
D-Antonelli Aug 19, 2024
93f87fe
sets up base url
D-Antonelli Aug 19, 2024
f7f7cea
updates test
D-Antonelli Aug 19, 2024
26fb9ab
excludes playwright folders from jest
D-Antonelli Aug 19, 2024
9cd991e
updates workflow
D-Antonelli Aug 19, 2024
a18da38
updates main.yml
D-Antonelli Aug 19, 2024
be84fc9
updates main.yml
D-Antonelli Aug 19, 2024
8446fde
Merge pull request #35 from Codespice1/D-Antonelli/feature/#32-Playwr…
D-Antonelli Aug 21, 2024
2ab2caf
version upgrade
D-Antonelli Aug 27, 2024
44424e1
Merge pull request #38 from Codespice1/D-Antonelli/feature/#33-BUG-Si…
D-Antonelli Aug 28, 2024
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
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
title: '[BUG] '
labels:
- "🐞 goal: bugfix"
assignees: ''

---
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
title: '[FEATURE] '
labels: '⭐️ goal: new feature'
assignees: ''

---
Expand Down
94 changes: 76 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,99 @@ on:
[push]

jobs:
build_and_test:
# Job for installing dependencies and linting code
Lint:
runs-on: ubuntu-latest
timeout-minutes: 5

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.14.0'
cache: 'npm'
node-version: 20

- name: Install dependencies
run: npm install
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Build the Next.js application
env:
STRIPE_KEY: ${{ secrets.STRIPE_KEY }}
NEXTAUTH_URL: ${{secrets.NEXTAUTH_URL}}
NEXTAUTH_SECRET: ${{secrets.NEXTAUTH_SECRET}}
AUTH_GITHUB_ID: ${{secrets.AUTH_GITHUB_ID}}
AUTH_GITHUB_SECRET: ${{secrets.AUTH_GITHUB_SECRET}}
GOOGLE_CLIENT_ID: ${{secrets.GOOGLE_CLIENT_ID}}
GOOGLE_CLIENT_SECRET: ${{secrets.GOOGLE_CLIENT_SECRET}}
run: npm run build --if-present
- name: Install dependencies
run: npm ci

- name: Code linting
run: npm run lint

- name: Run tests and collect coverage
# Job for building and running tests
End-to-end-Tests:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cypress run
uses: cypress-io/github-action@v6
env:
NEXTAUTH_URL: ${{secrets.NEXTAUTH_URL}}
STRIPE_KEY: ${{ secrets.STRIPE_KEY }}
NEXTAUTH_SECRET: ${{secrets.NEXTAUTH_SECRET}}
AUTH_GITHUB_ID: ${{secrets.AUTH_GITHUB_ID}}
AUTH_GITHUB_SECRET: ${{secrets.AUTH_GITHUB_SECRET}}
GOOGLE_CLIENT_ID: ${{secrets.GOOGLE_CLIENT_ID}}
GOOGLE_CLIENT_SECRET: ${{secrets.GOOGLE_CLIENT_SECRET}}
with:
build: npm run build
start: npm start
spec: |
cypress/e2e/*.cy.ts

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright tests
run: npx playwright test

- name: Upload Playwright Report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 30

# Job for running unit tests and uploading coverage report
Unit-Tests:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test

- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ next-env.d.ts
.vscode/tasks.json
/certificates/*
cypress.env.json
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default defineConfig({
chromeWebSecurity: false,

e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.ts')(on, config)
},
Expand Down
14 changes: 14 additions & 0 deletions cypress/e2e/auth/dashboard_access.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe("Accessing Dashboard Page With Authentication", () => {
beforeEach(() => {
cy.stubGoogleLogin();
});

it('Should display dashboard', () => {
cy.get("[data-cy='authenticated']")
.should("exist")
.then(() => {
cy.log("Cypress login successful");
});
})
});

10 changes: 10 additions & 0 deletions cypress/e2e/dashboard_access.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe("Accessing Dashboard Page Without Authentication", () => {
it("should redirect to the login page if user is not authenticated", () => {
cy.visit("/dashboard");

cy.url().should("include", "api/auth/signin");

cy.get("button").should("contain.text", "Sign in with Google");
});
});

48 changes: 0 additions & 48 deletions cypress/e2e/google-login.cy.ts

This file was deleted.

9 changes: 9 additions & 0 deletions cypress/e2e/redirect_to_login.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe("Redirection to Sign-In Page", () => {
it("should redirect unauthenticated user from root url to sign-in page", () => {
cy.visit("/");

cy.url().should("include", "/api/auth/signin");

cy.get("button").should("contain.text", "Sign in with Google");
});
});
5 changes: 0 additions & 5 deletions cypress/e2e/spec.cy.ts

This file was deleted.

9 changes: 9 additions & 0 deletions cypress/fixtures/session.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"user": {
"name": "Morty Smith",
"email": "[email protected]",
"image": "/path/to/your/mock/user.jpg"
},
"expires": "3000-01-01T00:00:00.000Z",
"accessToken": "abcdefghijklmnopqrst"
}
9 changes: 9 additions & 0 deletions cypress/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare namespace Cypress {
// noinspection JSUnusedGlobalSymbols
interface Chainable {
/**
* Logs in via the next-auth session cookie for the JWT strategy ONLY!
*/
stubGoogleLogin(): Chainable<any>;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions cypress/support/auth-provider-commands/next-auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Cypress.Commands.add("stubGoogleLogin", () => {
Cypress.log({
displayName: "STUB GOOGLE LOGIN",
message: [`🔐 Authenticating`],
});

cy.intercept("/api/auth/session", {fixture: "session.json"}).as("session");

cy.setCookie("next-auth.session-token", Cypress.env("NEXTAUTH_JWT_SECRET"));
cy.visit("/dashboard");
cy.wait("@session");
});
5 changes: 4 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }

// Import commands for third-party auth providers
import "./auth-provider-commands/next-auth";
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const config: Config = {

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
modulePathIgnorePatterns: ["playwright"],

// The test environment that will be used for testing
testEnvironment: "jsdom",
Expand Down
Loading