Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: e2e-tests
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
test-by-cypress:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Install Dependencies
run: pnpm install

- name: Install Cypress
run: npx cypress install

- name: Cypress Info
run: pnpm exec cypress info

- name: Run Cypress tests
uses: cypress-io/github-action@v5
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
with:
start: npm run dev
wait-on: http://localhost:3000
continue-on-error: true

- name: Upload screenshots
uses: actions/upload-artifact@v4
with:
name: screenshots-headless-chrome
path: ./cypress/screenshots

- name: Check screenshot dimensions
run: npx image-size cypress/screenshots/**/*.png
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
9 changes: 9 additions & 0 deletions cypress/e2e/changelog.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Changelog Page', () => {
beforeEach(() => {
cy.visit('/changelog')
})

it('should display the main heading', () => {
cy.get('h1').should('be.visible')
})
})
9 changes: 9 additions & 0 deletions cypress/e2e/excalidraws.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Excalidraws Page', () => {
beforeEach(() => {
cy.visit('/excalidraws')
})

it('should display the main heading', () => {
cy.get('h1').should('be.visible')
})
})
20 changes: 20 additions & 0 deletions cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('Home Page', () => {
beforeEach(() => {
cy.visit('/')
})

it('should display the main heading', () => {
cy.get('h1').should('be.visible')
})

it('should have working navigation', () => {
// 检查导航链接是否存在
cy.get('nav').should('exist')
cy.get('nav a').should('have.length.at.least', 1)
})

// it('should load blog posts', () => {
// // 检查文章列表是否存在
// cy.get('article').should('exist')
// })
})
8 changes: 8 additions & 0 deletions cypress/e2e/reader.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('Reader', () => {
it('should be accessible and have correct content type', () => {
cy.request('/reader').then((response) => {
expect(response.status).to.eq(200)
expect(response.headers['content-type']).to.include('text/html')
})
})
})
10 changes: 10 additions & 0 deletions cypress/e2e/rss.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe('RSS', () => {
it('should be accessible and have correct content type', () => {
cy.request('/rss.xml').then((response) => {
expect(response.status).to.eq(200)
expect(response.headers['content-type']).to.include('application/rss+xml')
expect(response.body).to.include('<?xml')
expect(response.body).to.include('<rss')
})
})
})
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
17 changes: 17 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"scripts": {
"dev": "next dev -p 4000",
"dev": "next dev",
"build": "next build",
"start": "next start",
"format": "prettier --write .",
Expand Down Expand Up @@ -35,6 +35,7 @@
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"cypress": "^14.4.0",
"drizzle-kit": "^0.31.1"
}
}
Loading
Loading