Skip to content

Commit cc7d648

Browse files
committed
Merge remote-tracking branch 'origin/main' into test/383-account-settings
2 parents c21760b + 3684542 commit cc7d648

File tree

162 files changed

+2704
-1727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+2704
-1727
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const filePath = path.join(__dirname, 'counter.txt');
5+
6+
try {
7+
// Read current value
8+
let current = 0;
9+
if (fs.existsSync(filePath)) {
10+
const content = fs.readFileSync(filePath, 'utf8').trim();
11+
current = parseInt(content, 10) || 0;
12+
}
13+
14+
console.info(`\n\nTests ran: ${current}\n\n`);
15+
} catch (err) {
16+
console.error('Error updating counter:', err.message);
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const filePath = path.join(__dirname, 'counter.txt');
5+
6+
try {
7+
// Read current value
8+
let current = 0;
9+
if (fs.existsSync(filePath)) {
10+
const content = fs.readFileSync(filePath, 'utf8').trim();
11+
current = parseInt(content, 10) || 0;
12+
}
13+
14+
// Increment
15+
const updated = current + 1;
16+
17+
// Write back
18+
fs.writeFileSync(filePath, String(updated));
19+
console.info(`\n\nCounter updated: ${current}${updated}\n\n`);
20+
} catch (err) {
21+
console.error('Error updating counter:', err.message);
22+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const fs = require('fs');
2+
const { execSync } = require('child_process');
3+
const coverage = require('../../coverage/coverage-summary.json');
4+
const jestConfig = require('../../jest.config.js');
5+
6+
const summary = coverage.total;
7+
const thresholds = jestConfig.coverageThreshold.global;
8+
9+
let failed = false;
10+
const errors = [];
11+
for (const key of ['branches', 'functions', 'lines', 'statements']) {
12+
const current = summary[key].pct;
13+
const threshold = thresholds[key];
14+
if (current > threshold) {
15+
errors.push(
16+
`Coverage for ${key} (${current}%) is above the threshold (${threshold}%).\n\tPlease update the coverageThreshold.global.${key} in the jest.config.js to ${current}!`
17+
)
18+
failed = true;
19+
}
20+
}
21+
22+
if (failed) {
23+
execSync('clear', { stdio: 'inherit' });
24+
console.log('\n\nCongratulations! You have successfully run the coverage check and added tests.');
25+
console.log('\n\nThe jest.config.js file is not insync with your new test additions.');
26+
console.log('Please update the coverage thresholds in jest.config.js.');
27+
console.log('You will need to commit again once you have updated the jst.config.js file.');
28+
console.log('This is only necessary until we hit 100% coverage.\n\n');
29+
errors.forEach(err => console.error(`${err}\n`));
30+
process.exit(1);
31+
}

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Run Jest Tests
2+
3+
on:
4+
pull_request:
5+
branches: ['*'] # or change to match your default branch
6+
push:
7+
branches: ['*']
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Use Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22.13.1
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run Jest tests with coverage
26+
run: npm run ci
27+
28+
- name: Check coverage thresholds
29+
run: npm run test:check-coverage-thresholds

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ yarn-error.log
3737
testem.log
3838
/typings
3939

40+
.github/counter/counter.txt
41+
4042
# System files
4143
.DS_Store
4244
Thumbs.db

.husky/pre-commit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
npx lint-staged
1+
npx lint-staged || {
2+
printf "\n\nERROR: Linting issues were found in the committed files. Please address them before proceeding.\n\n\n\n"
3+
exit 1
4+
}

.husky/pre-push

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
npm run build
2+
3+
npm run test:coverage || {
4+
printf "\n\nERROR: Testing errors or coverage issues were found. Please address them before proceeding.\n\n\n\n"
5+
exit 1
6+
}
7+
8+
npm run test:check-coverage-thresholds || {
9+
printf "\n\nERROR: Coverage thresholds were not met. Please address them before proceeding.\n\n\n\n"
10+
exit 1
11+
}

.vscode/settings.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"source.fixAll.stylelint": "explicit",
66
"source.fixAll.eslint": "explicit"
77
},
8-
"[html]": {
9-
"editor.defaultFormatter": "esbenp.prettier-vscode"
10-
},
8+
"editor.defaultFormatter": "esbenp.prettier-vscode",
119
"scss.lint.unknownAtRules": "ignore",
1210
"eslint.validate": ["json"]
1311
}

eslint.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,11 @@ module.exports = tseslint.config(
8585
files: ['**/*.html'],
8686
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
8787
rules: {},
88+
},
89+
{
90+
files: ['**/*.spec.ts'],
91+
rules: {
92+
'@typescript-eslint/no-explicit-any': 'off',
93+
},
8894
}
8995
);

jest.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
22
preset: 'jest-preset-angular',
33
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
4+
globalSetup: '<rootDir>/jest.global-setup.ts',
5+
collectCoverage: true,
6+
coverageReporters: ['json-summary', 'lcov', 'clover'],
47
moduleNameMapper: {
58
'^@osf/(.*)$': '<rootDir>/src/app/$1',
69
'^@core/(.*)$': '<rootDir>/src/app/core/$1',
@@ -24,16 +27,39 @@ module.exports = {
2427
coverageDirectory: 'coverage',
2528
collectCoverageFrom: [
2629
'src/app/**/*.{ts,js}',
30+
'!src/app/app.config.ts',
31+
'!src/app/**/*.routes.{ts.js}',
32+
'!src/app/**/*.models.{ts.js}',
33+
'!src/app/**/*.model.{ts.js}',
34+
'!src/app/**/*.route.{ts,js}',
2735
'!src/app/**/*.spec.{ts,js}',
2836
'!src/app/**/*.module.ts',
2937
'!src/app/**/index.ts',
3038
'!src/app/**/public-api.ts',
3139
],
3240
extensionsToTreatAsEsm: ['.ts'],
41+
coverageThreshold: {
42+
global: {
43+
branches: 11.2,
44+
functions: 11.34,
45+
lines: 36.73,
46+
statements: 37.33,
47+
},
48+
},
3349
testPathIgnorePatterns: [
50+
'<rootDir>/src/app/app.config.ts',
51+
'<rootDir>/src/app/app.routes.ts',
3452
'<rootDir>/src/app/features/registry/',
3553
'<rootDir>/src/app/features/project/',
3654
'<rootDir>/src/app/features/registries/',
55+
'<rootDir>/src/app/features/settings/addons/',
56+
'<rootDir>/src/app/features/settings/developer-apps/',
57+
'<rootDir>/src/app/features/settings/notifications/',
58+
'<rootDir>/src/app/features/settings/settings-container.component.ts',
59+
'<rootDir>/src/app/features/settings/tokens/components/',
60+
'<rootDir>/src/app/features/settings/tokens/mappers/',
61+
'<rootDir>/src/app/features/settings/tokens/store/',
62+
'<rootDir>/src/app/features/settings/tokens/pages/tokens-list/',
3763
'<rootDir>/src/app/shared/',
3864
],
3965
};

0 commit comments

Comments
 (0)