Skip to content

Commit

Permalink
ci: unit & ui testing
Browse files Browse the repository at this point in the history
also:
 - migrate react-app to vite
 - remove react-scripts
 - common prettier config
  • Loading branch information
TobiTenno committed Apr 28, 2024
1 parent a7f87b5 commit b92dba9
Showing 70 changed files with 19,126 additions and 16,561 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- fix-4

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
defaults:
run:
working-directory: ${{ matrix.project }}
strategy:
matrix:
project:
- 'react-app'
- 'rest-api-with-express'
- 'rest-api-with-fastify'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: ${{ matrix.project }}/package-lock.json
- name: Install Dependencies
run: npm ci
- name: Run linters
run: npm run lint
test-ui:
name: Test (UI)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.project }}
strategy:
matrix:
browser:
- 'chrome'
project:
- 'react-app'
- 'rest-api-with-express'
- 'rest-api-with-fastify'
- 'html-web-page'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: ${{ matrix.project }}/package-lock.json
- name: Build for Cypress
uses: cypress-io/github-action@v6
with:
working-directory: ${{ matrix.project }}
build: npm run build -- --logLevel error
runTests: false
- name: Run Cypress
uses: cypress-io/github-action@v6
with:
working-directory: ${{ matrix.project }}
start: npm run start:built
browser: ${{ matrix.browser }}
install: false
- uses: actions/upload-artifact@master
if: failure()
with:
name: screenshots
path: ${{ matrix.project }}/cypress/screenshots
- uses: actions/upload-artifact@master
if: failure()
with:
name: videos
path: ${{ matrix.project }}/cypress/videos
test-unit:
name: Test (Unit)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.project }}
strategy:
matrix:
project:
- 'rest-api-with-express'
- 'rest-api-with-fastify'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: ${{ matrix.project }}/package-lock.json
- name: Install Dependencies
run: npm ci
- name: Run Unit Tests
run: npm test -- --reporter=xunit --reporter-options output=unit-tests.xml
- name: Report Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
${{ matrix.project }}/unit-tests.xml
7 changes: 7 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
singleQuote: true
quoteProps: as-needed
trailingComma: es5
bracketSpacing: true
arrowParens: always
printWidth: 120
semi: true
1 change: 1 addition & 0 deletions html-web-page/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public/romcal/*.js
8 changes: 8 additions & 0 deletions html-web-page/cypress.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
supportFile: false,
},
});
15 changes: 15 additions & 0 deletions html-web-page/cypress/e2e/load.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Load', () => {
it('should load the page', () => {
cy.visit('http://localhost:3000');
cy.get('h1').should('have.text', 'romcal v3');
cy.get('p').should('have.text', 'Open the developer tools and check the console.');

cy.get('#calendar').find('div').should('have.length', 2).as('messages');
cy.get('@messages').eq(0).should('have.text', 'All definitions, which are all possible liturgical days of a specific calendar, that can occur during a whole year:');
cy.get('@messages').eq(1).should('have.text', 'A calendar that contains all liturgical days occurring during 2024:');

cy.get('#calendar').find('pre').should('have.length', 2).as('codes');
cy.get('@codes').eq(0).should('include.text', 'mary_mother_of_god');
cy.get('@codes').eq(1).should('include.text', 'mary_mother_of_god');
});
});
Loading

0 comments on commit b92dba9

Please sign in to comment.