Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Setup lint and testing suites #203

Merged
merged 75 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
02f4e92
Setup lint
Yudi May 31, 2024
b36660d
Update eslint.config.js
Yudi May 31, 2024
3aa63f4
Update eslint.config.js
Yudi May 31, 2024
48ca2cc
wip
Yudi May 31, 2024
c029214
wip
Yudi May 31, 2024
a70d964
wip
Yudi May 31, 2024
35dbc16
wip
Yudi May 31, 2024
1e2a9c3
wip
Yudi May 31, 2024
ddd6cd9
wip
Yudi May 31, 2024
697120e
wip
Yudi May 31, 2024
2917c06
wip
Yudi May 31, 2024
543c88c
wip
Yudi May 31, 2024
3e27766
wip
Yudi May 31, 2024
7cfe82c
wip
Yudi May 31, 2024
2431c6d
Both
Yudi Jun 1, 2024
5bdbd95
no jest
Yudi Jun 1, 2024
d32f694
Revert
Yudi Jun 1, 2024
f029d5c
Revert
Yudi Jun 1, 2024
3dc033f
wip
Yudi Jun 1, 2024
eba43b3
Merge branch 'angular-setup-lint' into angular-testing
Yudi Jun 1, 2024
7ea9bd7
Update calendar.page.html
Yudi Jun 1, 2024
ca0a0b8
wip
Yudi Jun 1, 2024
2b86556
Delete spec files
Yudi Jun 1, 2024
f109f03
Create date.service.spec.ts
Yudi Jun 1, 2024
b2cea0d
Update CI.yml
Yudi Jun 1, 2024
fefa9be
wip
Yudi Jun 1, 2024
e959eb0
Update CI.yml
Yudi Jun 1, 2024
d88f9dd
Fix imports
Yudi Jun 1, 2024
7d3f273
wip
Yudi Jun 1, 2024
20eb173
Update CI.yml
Yudi Jun 1, 2024
f381ff7
Create tests.yml
Yudi Jun 1, 2024
7c2f92d
Update tests.yml
Yudi Jun 1, 2024
1e8ad00
Use karma
Yudi Jun 1, 2024
f5ab73f
Update angular.json
Yudi Jun 1, 2024
6e54004
Update
Yudi Jun 1, 2024
440ef2b
Update karma.conf.js
Yudi Jun 1, 2024
afd1604
Update karma.conf.js
Yudi Jun 1, 2024
d372d37
Update karma.conf.js
Yudi Jun 1, 2024
b196446
Update karma.conf.js
Yudi Jun 1, 2024
917293c
wip
Yudi Jun 1, 2024
562bf4a
Update karma.conf.js
Yudi Jun 1, 2024
7056472
Revert "Delete spec files"
Yudi Jun 1, 2024
76fa461
wip
Yudi Jun 1, 2024
28f036d
Update angular.json
Yudi Jun 1, 2024
5d3093e
Reapply "Delete spec files"
Yudi Jun 1, 2024
486dae0
Update CI.yml
Yudi Jun 1, 2024
177b08f
a
Yudi Jun 1, 2024
e61afa6
Update tests.yml
Yudi Jun 1, 2024
241d1db
Update tests.yml
Yudi Jun 1, 2024
3047735
Update tests.yml
Yudi Jun 1, 2024
eb28b34
Update tests.yml
Yudi Jun 1, 2024
8e7edd0
Update tests.yml
Yudi Jun 1, 2024
88e13e1
a
Yudi Jun 1, 2024
5051393
wip
Yudi Jun 1, 2024
790996c
Update aztec-scanner.component.ts
Yudi Jun 1, 2024
fb5c2de
Update filter-modal.page.ts
Yudi Jun 1, 2024
348a31b
Update calendar.page.ts
Yudi Jun 1, 2024
ebf4594
a
Yudi Jun 1, 2024
24adcbb
a
Yudi Jun 1, 2024
77e3b13
a
Yudi Jun 1, 2024
aaee289
Update filter-modal.page.ts
Yudi Jun 1, 2024
33731a3
Update filter-modal.page.ts
Yudi Jun 1, 2024
d2dac67
a
Yudi Jun 1, 2024
d050c2d
a
Yudi Jun 1, 2024
285cdc7
Update CI.yml
Yudi Jun 1, 2024
eb13059
Update CI.yml
Yudi Jun 1, 2024
f2f3a42
Update setup-deps.yml
Yudi Jun 1, 2024
97cf15e
a
Yudi Jun 1, 2024
f7ccb14
a
Yudi Jun 1, 2024
39282a7
Update CI.yml
Yudi Jun 1, 2024
0e39fe9
Update CI.yml
Yudi Jun 1, 2024
bb13edb
Update setup-deps.yml
Yudi Jun 1, 2024
0bc91cc
a
Yudi Jun 1, 2024
bb6e35e
Update CI.yml
Yudi Jun 1, 2024
e5001f2
a
Yudi Jun 1, 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
64 changes: 62 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1

