Skip to content

Commit 0f261e6

Browse files
committed
initial
1 parent 50641c0 commit 0f261e6

File tree

19 files changed

+1753
-3
lines changed

19 files changed

+1753
-3
lines changed

.github/workflows/node.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: Install dependencies
3737
run: |
38-
npm ci --omit=dev
38+
npm ci
3939
npm install @rollup/rollup-linux-x64-gnu
4040
4141
- run: npm run build
@@ -57,4 +57,30 @@ jobs:
5757
REDIRECT_URL: /auth/callback
5858
SESSION_SECRET: secret555555
5959
HTTPS: true
60-
run: npm run test
60+
run: |
61+
npm run lint
62+
npm run coverage
63+
64+
- name: Upload coverage artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: coverage-html
68+
path: coverage
69+
if-no-files-found: error
70+
71+
- name: Install qlty CLI
72+
run: |
73+
curl -sSL https://qlty.sh/install | bash
74+
echo "$HOME/.qlty/bin" >> $GITHUB_PATH
75+
76+
- name: Upload coverage to qlty.sh
77+
env:
78+
QLTY_TOKEN: ${{ secrets.QLTY_TOKEN }}
79+
run: |
80+
qlty report \
81+
--format lcov \
82+
--file coverage/lcov.info \
83+
--commit "$GITHUB_SHA" \
84+
--branch "$GITHUB_REF_NAME" \
85+
--repo "$GITHUB_REPOSITORY" \
86+
--token "$QLTY_TOKEN"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[![Maintainability](https://qlty.sh/gh/internetee/projects/registrant_center/maintainability.svg)](https://qlty.sh/gh/internetee/projects/registrant_center)
2+
[![Code Coverage](https://qlty.sh/gh/internetee/projects/registrant_center/coverage.svg)](https://qlty.sh/gh/internetee/projects/registrant_center)
3+
14
# EESTI INTERNETI SA - Registrant Center
25

36
## Tech Stack 🛠

server/index.test.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// @vitest-environment node
2+
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
3+
4+
// Mock SSL files and https server to avoid real network and fs
5+
vi.mock('fs', () => ({
6+
default: {
7+
readFileSync: vi.fn(() => 'dummy'),
8+
},
9+
}));
10+
11+
vi.mock('https', () => ({
12+
default: {
13+
createServer: vi.fn((credentials, app) => {
14+
const serverInstance = {
15+
emit: vi.fn(),
16+
listen: vi.fn((port, cb) => {
17+
if (cb) {
18+
// Call callback asynchronously to match real behavior
19+
setTimeout(() => cb(), 0);
20+
}
21+
return serverInstance;
22+
}),
23+
};
24+
return serverInstance;
25+
}),
26+
},
27+
}));
28+
29+
vi.mock('grant-express', () => ({ default: () => (req, res, next) => next() }));
30+
vi.mock('express-winston', () => ({ default: { logger: () => (req, res, next) => next(), errorLogger: () => (req, res, next) => next() } }));
31+
vi.mock('helmet', () => ({ default: () => (req, res, next) => next() }));
32+
vi.mock('compression', () => ({ default: () => (req, res, next) => next() }));
33+
vi.mock('cookie-session', () => ({ default: () => (req, res, next) => next() }));
34+
35+
vi.mock('./utils/banner.js', () => ({ default: vi.fn() }));
36+
vi.mock('axios', () => ({
37+
default: {
38+
get: vi.fn(async () => ({ data: { keys: [{}] } })),
39+
create: vi.fn(() => ({
40+
get: vi.fn(async () => ({ status: 200, data: {} })),
41+
post: vi.fn(async () => ({ status: 200, data: {} })),
42+
delete: vi.fn(async () => ({ status: 200, data: {} })),
43+
patch: vi.fn(async () => ({ status: 200, data: {} })),
44+
})),
45+
},
46+
}));
47+
48+
describe('server/index smoke', () => {
49+
let serverModule;
50+
const prevEnv = { ...process.env };
51+
52+
beforeAll(async () => {
53+
process.env.NODE_ENV = 'test';
54+
process.env.HOST = 'localhost';
55+
process.env.VITE_SERVER_PORT = '4000';
56+
process.env.REDIRECT_URL = '/auth/callback';
57+
process.env.SESSION_SECRET = 'x';
58+
process.env.ISSUER_URL = 'https://issuer';
59+
process.env.JWKS_PATH = '/jwks';
60+
process.env.API_HOST = 'https://api.test';
61+
process.env.PUBLIC_API_HOST = 'https://public.test';
62+
process.env.PUBLIC_API_KEY = 'test-key';
63+
process.env.VITE_SCOPE = 'openid';
64+
process.env.RESPONSE_TYPE = 'code';
65+
process.env.AUTH_PATH = '/auth';
66+
process.env.TOKEN_PATH = '/token';
67+
serverModule = await import('./index.js');
68+
}, 30000);
69+
70+
afterAll(() => {
71+
process.env = prevEnv;
72+
});
73+
74+
it('exports server instance', () => {
75+
expect(serverModule.default).toBeDefined();
76+
});
77+
});
78+
79+

0 commit comments

Comments
 (0)