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

Updated eslint configuration, footer changes, unit tests, edit dialog #15

Merged
merged 21 commits into from
Jun 9, 2023
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
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_VERCEL_GIT_COMMIT_SHA=test
VITE_VERCEL_ENV=test
45 changes: 0 additions & 45 deletions .eslintrc

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Check PR

on:
pull_request:
branches:
- master

jobs:
lint:
name: 'Run lint'
uses: ./.github/workflows/run-lint.yml
tests:
name: 'Run tests'
uses: ./.github/workflows/run-tests.yml
build:
name: 'Run tsc'
uses: ./.github/workflows/run-tsc.yml
# vercel:
# name: 'Run vercel build'
# needs: ['lint', 'tests', 'build']
# uses: ./.github/workflows/run-vercel.yml
# secrets:
# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
# with:
# deploy: true
# branch: ${{ github.ref_name }}
# create-deployment:
# name: 'Create github deployment'
# needs: 'vercel'
# runs-on: ubuntu-latest
# env:
# GITHUB_SLUG: ${{ github.repository }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PR_ID: ${{ github.event.pull_request.id }}
# PR_COMMIT: ${{ github.sha }}
# steps:
# - run: gh api --method POST -H "Accept: application/vnd.github+json" "/repos/$GITHUB_SLUG/deployments" -f ref=
29 changes: 29 additions & 0 deletions .github/workflows/deploy-master.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy master

on:
push:
branches:
- master

jobs:
lint:
name: 'Run lint'
uses: ./.github/workflows/run-lint.yml
tests:
name: 'Run tests'
uses: ./.github/workflows/run-tests.yml
build:
name: 'Run tsc'
uses: ./.github/workflows/run-tsc.yml
vercel:
name: 'Run vercel build'
needs: ['lint', 'tests', 'build']
uses: ./.github/workflows/run-vercel.yml
secrets:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deploy: true
prod: true
branch: ${{ github.ref_name }}
18 changes: 18 additions & 0 deletions .github/workflows/run-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run lint

on:
workflow_call

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Run tests

on:
pull_request:
branches:
- master
workflow_call

jobs:
test:
tests:
runs-on: ubuntu-latest

steps:
Expand All @@ -17,8 +15,6 @@ jobs:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn tsc --noEmit
# todo: eslint
- run: yarn coverage
- name: Archive code coverage results
uses: actions/upload-artifact@v3
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/run-tsc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run tsc

on:
workflow_call

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn tsc --noEmit
58 changes: 58 additions & 0 deletions .github/workflows/run-vercel.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Run vercel build

on:
workflow_call:
inputs:
deploy:
description: 'Deploy to vercel'
required: false
type: boolean
prod:
description: 'Deploy as prod'
required: false
type: boolean
branch:
description: 'Branch being built'
required: true
type: string
outputs:
deployment-url:
description: "Deployment URL"
value: ${{ jobs.vercel.outputs.deployment-url }}
secrets:
VERCEL_ORG_ID:
description: 'VERCEL_ORG_ID'
required: true
VERCEL_PROJECT_ID:
description: 'VERCEL_PROJECT_ID'
required: true
VERCEL_TOKEN:
description: 'VERCEL_TOKEN'
required: true

jobs:
vercel:
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
outputs:
deployment-url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile
- name: Install Vercel CLI
run: yarn global add vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=${{ inputs.prod && 'production' || 'preview' }} --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build ${{ inputs.prod && '--prod' || '' }} --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
id: deploy
if: ${{ inputs.deploy }}
run: echo url=$(vercel deploy --prebuilt ${{ inputs.prod && '--prod' || '' }} --token=${{ secrets.VERCEL_TOKEN }})
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/dev-dist

# production
/dev-dist
/dist

# misc
Expand Down
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"vitest.enable": true,
"vitest.commandLine": "yarn test --"
"vitest.enable": true,
"vitest.commandLine": "yarn test --"
}
67 changes: 67 additions & 0 deletions api/__tests__/__snapshots__/metadata.test.ts.snap

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions api/__tests__/metadata.parseManifest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* eslint-disable object-curly-newline */
import type { WebAppManifest } from 'web-app-manifest';

import { parseManifest } from '@@api/metadata/_parseManifest';


describe('api/manifest/parseManifest', () => {
it.each<Pick<WebAppManifest, 'icons'>>([
{
icons: undefined
},
{
icons: []
}
])('should return null', ({ icons }) => {
expect(parseManifest({ icons }, 'https://example.com/path/file')).toBeNull();
});

it.each<Pick<WebAppManifest, 'icons'> & { expected: string }>([
{
icons: [{ src: 'icon.png' }],
expected: 'https://example.com/path/icon.png'
},
{
icons: [{ src: '/icon.png' }],
expected: 'https://example.com/icon.png'
},
{
icons: [{ src: 'https://cdn.example.com/icon.png' }],
expected: 'https://cdn.example.com/icon.png'
},
{
icons: [{
src: '/icon1.png'
}, {
src: '/icon2.png',
sizes: '75x75 150x150'
}, {
src: '/icon3.png',
sizes: 'any'
}],
expected: 'https://example.com/icon3.png'
},
{
icons: [{
src: '/icon1.png'
}, {
src: '/icon2.png',
sizes: '75x75 150x150'
}, {
src: '/icon3.png',
sizes: '50x50 200x200'
}],
expected: 'https://example.com/icon3.png'
},
{
icons: [{
src: '/icon1.png'
}, {
src: '/icon3.png',
sizes: 'any'
}],
expected: 'https://example.com/icon3.png'
},
{
icons: [{
src: '/icon1.png'
}, {
src: '/icon2.png',
sizes: '75x75 150x150'
}],
expected: 'https://example.com/icon2.png'
}
])('should return correct url', ({ icons, expected }) => {
expect(parseManifest({ icons }, 'https://example.com/path/file')).toStrictEqual(expect.objectContaining({ icon: expected }));
});
});
Loading