Expand All @@ -23,4 +23,64 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Build-artifacts
path: dist/
path: dist/

lint:
runs-on: ubuntu-latest

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

- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Lint
run: bun run lint

unit-tests:
if: ${{ github.event_name == 'pull_request' }}
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Unit tests
run: bun run test --no-watch --no-progress --browsers=ChromeHeadless


unit-tests-upload:
# This job uses a secret
# Pull requests are untrusted
if: ${{ github.event_name == 'push' }}
name: Unit tests and upload to Codecov
runs-on: ubuntu-latest

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

- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Unit tests
run: bun run test --no-watch --no-progress --browsers=ChromeHeadless

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ storage.rules
/.next/
/out/
next-env.d.ts
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
// Disable editor indentation detection
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.detectIndentation": false
"editor.detectIndentation": false,

// ESLint
"eslint.useFlatConfig": false
}
9 changes: 6 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"codeCoverage": true,
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"styles": [],
"scripts": [],
"exclude": [
"src/app/unused/**/*.ts"
],
"assets": [
{
"glob": "favicon.ico",
Expand All @@ -119,7 +121,8 @@
"input": "src/assets",
"output": "/assets"
}
]
],
"karmaConfig": "karma.conf.js"
},
"configurations": {
"ci": {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
45 changes: 45 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @ts-check
const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');
const angular = require('angular-eslint');

module.exports = tseslint.config(
{
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
...angular.configs.tsRecommended,
],
processor: angular.processInlineTemplates,
rules: {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'app',
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'app',
style: 'kebab-case',
},
],
'@angular-eslint/component-class-suffix': 'off',
'@typescript-eslint/consistent-indexed-object-style': ['error', 'record'],
},
},
{
files: ['**/*.html'],
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
rules: {},
},
{
ignores: ['functions/*', 'src/app/unused/*'],
}
);
2 changes: 1 addition & 1 deletion functions/src/certificates/issue-certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.issueMajorEventCertificate = onCall(
const data: MajorEventCertificateData = request.data;
const context = request;

if (context.app == undefined) {
if (context.app === undefined) {
throw new HttpsError('failed-precondition', 'The function must be called from an App Check verified app.');
}

Expand Down
10 changes: 5 additions & 5 deletions functions/src/claims/claims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { log } from 'firebase-functions/logger';
exports.addAdminRole = onCall(async (request): Promise<MainReturnType> => {
const data = request.data;
const context = request;
if (context.app == undefined) {
if (context.app === undefined) {
throw new HttpsError('failed-precondition', 'The function must be called from an App Check verified app.');
}

Expand Down Expand Up @@ -50,7 +50,7 @@ exports.removeAdminRole = onCall(async (request): Promise<MainReturnType> => {
const context = request;
const remoteConfig = getRemoteConfig();

if (context.app == undefined) {
if (context.app === undefined) {
throw new HttpsError('failed-precondition', 'The function must be called from an App Check verified app.');
}

Expand All @@ -65,7 +65,7 @@ exports.removeAdminRole = onCall(async (request): Promise<MainReturnType> => {
// Get whitelist array as string from remote config
const template = await remoteConfig.getTemplate();

// @ts-ignore
// @ts-expect-error
const whitelist: string = template.parameters.adminWhitelist.defaultValue?.value;
// Check if email is included in whitelist array
if (whitelist.includes(data.email)) {
Expand Down Expand Up @@ -110,7 +110,7 @@ exports.addProfessorRole = onCall(async (request): Promise<MainReturnType> => {
const context = request;
const db = getFirestore();

if (context.app == undefined) {
if (context.app === undefined) {
throw new HttpsError('failed-precondition', 'The function must be called from an App Check verified app.');
}

Expand All @@ -128,7 +128,7 @@ exports.addProfessorRole = onCall(async (request): Promise<MainReturnType> => {
return remoteConfig
.getTemplate()
.then((template) => {
// @ts-ignore
// @ts-expect-error
const professors: string = template.parameters.professors.defaultValue?.value;

// Check if email is included in professors array
Expand Down
2 changes: 1 addition & 1 deletion functions/src/unused/move-certificates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.moveCertificates = onCall({ timeoutSeconds: 540, memory: '1GiB' }, async
throw new HttpsError('failed-precondition', 'The function must be called while authenticated.');
}

if (context.app == undefined) {
if (context.app === undefined) {
throw new HttpsError('failed-precondition', 'The function must be called from an App Check verified app.');
}

Expand Down
4 changes: 2 additions & 2 deletions functions/src/utils/user/impersonate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Attribution: amiregelz
// https://stackoverflow.com/questions/36759627/firebase-login-as-other-user/71808501#71808501
/*exports.impersonate = functions.https.onCall((data, context) => {
if (context.app == undefined) {
if (context.app===undefined) {
throw new functions.https.HttpsError(
'failed-precondition',
'The function must be called from an App Check verified app.'
Expand All @@ -20,7 +20,7 @@

// Get whitelist array as string from remote config
return remoteConfig.getTemplate().then((template) => {
// @ts-ignore
// @ts-expect-error
const whitelist: string = template.parameters.adminWhitelist.defaultValue?.value;

if (context.auth?.uid) {
Expand Down
2 changes: 1 addition & 1 deletion functions/src/utils/user/user-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports.getUserUid = onCall(async (context): Promise<StringDataReturnType> => {
throw new HttpsError('failed-precondition', 'The function must be called while authenticated.');
}

if (context.app == undefined) {
if (context.app === undefined) {
throw new HttpsError('failed-precondition', 'The function must be called from an App Check verified app.');
}

Expand Down
40 changes: 40 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma'),
],
preprocessors: {
'src/**/*.ts': ['coverage'],
},

client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true, // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/app'),
subdir: '.',
reporters: [{ type: 'html' }, { type: 'text-summary' }, { type: 'lcovonly' }],
},
reporters: ['progress', 'kjhtml', 'coverage'],
browsers: ['Chrome'],
restartOnFileChange: true,
});
};
58 changes: 33 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "playwright test"
},
"private": true,
"dependencies": {
"@angular/animations": "18.0.0",
"@angular/common": "~18.0.0",
"@angular/core": "~18.0.0",
"@angular/animations": "18.0.1",
"@angular/common": "~18.0.1",
"@angular/core": "~18.0.1",
"@angular/fire": "^18.0.1",
"@angular/forms": "~18.0.0",
"@angular/platform-browser": "~18.0.0",
"@angular/platform-browser-dynamic": "~18.0.0",
"@angular/router": "~18.0.0",
"@angular/service-worker": "^18.0.0",
"@angular/forms": "~18.0.1",
"@angular/platform-browser": "~18.0.1",
"@angular/platform-browser-dynamic": "~18.0.1",
"@angular/router": "~18.0.1",
"@angular/service-worker": "^18.0.1",
"@ionic/angular": "^8.2.0",
"@ngneat/until-destroy": "^10.0.0",
"@notiz/ngx-plausible": "^0.7.0",
"@pdfme/generator": "^4.0.1",
"@pdfme/generator": "^4.0.2",
"@sweetalert2/ngx-sweetalert2": "^12.3.0",
"buffer": "^6.0.3",
"bwip-js": "^4.3.2",
"date-fns": "^3.6.0",
"highlight.run": "^8.12.3",
"highlight.run": "^8.13.0",
"ionicons": "^7.4.0",
"marked": "^12.0.2",
"ngx-image-compress": "^15.1.6",
Expand All @@ -45,33 +45,41 @@
"zxing-wasm": "^1.2.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "~18.0.1",
"@angular-eslint/builder": "~17.5.1",
"@angular-eslint/eslint-plugin": "~17.5.1",
"@angular-eslint/eslint-plugin-template": "~17.5.1",
"@angular-eslint/template-parser": "~17.5.1",
"@angular/cli": "~18.0.1",
"@angular/compiler": "~18.0.0",
"@angular/compiler-cli": "~18.0.0",
"@angular/language-service": "~18.0.0",
"@angular-devkit/build-angular": "~18.0.2",
"@angular/cli": "~18.0.2",
"@angular/compiler": "~18.0.1",
"@angular/compiler-cli": "~18.0.1",
"@angular/language-service": "~18.0.1",
"@ionic/angular-toolkit": "^11.0.1",
"@pdfme/common": "^4.0.1",
"@pdfme/schemas": "^4.0.1",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"@pdfme/common": "^4.0.2",
"@pdfme/schemas": "^4.0.2",
"@playwright/test": "^1.44.1",
"@types/google-one-tap": "^1.2.6",
"@types/jasmine": "^5.1.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.13.0",
"@types/twemoji-parser": "^13.1.4",
"@web/test-runner": "^0.18.2",
"angular-eslint": "18.0.1",
"eslint": "^9.3.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "48.2.6",
"eslint-plugin-jsdoc": "48.2.7",
"eslint-plugin-prefer-arrow": "1.2.3",
"jasmine": "^5.1.0",
"jest-preset-angular": "^14.1.0",
"karma": "^6.4.3",
"karma-chrome-launcher": "^3.2.0",
"karma-coverage": "^2.2.1",
"karma-jasmine": "^5.1.0",
"karma-jasmine-html-reporter": "^2.1.0",
"protractor": "~7.0.0",
"react": "^18.3.1",
"react-dom": "18.3.1",
"terser": "5.31.0",
"ts-node": "~10.9.2",
"tslib": "^2.6.2",
"typescript": "5.4.5",
"typescript-eslint": "8.0.0-alpha.20",
"typescript-strict-plugin": "^2.4.3"
},
"trustedDependencies": [
Expand Down
Loading
Loading