Merge pull request 'Migrate the API to native ESM and vitest; pin Node 26' (#10) from feature/api-esm-prep into master
Jenkins Production Deployment
Jenkins Production Deployment
Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
@@ -8,12 +8,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
npm run build # Compile TypeScript → dist/
|
||||
npm run start # Build and start (tsc && node ./dist/app.js)
|
||||
npm run debug # Start with DEBUG=* environment variable
|
||||
npm run test # Run Jest tests with coverage (outputs sonar-report.xml)
|
||||
npm run test # Run the vitest suite once with coverage (lcov + testResults/sonar-report.xml)
|
||||
npm run test:watch # vitest in watch mode
|
||||
```
|
||||
|
||||
Run a single test file:
|
||||
```bash
|
||||
npx jest test/some.test.ts
|
||||
npx vitest run test/some.test.ts
|
||||
```
|
||||
|
||||
## Architecture
|
||||
@@ -69,6 +70,10 @@ CHOIR_CREDENTIAL=
|
||||
MANAGEMENT_CREDENTIAL=
|
||||
```
|
||||
|
||||
## TypeScript config
|
||||
## TypeScript / module system
|
||||
|
||||
Strict mode enabled, target ES2016, compiled output in `./dist`, inline source maps. Tests run through `ts-jest` directly against `.ts` sources.
|
||||
The API runs on Node 26 (`engines` in package.json, `.nvmrc`; Plesk runs 26 too) and is native ESM (`"type": "module"`, `module: nodenext`, target ES2024, strict mode, compiled output in `./dist`, inline source maps). Consequences:
|
||||
|
||||
- Relative imports carry the `.js` suffix (`import {x} from "./x.js"`) even though the source file is `.ts`.
|
||||
- CommonJS dependencies are consumed via default imports (`import mariadb from "mariadb"`, `import cors from "cors"`, `import winston from "winston"`), never `require()`.
|
||||
- Tests run with vitest directly against `.ts` sources; import `describe`/`it`/`expect`/`vi` from `vitest` explicitly (no globals). Module mocks use `vi.mock(...)` with the same `.js`-suffixed paths as the imports.
|
||||
|
||||
@@ -3,16 +3,15 @@ import * as http from 'http';
|
||||
import * as dotenv from 'dotenv';
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
import swaggerJSDoc from 'swagger-jsdoc';
|
||||
import logger from './src/middleware/logger';
|
||||
import cors from 'cors';
|
||||
import logger from './src/middleware/logger.js';
|
||||
|
||||
// Router imports
|
||||
import {calendarRouter} from './src/models/calendar/Calendar.router';
|
||||
import {feedbackRouter} from './src/models/feedback/Feedback.router';
|
||||
import {ticketsRouter} from './src/models/tickets/Tickets.router';
|
||||
import {calendarRouter} from './src/models/calendar/Calendar.router.js';
|
||||
import {feedbackRouter} from './src/models/feedback/Feedback.router.js';
|
||||
import {ticketsRouter} from './src/models/tickets/Tickets.router.js';
|
||||
|
||||
|
||||
let cors = require('cors');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
if (!process.env.PORT) {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
roots: [
|
||||
'test'
|
||||
]
|
||||
};
|
||||
Generated
+2166
-5904
File diff suppressed because it is too large
Load Diff
+14
-16
@@ -3,22 +3,27 @@
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=26"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "tsc && node ./dist/app.js",
|
||||
"build": "tsc",
|
||||
"debug": "export DEBUG=* && npm run start",
|
||||
"test": "jest --coverage --testResultsProcessor ./node_modules/jest-sonar-reporter/index.js"
|
||||
"test": "vitest run --coverage",
|
||||
"test:watch": "vitest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"app-root-path": "^3.0.0",
|
||||
"axios": "^0.24.0",
|
||||
"axios": "^1.20.0",
|
||||
"bcrypt": "^5.0.1",
|
||||
"cors": "^2.8.5",
|
||||
"debug": "^4.3.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"dotenv": "^16.6.1",
|
||||
"express": "^4.18.2",
|
||||
"guid-typescript": "^1.0.9",
|
||||
"mariadb": "^3.0.2",
|
||||
@@ -30,26 +35,19 @@
|
||||
"devDependencies": {
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/bcrypt": "^3.0.1",
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/debug": "^4.1.5",
|
||||
"@types/express": "^4.17.15",
|
||||
"@types/jest": "^28.1.3",
|
||||
"@types/node": "^18.11.17",
|
||||
"@types/node": "^26.4.1",
|
||||
"@types/random-words": "^1.1.2",
|
||||
"@types/swagger-jsdoc": "^6.0.1",
|
||||
"@types/swagger-ui-express": "^4.1.3",
|
||||
"@types/winston": "^2.4.4",
|
||||
"@vitest/coverage-v8": "^5.0.0",
|
||||
"is-number": "^7.0.0",
|
||||
"jest": "^28.1.1",
|
||||
"jest-sonar-reporter": "^2.0.0",
|
||||
"source-map-support": "^0.5.19",
|
||||
"ts-jest": "^28.0.5",
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"jestSonar": {
|
||||
"sonar56x": true,
|
||||
"reportPath": "testResults",
|
||||
"reportFile": "sonar-report.xml",
|
||||
"indent": 4
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^5.0.0",
|
||||
"vitest-sonar-reporter": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import logger from '../middleware/logger';
|
||||
import {salesforceApexRestPost, salesforceEnabled} from './salesforce.client';
|
||||
import logger from '../middleware/logger.js';
|
||||
import {salesforceApexRestPost, salesforceEnabled} from './salesforce.client.js';
|
||||
|
||||
// Transactional email for the ticketing/calendar flows (voucher redemption
|
||||
// confirmations, account activation links, password-reset tokens) is relayed
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as appRoot from 'app-root-path';
|
||||
import * as winston from 'winston';
|
||||
import appRoot from 'app-root-path';
|
||||
import winston from 'winston';
|
||||
|
||||
const options = {
|
||||
file_info: {
|
||||
level: 'info',
|
||||
filename: `${appRoot}/logs/app.log`,
|
||||
filename: `${appRoot.path}/logs/app.log`,
|
||||
handleExceptions: true,
|
||||
json: true,
|
||||
maxsize: 5242880, // 5MB
|
||||
@@ -13,7 +13,7 @@ const options = {
|
||||
},
|
||||
file_error: {
|
||||
level: 'error',
|
||||
filename: `${appRoot}/logs/error.log`,
|
||||
filename: `${appRoot.path}/logs/error.log`,
|
||||
handleExceptions: true,
|
||||
json: true,
|
||||
maxsize: 5242880, // 5MB
|
||||
@@ -22,7 +22,7 @@ const options = {
|
||||
},
|
||||
file_debug: {
|
||||
level: 'debug',
|
||||
filename: `${appRoot}/logs/debug.log`,
|
||||
filename: `${appRoot.path}/logs/debug.log`,
|
||||
handleExceptions: true,
|
||||
json: true,
|
||||
maxsize: 5242880, // 5MB
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
const mariadb = require('mariadb');
|
||||
import mariadb from 'mariadb';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -10,8 +9,7 @@ export namespace NachklangCalendarDB {
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.CALENDAR_DB,
|
||||
connectionLimit: 5,
|
||||
autoCommit: false
|
||||
connectionLimit: 5
|
||||
});
|
||||
|
||||
export const getConnection = async () => {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import logger from '../../middleware/logger';
|
||||
import {eventsRouter} from './events/events.router';
|
||||
import {usersRouter} from './users/users.router';
|
||||
import logger from '../../middleware/logger.js';
|
||||
import {eventsRouter} from './events/events.router.js';
|
||||
import {usersRouter} from './users/users.router.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as UserService from '../users/users.service';
|
||||
import * as UserService from '../users/users.service.js';
|
||||
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
*/
|
||||
|
||||
import express, {Request, Response} from 'express';
|
||||
import {Event} from './event.interface';
|
||||
import * as EventService from './events.service';
|
||||
import * as iCalService from './icalgenerator.service';
|
||||
import * as CredentialService from './credentials.service';
|
||||
import * as UserService from '../users/users.service';
|
||||
import {Event} from './event.interface.js';
|
||||
import * as EventService from './events.service.js';
|
||||
import * as iCalService from './icalgenerator.service.js';
|
||||
import * as CredentialService from './credentials.service.js';
|
||||
import * as UserService from '../users/users.service.js';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import logger from '../../../middleware/logger';
|
||||
import logger from '../../../middleware/logger.js';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import {Event} from './event.interface';
|
||||
import {NachklangCalendarDB} from '../Calendar.db';
|
||||
import {Event} from './event.interface.js';
|
||||
import {NachklangCalendarDB} from '../Calendar.db.js';
|
||||
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Event} from './event.interface';
|
||||
import {Event} from './event.interface.js';
|
||||
|
||||
/**
|
||||
* Interface to external classes - Turns the given events into an ical string
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
*/
|
||||
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as UserService from './users.service';
|
||||
import {Session} from './session.interface';
|
||||
import {User} from './user.interface';
|
||||
import * as UserService from './users.service.js';
|
||||
import {Session} from './session.interface.js';
|
||||
import {User} from './user.interface.js';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import logger from '../../../middleware/logger';
|
||||
import logger from '../../../middleware/logger.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import bcrypt from 'bcrypt';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import {User} from './user.interface';
|
||||
import {Session} from './session.interface';
|
||||
import {NachklangCalendarDB} from '../Calendar.db';
|
||||
import {MailService} from "../../../common/common.mail";
|
||||
import {User} from './user.interface.js';
|
||||
import {Session} from './session.interface.js';
|
||||
import {NachklangCalendarDB} from '../Calendar.db.js';
|
||||
import {MailService} from '../../../common/common.mail.js';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
const mariadb = require('mariadb');
|
||||
import mariadb from 'mariadb';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -10,8 +9,7 @@ export namespace NachklangFeedbackDB {
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.FEEDBACK_DB,
|
||||
connectionLimit: 5,
|
||||
autoCommit: false
|
||||
connectionLimit: 5
|
||||
});
|
||||
|
||||
export const getConnection = async () => {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import {publicRouter} from './public/public.router';
|
||||
import {adminRouter} from './admin/admin.router';
|
||||
import {sendServerError} from './feedback.errors';
|
||||
import {publicRouter} from './public/public.router.js';
|
||||
import {adminRouter} from './admin/admin.router.js';
|
||||
import {sendServerError} from './feedback.errors.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
* type: boolean
|
||||
*/
|
||||
|
||||
import {QuestionType, Song} from '../feedback.interface';
|
||||
import {QuestionType, Song} from '../feedback.interface.js';
|
||||
|
||||
export interface EventAdminSummary {
|
||||
eventId: number;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import {requireAdminAuth} from '../feedback.auth';
|
||||
import {sendServerError} from '../feedback.errors';
|
||||
import {eventsAdminRouter} from './events.admin.router';
|
||||
import {songsAdminRouter} from './songs.admin.router';
|
||||
import {questionsAdminRouter} from './questions.admin.router';
|
||||
import {reportsAdminRouter} from './reports.admin.router';
|
||||
import * as ReportsAdminService from './reports.admin.service';
|
||||
import {requireAdminAuth} from '../feedback.auth.js';
|
||||
import {sendServerError} from '../feedback.errors.js';
|
||||
import {eventsAdminRouter} from './events.admin.router.js';
|
||||
import {songsAdminRouter} from './songs.admin.router.js';
|
||||
import {questionsAdminRouter} from './questions.admin.router.js';
|
||||
import {reportsAdminRouter} from './reports.admin.router.js';
|
||||
import * as ReportsAdminService from './reports.admin.service.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {formatDatetime} from '../feedback.dates';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import {formatDatetime} from '../feedback.dates.js';
|
||||
|
||||
const CSV_SEPARATOR = ';';
|
||||
const UTF8_BOM = '';
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as EventsAdminService from './events.admin.service';
|
||||
import * as SongsAdminService from './songs.admin.service';
|
||||
import {sendServerError} from '../feedback.errors';
|
||||
import * as EventsAdminService from './events.admin.service.js';
|
||||
import * as SongsAdminService from './songs.admin.service.js';
|
||||
import {sendServerError} from '../feedback.errors.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {Song} from '../feedback.interface';
|
||||
import {CreateEventInput, EventAdminDetail, EventAdminQuestionAssignment, EventAdminSummary, UpdateEventInput} from './admin.interface';
|
||||
import {formatDatetime} from '../feedback.dates';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import {Song} from '../feedback.interface.js';
|
||||
import {CreateEventInput, EventAdminDetail, EventAdminQuestionAssignment, EventAdminSummary, UpdateEventInput} from './admin.interface.js';
|
||||
import {formatDatetime} from '../feedback.dates.js';
|
||||
|
||||
const UMLAUT_MAP: Record<string, string> = {
|
||||
'ä': 'ae', 'ö': 'oe', 'ü': 'ue', 'ß': 'ss',
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as QuestionsAdminService from './questions.admin.service';
|
||||
import {sendServerError} from '../feedback.errors';
|
||||
import * as QuestionsAdminService from './questions.admin.service.js';
|
||||
import {sendServerError} from '../feedback.errors.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {QuestionType} from '../feedback.interface';
|
||||
import {AdminQuestion} from './admin.interface';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import {QuestionType} from '../feedback.interface.js';
|
||||
import {AdminQuestion} from './admin.interface.js';
|
||||
|
||||
const mapRow = (row: any): AdminQuestion => ({
|
||||
questionId: row.question_id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {QuestionType} from '../feedback.interface';
|
||||
import {QuestionType} from '../feedback.interface.js';
|
||||
|
||||
export interface SongPickResult {
|
||||
songId: number;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as ReportsAdminService from './reports.admin.service';
|
||||
import * as CsvService from './csv.service';
|
||||
import * as EventsAdminService from './events.admin.service';
|
||||
import {sendServerError} from '../feedback.errors';
|
||||
import * as ReportsAdminService from './reports.admin.service.js';
|
||||
import * as CsvService from './csv.service.js';
|
||||
import * as EventsAdminService from './events.admin.service.js';
|
||||
import {sendServerError} from '../feedback.errors.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import {
|
||||
AnswerRow, EventReport, FreeTextReport, SongPickReport, SongRatingReport
|
||||
} from './reports.admin.interface';
|
||||
} from './reports.admin.interface.js';
|
||||
|
||||
const FREE_TEXT_CAP = 500;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as SongsAdminService from './songs.admin.service';
|
||||
import {sendServerError} from '../feedback.errors';
|
||||
import * as SongsAdminService from './songs.admin.service.js';
|
||||
import {sendServerError} from '../feedback.errors.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
|
||||
export const addSong = async (eventId: number, title: string, composer: string | null): Promise<number> => {
|
||||
let conn = await NachklangFeedbackDB.getConnection();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import * as UserService from '../calendar/users/users.service';
|
||||
import {sendServerError} from './feedback.errors';
|
||||
import * as UserService from '../calendar/users/users.service.js';
|
||||
import {sendServerError} from './feedback.errors.js';
|
||||
|
||||
/**
|
||||
* This file is the ONLY place in the feedback module that knows how admin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Response} from 'express';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import logger from '../../middleware/logger';
|
||||
import logger from '../../middleware/logger.js';
|
||||
|
||||
/**
|
||||
* The feedback module's standard catch-block response: log with a
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as crypto from 'crypto';
|
||||
import * as dotenv from 'dotenv';
|
||||
import {NachklangFeedbackDB} from './Feedback.db';
|
||||
import {NachklangFeedbackDB} from './Feedback.db.js';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import logger from '../../../middleware/logger';
|
||||
import {salesforceApexRestPost} from '../../../common/salesforce.client';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import logger from '../../../middleware/logger.js';
|
||||
import {salesforceApexRestPost} from '../../../common/salesforce.client.js';
|
||||
|
||||
// Newsletter opt-ins sync to Salesforce, which already runs a full
|
||||
// double-opt-in subscription flow (Person Account for existing constituents,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {EventConfig, EventSummary, Question, Song} from '../feedback.interface';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import {EventConfig, EventSummary, Question, Song} from '../feedback.interface.js';
|
||||
|
||||
/**
|
||||
* Returns all events currently eligible to receive feedback:
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
* Required External Modules and Interfaces
|
||||
*/
|
||||
import express, {Request, Response} from 'express';
|
||||
import logger from '../../../middleware/logger';
|
||||
import {getEligibleEvents, getEventConfigBySlug} from './events.public.service';
|
||||
import {submitFeedback} from './submissions.service';
|
||||
import {hashIp, isRateLimited, recordSubmission} from '../feedback.ratelimit';
|
||||
import {sendServerError} from '../feedback.errors';
|
||||
import logger from '../../../middleware/logger.js';
|
||||
import {getEligibleEvents, getEventConfigBySlug} from './events.public.service.js';
|
||||
import {submitFeedback} from './submissions.service.js';
|
||||
import {hashIp, isRateLimited, recordSubmission} from '../feedback.ratelimit.js';
|
||||
import {sendServerError} from '../feedback.errors.js';
|
||||
|
||||
/**
|
||||
* Router Definition
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {NachklangFeedbackDB} from '../Feedback.db';
|
||||
import {QuestionType} from '../feedback.interface';
|
||||
import {getEventConfigBySlug} from './events.public.service';
|
||||
import {AnswerInput, GuestBookInput, NewsletterInput, SubmissionRequestBody} from './submission.interface';
|
||||
import {syncNewsletterSignup} from '../integrations/salesforce.service';
|
||||
import logger from '../../../middleware/logger';
|
||||
import {NachklangFeedbackDB} from '../Feedback.db.js';
|
||||
import {QuestionType} from '../feedback.interface.js';
|
||||
import {getEventConfigBySlug} from './events.public.service.js';
|
||||
import {AnswerInput, GuestBookInput, NewsletterInput, SubmissionRequestBody} from './submission.interface.js';
|
||||
import {syncNewsletterSignup} from '../integrations/salesforce.service.js';
|
||||
import logger from '../../../middleware/logger.js';
|
||||
|
||||
// Bump when the privacy/consent copy shown next to the newsletter opt-in
|
||||
// changes; recorded per-signup so a past consent's exact wording is provable.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
const mariadb = require('mariadb');
|
||||
import mariadb from 'mariadb';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -10,8 +9,7 @@ export namespace NachklangTicketsDB {
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.TICKETS_DB,
|
||||
connectionLimit: 5,
|
||||
autoCommit: false
|
||||
connectionLimit: 5
|
||||
});
|
||||
|
||||
export const getConnection = async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import {adminRouter} from './admin/admin.router';
|
||||
import {publicRouter} from './public/public.router';
|
||||
import {adminRouter} from './admin/admin.router.js';
|
||||
import {publicRouter} from './public/public.router.js';
|
||||
|
||||
export const ticketsRouter = express.Router();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import express, {Request, Response} from 'express';
|
||||
import {requireAdminAuth} from '../tickets.auth';
|
||||
import {vouchersAdminRouter} from './vouchers.admin.router';
|
||||
import {redemptionsAdminRouter, voucherHistoryRouter} from './redemptions.admin.router';
|
||||
import {eventsAdminRouter} from './events.admin.router';
|
||||
import {requireAdminAuth} from '../tickets.auth.js';
|
||||
import {vouchersAdminRouter} from './vouchers.admin.router.js';
|
||||
import {redemptionsAdminRouter, voucherHistoryRouter} from './redemptions.admin.router.js';
|
||||
import {eventsAdminRouter} from './events.admin.router.js';
|
||||
|
||||
export const adminRouter = express.Router();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as EventsAdminService from './events.admin.service';
|
||||
import {sendServerError} from '../tickets.errors';
|
||||
import * as EventsAdminService from './events.admin.service.js';
|
||||
import {sendServerError} from '../tickets.errors.js';
|
||||
|
||||
export const eventsAdminRouter = express.Router();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as CalendarEventsService from '../../calendar/events/events.service';
|
||||
import {NachklangTicketsDB} from '../Tickets.db';
|
||||
import {getEventTicketState} from '../tickets.capacity';
|
||||
import {EventStats, EventTicketSettings} from '../tickets.interface';
|
||||
import * as CalendarEventsService from '../../calendar/events/events.service.js';
|
||||
import {NachklangTicketsDB} from '../Tickets.db.js';
|
||||
import {getEventTicketState} from '../tickets.capacity.js';
|
||||
import {EventStats, EventTicketSettings} from '../tickets.interface.js';
|
||||
|
||||
// Concerts are managed on the public calendar (calendarId 1) - see
|
||||
// docs/plan-ticket-shop.md. getAllEventsAdmin includes DRAFT events so
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as RedemptionsAdminService from './redemptions.admin.service';
|
||||
import {sendServerError} from '../tickets.errors';
|
||||
import * as RedemptionsAdminService from './redemptions.admin.service.js';
|
||||
import {sendServerError} from '../tickets.errors.js';
|
||||
|
||||
export const redemptionsAdminRouter = express.Router();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {NachklangTicketsDB} from '../Tickets.db';
|
||||
import {getEventTicketState} from '../tickets.capacity';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../tickets.confirmation-email';
|
||||
import {AuditLogEntry, RedemptionSummary} from '../tickets.interface';
|
||||
import {isValidEmail} from '../tickets.validation';
|
||||
import {NachklangTicketsDB} from '../Tickets.db.js';
|
||||
import {getEventTicketState} from '../tickets.capacity.js';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../tickets.confirmation-email.js';
|
||||
import {AuditLogEntry, RedemptionSummary} from '../tickets.interface.js';
|
||||
import {isValidEmail} from '../tickets.validation.js';
|
||||
|
||||
const mapRedemptionRow = (row: any, guests: string[]): RedemptionSummary => ({
|
||||
redemptionId: row.redemption_id,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as VouchersAdminService from './vouchers.admin.service';
|
||||
import {sendServerError} from '../tickets.errors';
|
||||
import * as VouchersAdminService from './vouchers.admin.service.js';
|
||||
import {sendServerError} from '../tickets.errors.js';
|
||||
|
||||
export const vouchersAdminRouter = express.Router();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {Guid} from 'guid-typescript';
|
||||
import {NachklangTicketsDB} from '../Tickets.db';
|
||||
import {generateUniqueCode} from '../tickets.codes';
|
||||
import {VoucherCode, VoucherStatus} from '../tickets.interface';
|
||||
import {isValidEmail} from '../tickets.validation';
|
||||
import {NachklangTicketsDB} from '../Tickets.db.js';
|
||||
import {generateUniqueCode} from '../tickets.codes.js';
|
||||
import {VoucherCode, VoucherStatus} from '../tickets.interface.js';
|
||||
import {isValidEmail} from '../tickets.validation.js';
|
||||
|
||||
export interface WildcardGenerateInput {
|
||||
eventIds: number[];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import express, {Request, Response} from 'express';
|
||||
import * as VoucherPublicService from './voucher.public.service';
|
||||
import {sendServerError} from '../tickets.errors';
|
||||
import {hashIp, redeemLimiter, validateLimiter} from '../tickets.ratelimit';
|
||||
import * as VoucherPublicService from './voucher.public.service.js';
|
||||
import {sendServerError} from '../tickets.errors.js';
|
||||
import {hashIp, redeemLimiter, validateLimiter} from '../tickets.ratelimit.js';
|
||||
|
||||
export const publicRouter = express.Router();
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as EventsService from '../../calendar/events/events.service';
|
||||
import logger from '../../../middleware/logger';
|
||||
import {NachklangTicketsDB} from '../Tickets.db';
|
||||
import {getEventTicketState} from '../tickets.capacity';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../tickets.confirmation-email';
|
||||
import {EligibleEvent, RedeemRequest, VoucherValidation} from '../tickets.interface';
|
||||
import {isValidEmail} from '../tickets.validation';
|
||||
import * as EventsService from '../../calendar/events/events.service.js';
|
||||
import logger from '../../../middleware/logger.js';
|
||||
import {NachklangTicketsDB} from '../Tickets.db.js';
|
||||
import {getEventTicketState} from '../tickets.capacity.js';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../tickets.confirmation-email.js';
|
||||
import {EligibleEvent, RedeemRequest, VoucherValidation} from '../tickets.interface.js';
|
||||
import {isValidEmail} from '../tickets.validation.js';
|
||||
|
||||
/**
|
||||
* Builds the eligible-events list for a code: for each event it's linked
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import * as UserService from '../calendar/users/users.service';
|
||||
import {sendServerError} from './tickets.errors';
|
||||
import * as UserService from '../calendar/users/users.service.js';
|
||||
import {sendServerError} from './tickets.errors.js';
|
||||
|
||||
/**
|
||||
* Mirrors the Feedback module's feedback.auth.ts: this is the ONLY place in
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as EventsService from '../calendar/events/events.service';
|
||||
import * as IcalService from '../calendar/events/icalgenerator.service';
|
||||
import {MailService} from '../../common/common.mail';
|
||||
import logger from '../../middleware/logger';
|
||||
import {NachklangTicketsDB} from './Tickets.db';
|
||||
import * as EventsService from '../calendar/events/events.service.js';
|
||||
import * as IcalService from '../calendar/events/icalgenerator.service.js';
|
||||
import {MailService} from '../../common/common.mail.js';
|
||||
import logger from '../../middleware/logger.js';
|
||||
import {NachklangTicketsDB} from './Tickets.db.js';
|
||||
|
||||
export type ConfirmationEmailStatus = 'SENT' | 'FAILED';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Response} from 'express';
|
||||
import {Guid} from 'guid-typescript';
|
||||
import logger from '../../middleware/logger';
|
||||
import logger from '../../middleware/logger.js';
|
||||
|
||||
/**
|
||||
* The tickets module's standard catch-block response: log with a reference
|
||||
|
||||
@@ -5,17 +5,18 @@
|
||||
// behaviour, and that a delivery failure is swallowed (returns false, never
|
||||
// throws).
|
||||
|
||||
jest.mock('../../src/common/salesforce.client');
|
||||
jest.mock('../../src/middleware/logger', () => ({
|
||||
import {vi, describe, it, expect, beforeEach, type Mock} from 'vitest';
|
||||
vi.mock('../../src/common/salesforce.client.js');
|
||||
vi.mock('../../src/middleware/logger.js', () => ({
|
||||
__esModule: true,
|
||||
default: {info: jest.fn(), warn: jest.fn(), error: jest.fn()}
|
||||
default: {info: vi.fn(), warn: vi.fn(), error: vi.fn()}
|
||||
}));
|
||||
|
||||
import {MailService} from '../../src/common/common.mail';
|
||||
import {salesforceApexRestPost, salesforceEnabled} from '../../src/common/salesforce.client';
|
||||
import {MailService} from '../../src/common/common.mail.js';
|
||||
import {salesforceApexRestPost, salesforceEnabled} from '../../src/common/salesforce.client.js';
|
||||
|
||||
const mockPost = salesforceApexRestPost as jest.Mock;
|
||||
const mockEnabled = salesforceEnabled as jest.Mock;
|
||||
const mockPost = salesforceApexRestPost as Mock;
|
||||
const mockEnabled = salesforceEnabled as Mock;
|
||||
|
||||
const httpError = (status: number, body?: any): any => {
|
||||
const err: any = new Error('request failed with ' + status);
|
||||
@@ -24,7 +25,7 @@ const httpError = (status: number, body?: any): any => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
mockEnabled.mockReturnValue(true);
|
||||
mockPost.mockResolvedValue({status: 'SENT'});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// salesforce.client caches the OAuth token at module scope, so every test
|
||||
// resets the module registry for a clean cache and re-requires axios + the
|
||||
// resets the module registry for a clean cache and re-imports axios + the
|
||||
// module under test after the reset (same approach as
|
||||
// test/feedback/salesforce.service.test.ts).
|
||||
// test/feedback/salesforce.service.test.ts). Mocked modules survive
|
||||
// vi.resetModules(), so mock state is reset explicitly in beforeEach.
|
||||
|
||||
export {}; // isolate module scope from other script-style test files
|
||||
import {vi, describe, it, expect, beforeEach, afterAll} from 'vitest';
|
||||
vi.mock('axios');
|
||||
|
||||
jest.mock('axios');
|
||||
|
||||
const freshImports = () => {
|
||||
const axios = require('axios');
|
||||
const {salesforceApexRestPost, salesforceEnabled} = require('../../src/common/salesforce.client');
|
||||
const freshImports = async () => {
|
||||
const axios: any = (await import('axios')).default;
|
||||
const {salesforceApexRestPost, salesforceEnabled} = await import('../../src/common/salesforce.client.js');
|
||||
return {axios, salesforceApexRestPost, salesforceEnabled};
|
||||
};
|
||||
|
||||
@@ -23,7 +23,8 @@ const ENABLED_ENV = {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
vi.resetAllMocks();
|
||||
process.env = {...ENABLED_ENV};
|
||||
});
|
||||
|
||||
@@ -32,19 +33,19 @@ afterAll(() => {
|
||||
});
|
||||
|
||||
describe('salesforceEnabled', () => {
|
||||
it('is true only when SALESFORCE_ENABLED === "true"', () => {
|
||||
it('is true only when SALESFORCE_ENABLED === "true"', async () => {
|
||||
process.env.SALESFORCE_ENABLED = 'true';
|
||||
expect(freshImports().salesforceEnabled()).toBe(true);
|
||||
expect((await freshImports()).salesforceEnabled()).toBe(true);
|
||||
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env.SALESFORCE_ENABLED = 'false';
|
||||
expect(freshImports().salesforceEnabled()).toBe(false);
|
||||
expect((await freshImports()).salesforceEnabled()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('salesforceApexRestPost', () => {
|
||||
it('fetches a token, posts to the given Apex REST path, and returns the response body', async () => {
|
||||
const {axios, salesforceApexRestPost} = freshImports();
|
||||
const {axios, salesforceApexRestPost} = await freshImports();
|
||||
axios.post.mockImplementation((url: string) => {
|
||||
if (url.endsWith('/services/oauth2/token')) return Promise.resolve({data: {access_token: 'tok-1'}});
|
||||
return Promise.resolve({data: {ok: true}});
|
||||
@@ -66,7 +67,7 @@ describe('salesforceApexRestPost', () => {
|
||||
});
|
||||
|
||||
it('reuses the cached token across calls instead of fetching twice', async () => {
|
||||
const {axios, salesforceApexRestPost} = freshImports();
|
||||
const {axios, salesforceApexRestPost} = await freshImports();
|
||||
axios.post.mockImplementation((url: string) => {
|
||||
if (url.endsWith('/services/oauth2/token')) return Promise.resolve({data: {access_token: 'tok-1'}});
|
||||
return Promise.resolve({data: {}});
|
||||
@@ -80,7 +81,7 @@ describe('salesforceApexRestPost', () => {
|
||||
});
|
||||
|
||||
it('retries once with a fresh token on a 401, then succeeds', async () => {
|
||||
const {axios, salesforceApexRestPost} = freshImports();
|
||||
const {axios, salesforceApexRestPost} = await freshImports();
|
||||
let tokenFetches = 0;
|
||||
axios.post.mockImplementation((url: string) => {
|
||||
if (url.endsWith('/services/oauth2/token')) {
|
||||
@@ -102,7 +103,7 @@ describe('salesforceApexRestPost', () => {
|
||||
});
|
||||
|
||||
it('does not retry on a non-401 error and rethrows it', async () => {
|
||||
const {axios, salesforceApexRestPost} = freshImports();
|
||||
const {axios, salesforceApexRestPost} = await freshImports();
|
||||
axios.post.mockImplementation((url: string) => {
|
||||
if (url.endsWith('/services/oauth2/token')) return Promise.resolve({data: {access_token: 'tok-1'}});
|
||||
const err: any = new Error('Server error');
|
||||
@@ -117,7 +118,7 @@ describe('salesforceApexRestPost', () => {
|
||||
|
||||
it('throws a clear error when client credentials are not configured', async () => {
|
||||
process.env.SALESFORCE_CLIENT_ID = '';
|
||||
const {salesforceApexRestPost} = freshImports();
|
||||
const {salesforceApexRestPost} = await freshImports();
|
||||
|
||||
await expect(salesforceApexRestPost('/services/apexrest/email/send', {})).rejects.toThrow('SALESFORCE_CLIENT_ID');
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {escapeCsvField} from '../../src/models/feedback/admin/csv.service';
|
||||
import {formatDatetime} from '../../src/models/feedback/feedback.dates';
|
||||
import {describe, it, expect} from 'vitest';
|
||||
import {escapeCsvField} from '../../src/models/feedback/admin/csv.service.js';
|
||||
import {formatDatetime} from '../../src/models/feedback/feedback.dates.js';
|
||||
|
||||
describe('escapeCsvField', () => {
|
||||
it('passes plain text through unchanged', () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {computeDefaultDeadline, slugBase, slugifyName} from '../../src/models/feedback/admin/events.admin.service';
|
||||
import {describe, it, expect} from 'vitest';
|
||||
import {computeDefaultDeadline, slugBase, slugifyName} from '../../src/models/feedback/admin/events.admin.service.js';
|
||||
|
||||
describe('slugifyName', () => {
|
||||
it('lowercases and hyphenates', () => {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import {vi, describe, it, expect, beforeEach, type Mock} from 'vitest';
|
||||
import {Request, Response} from 'express';
|
||||
|
||||
jest.mock('../../src/models/calendar/users/users.service', () => ({
|
||||
checkSession: jest.fn()
|
||||
vi.mock('../../src/models/calendar/users/users.service.js', () => ({
|
||||
checkSession: vi.fn()
|
||||
}));
|
||||
|
||||
import * as UserService from '../../src/models/calendar/users/users.service';
|
||||
import {requireAdminAuth, sessionHeaderAuthenticator} from '../../src/models/feedback/feedback.auth';
|
||||
import * as UserService from '../../src/models/calendar/users/users.service.js';
|
||||
import {requireAdminAuth, sessionHeaderAuthenticator} from '../../src/models/feedback/feedback.auth.js';
|
||||
|
||||
const mockCheckSession = UserService.checkSession as jest.Mock;
|
||||
const mockCheckSession = UserService.checkSession as Mock;
|
||||
|
||||
const makeReq = (headers: Record<string, string>): Request => {
|
||||
return {
|
||||
@@ -18,8 +19,8 @@ const makeReq = (headers: Record<string, string>): Request => {
|
||||
|
||||
const makeRes = (): Response => {
|
||||
const res: any = {};
|
||||
res.status = jest.fn().mockReturnValue(res);
|
||||
res.send = jest.fn().mockReturnValue(res);
|
||||
res.status = vi.fn().mockReturnValue(res);
|
||||
res.send = vi.fn().mockReturnValue(res);
|
||||
res.locals = {};
|
||||
return res as Response;
|
||||
};
|
||||
@@ -65,7 +66,7 @@ describe('requireAdminAuth', () => {
|
||||
mockCheckSession.mockResolvedValue(null);
|
||||
const req = makeReq({});
|
||||
const res = makeRes();
|
||||
const next = jest.fn();
|
||||
const next = vi.fn();
|
||||
|
||||
await requireAdminAuth(req, res, next);
|
||||
|
||||
@@ -77,7 +78,7 @@ describe('requireAdminAuth', () => {
|
||||
mockCheckSession.mockResolvedValue({userId: 1, email: 'a@nachklang.art', fullName: 'Anna Admin', isActive: true});
|
||||
const req = makeReq({'X-Session-Id': '1', 'X-Session-Key': 'k'});
|
||||
const res = makeRes();
|
||||
const next = jest.fn();
|
||||
const next = vi.fn();
|
||||
|
||||
await requireAdminAuth(req, res, next);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {isHoneypotTriggered} from '../../src/models/feedback/public/public.router';
|
||||
import {describe, it, expect} from 'vitest';
|
||||
import {isHoneypotTriggered} from '../../src/models/feedback/public/public.router.js';
|
||||
|
||||
describe('isHoneypotTriggered', () => {
|
||||
it('is false when the field is absent', () => {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Isolated from ratelimit.test.ts because it needs to control whether
|
||||
// FEEDBACK_IP_SALT is present at module-load time, which a real dotenv.config()
|
||||
// call would silently repopulate from the repo's .env file.
|
||||
jest.mock('dotenv', () => ({config: jest.fn()}));
|
||||
jest.mock('../../src/models/feedback/Feedback.db', () => ({
|
||||
NachklangFeedbackDB: {getConnection: jest.fn()}
|
||||
import {vi, describe, it, expect, afterEach} from 'vitest';
|
||||
vi.mock('dotenv', () => ({config: vi.fn()}));
|
||||
vi.mock('../../src/models/feedback/Feedback.db.js', () => ({
|
||||
NachklangFeedbackDB: {getConnection: vi.fn()}
|
||||
}));
|
||||
|
||||
describe('FEEDBACK_IP_SALT enforcement', () => {
|
||||
@@ -11,18 +12,18 @@ describe('FEEDBACK_IP_SALT enforcement', () => {
|
||||
|
||||
afterEach(() => {
|
||||
process.env.FEEDBACK_IP_SALT = originalSalt;
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it('throws at import time when FEEDBACK_IP_SALT is unset, rather than silently hashing unsalted', () => {
|
||||
jest.resetModules();
|
||||
it('throws at import time when FEEDBACK_IP_SALT is unset, rather than silently hashing unsalted', async () => {
|
||||
vi.resetModules();
|
||||
delete process.env.FEEDBACK_IP_SALT;
|
||||
expect(() => require('../../src/models/feedback/feedback.ratelimit')).toThrow(/FEEDBACK_IP_SALT/);
|
||||
await expect(import('../../src/models/feedback/feedback.ratelimit.js')).rejects.toThrow(/FEEDBACK_IP_SALT/);
|
||||
});
|
||||
|
||||
it('does not throw when FEEDBACK_IP_SALT is set', () => {
|
||||
jest.resetModules();
|
||||
it('does not throw when FEEDBACK_IP_SALT is set', async () => {
|
||||
vi.resetModules();
|
||||
process.env.FEEDBACK_IP_SALT = 'a-real-salt';
|
||||
expect(() => require('../../src/models/feedback/feedback.ratelimit')).not.toThrow();
|
||||
await expect(import('../../src/models/feedback/feedback.ratelimit.js')).resolves.toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {hashIp} from '../../src/models/feedback/feedback.ratelimit';
|
||||
import {describe, it, expect} from 'vitest';
|
||||
import {hashIp} from '../../src/models/feedback/feedback.ratelimit.js';
|
||||
|
||||
describe('hashIp', () => {
|
||||
it('never returns the raw IP', () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {aggregateReport} from '../../src/models/feedback/admin/reports.admin.service';
|
||||
import {AnswerRow} from '../../src/models/feedback/admin/reports.admin.interface';
|
||||
import {describe, it, expect} from 'vitest';
|
||||
import {aggregateReport} from '../../src/models/feedback/admin/reports.admin.service.js';
|
||||
import {AnswerRow} from '../../src/models/feedback/admin/reports.admin.interface.js';
|
||||
|
||||
const eventMeta = {eventId: 1, name: 'Sommerkonzert', eventDate: '2026-08-01', feedbackDeadline: '2026-08-15T23:59:59'};
|
||||
const emptyNewsletter = {total: 0, sent: 0, pending: 0, failed: 0, skipped: 0};
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
// The module under test caches its OAuth token at module scope (see
|
||||
// salesforce.service.ts's `cachedToken`), so every test resets the module
|
||||
// registry for a clean cache. That also invalidates any jest.mock() factory
|
||||
// instance captured before the reset, so every mocked dependency (axios,
|
||||
// Feedback.db, the logger) is re-required fresh after each reset rather
|
||||
// than referenced from a top-level import.
|
||||
// registry for a clean cache. Every mocked dependency (axios, Feedback.db,
|
||||
// the logger) is re-imported after the reset rather than referenced from a
|
||||
// top-level import, so the test always holds the same instance the service
|
||||
// under test resolves. Mocked modules survive vi.resetModules(), so their
|
||||
// mock state is reset explicitly in beforeEach.
|
||||
|
||||
jest.mock('axios');
|
||||
jest.mock('../../src/models/feedback/Feedback.db', () => ({
|
||||
NachklangFeedbackDB: {getConnection: jest.fn()}
|
||||
import {vi, describe, it, expect, beforeEach, type Mock} from 'vitest';
|
||||
vi.mock('axios');
|
||||
vi.mock('../../src/models/feedback/Feedback.db.js', () => ({
|
||||
NachklangFeedbackDB: {getConnection: vi.fn()}
|
||||
}));
|
||||
jest.mock('../../src/middleware/logger', () => ({
|
||||
vi.mock('../../src/middleware/logger.js', () => ({
|
||||
__esModule: true,
|
||||
default: {info: jest.fn(), error: jest.fn()}
|
||||
default: {info: vi.fn(), error: vi.fn()}
|
||||
}));
|
||||
|
||||
const SIGNUP_ROW = {
|
||||
@@ -23,30 +25,31 @@ const SIGNUP_ROW = {
|
||||
};
|
||||
|
||||
const makeConn = (rows: any[]) => ({
|
||||
query: jest.fn().mockResolvedValue(rows),
|
||||
end: jest.fn().mockResolvedValue(undefined)
|
||||
query: vi.fn().mockResolvedValue(rows),
|
||||
end: vi.fn().mockResolvedValue(undefined)
|
||||
});
|
||||
|
||||
// Re-requires every mocked dependency fresh (see the note above) and
|
||||
// returns the live references plus the service under test.
|
||||
const freshImports = () => {
|
||||
const axios = require('axios');
|
||||
const {NachklangFeedbackDB} = require('../../src/models/feedback/Feedback.db');
|
||||
const logger = require('../../src/middleware/logger').default;
|
||||
const {syncNewsletterSignup} = require('../../src/models/feedback/integrations/salesforce.service');
|
||||
return {axios, mockGetConnection: NachklangFeedbackDB.getConnection as jest.Mock, logger, syncNewsletterSignup};
|
||||
// Re-imports every mocked dependency (see the note above) and returns the
|
||||
// live references plus the service under test.
|
||||
const freshImports = async () => {
|
||||
const axios: any = (await import('axios')).default;
|
||||
const {NachklangFeedbackDB} = await import('../../src/models/feedback/Feedback.db.js');
|
||||
const logger = (await import('../../src/middleware/logger.js')).default;
|
||||
const {syncNewsletterSignup} = await import('../../src/models/feedback/integrations/salesforce.service.js');
|
||||
return {axios, mockGetConnection: NachklangFeedbackDB.getConnection as Mock, logger, syncNewsletterSignup};
|
||||
};
|
||||
|
||||
const ORIGINAL_ENV = {...process.env};
|
||||
|
||||
describe('syncNewsletterSignup - disabled mode', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
vi.resetAllMocks();
|
||||
process.env = {...ORIGINAL_ENV, SALESFORCE_ENABLED: 'false'};
|
||||
});
|
||||
|
||||
it('logs the payload it would send and does not touch the network or write to the DB', async () => {
|
||||
const {axios, mockGetConnection, logger, syncNewsletterSignup} = freshImports();
|
||||
const {axios, mockGetConnection, logger, syncNewsletterSignup} = await freshImports();
|
||||
const conn = makeConn([SIGNUP_ROW]);
|
||||
mockGetConnection.mockResolvedValue(conn);
|
||||
|
||||
@@ -66,7 +69,7 @@ describe('syncNewsletterSignup - disabled mode', () => {
|
||||
});
|
||||
|
||||
it('logs and returns without calling the network when the signup row does not exist', async () => {
|
||||
const {axios, mockGetConnection, logger, syncNewsletterSignup} = freshImports();
|
||||
const {axios, mockGetConnection, logger, syncNewsletterSignup} = await freshImports();
|
||||
mockGetConnection.mockResolvedValue(makeConn([]));
|
||||
|
||||
await syncNewsletterSignup(999);
|
||||
@@ -78,7 +81,8 @@ describe('syncNewsletterSignup - disabled mode', () => {
|
||||
|
||||
describe('syncNewsletterSignup - enabled mode', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
vi.resetAllMocks();
|
||||
process.env = {
|
||||
...ORIGINAL_ENV,
|
||||
SALESFORCE_ENABLED: 'true',
|
||||
@@ -89,7 +93,7 @@ describe('syncNewsletterSignup - enabled mode', () => {
|
||||
});
|
||||
|
||||
it('fetches a token, posts the signup, and marks the row SENT with the returned record id', async () => {
|
||||
const {axios, mockGetConnection, syncNewsletterSignup} = freshImports();
|
||||
const {axios, mockGetConnection, syncNewsletterSignup} = await freshImports();
|
||||
const updateConn = makeConn([]);
|
||||
mockGetConnection.mockResolvedValueOnce(makeConn([SIGNUP_ROW])).mockResolvedValueOnce(updateConn);
|
||||
axios.post.mockImplementation((url: string) => {
|
||||
@@ -116,7 +120,7 @@ describe('syncNewsletterSignup - enabled mode', () => {
|
||||
});
|
||||
|
||||
it('reuses the cached token across two calls instead of fetching twice', async () => {
|
||||
const {axios, mockGetConnection, syncNewsletterSignup} = freshImports();
|
||||
const {axios, mockGetConnection, syncNewsletterSignup} = await freshImports();
|
||||
mockGetConnection
|
||||
.mockResolvedValueOnce(makeConn([SIGNUP_ROW]))
|
||||
.mockResolvedValueOnce(makeConn([]))
|
||||
@@ -135,7 +139,7 @@ describe('syncNewsletterSignup - enabled mode', () => {
|
||||
});
|
||||
|
||||
it('retries once with a fresh token on a 401, then succeeds', async () => {
|
||||
const {axios, mockGetConnection, syncNewsletterSignup} = freshImports();
|
||||
const {axios, mockGetConnection, syncNewsletterSignup} = await freshImports();
|
||||
const updateConn = makeConn([]);
|
||||
mockGetConnection.mockResolvedValueOnce(makeConn([SIGNUP_ROW])).mockResolvedValueOnce(updateConn);
|
||||
|
||||
@@ -163,7 +167,7 @@ describe('syncNewsletterSignup - enabled mode', () => {
|
||||
});
|
||||
|
||||
it('marks the row FAILED with the error message on a non-401 error, without throwing', async () => {
|
||||
const {axios, mockGetConnection, logger, syncNewsletterSignup} = freshImports();
|
||||
const {axios, mockGetConnection, logger, syncNewsletterSignup} = await freshImports();
|
||||
const updateConn = makeConn([]);
|
||||
mockGetConnection.mockResolvedValueOnce(makeConn([SIGNUP_ROW])).mockResolvedValueOnce(updateConn);
|
||||
axios.post.mockImplementation((url: string) => {
|
||||
@@ -184,7 +188,7 @@ describe('syncNewsletterSignup - enabled mode', () => {
|
||||
|
||||
it('marks the row FAILED with a clear message when client credentials are not configured', async () => {
|
||||
process.env.SALESFORCE_CLIENT_ID = '';
|
||||
const {mockGetConnection, syncNewsletterSignup} = freshImports();
|
||||
const {mockGetConnection, syncNewsletterSignup} = await freshImports();
|
||||
const updateConn = makeConn([]);
|
||||
mockGetConnection.mockResolvedValueOnce(makeConn([SIGNUP_ROW])).mockResolvedValueOnce(updateConn);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {MAX_ANSWER_ROWS, validateAnswers, validateGuestBook, validateNewsletter} from '../../src/models/feedback/public/submissions.service';
|
||||
import {describe, it, expect} from 'vitest';
|
||||
import {MAX_ANSWER_ROWS, validateAnswers, validateGuestBook, validateNewsletter} from '../../src/models/feedback/public/submissions.service.js';
|
||||
|
||||
type QuestionLookup = Map<number, {eventQuestionId: number; questionId: number; type: 'SONG_PICK' | 'SONG_RATING' | 'FREE_TEXT'; label: string; position: number}>;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {test, expect} from 'vitest';
|
||||
test('Test template', async () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
// tickets.confirmation-email builds and sends the redemption confirmation
|
||||
// email, shared by the public redeem path and the admin resend action.
|
||||
|
||||
jest.mock('../../src/models/calendar/events/events.service', () => ({
|
||||
getEventById: jest.fn()
|
||||
import {vi, describe, it, expect, beforeEach, type Mock} from 'vitest';
|
||||
vi.mock('../../src/models/calendar/events/events.service.js', () => ({
|
||||
getEventById: vi.fn()
|
||||
}));
|
||||
jest.mock('../../src/models/calendar/events/icalgenerator.service', () => ({
|
||||
convertToIcal: jest.fn()
|
||||
vi.mock('../../src/models/calendar/events/icalgenerator.service.js', () => ({
|
||||
convertToIcal: vi.fn()
|
||||
}));
|
||||
jest.mock('../../src/common/common.mail', () => ({
|
||||
MailService: {sendMail: jest.fn()}
|
||||
vi.mock('../../src/common/common.mail.js', () => ({
|
||||
MailService: {sendMail: vi.fn()}
|
||||
}));
|
||||
jest.mock('../../src/models/tickets/Tickets.db', () => ({
|
||||
NachklangTicketsDB: {getConnection: jest.fn()}
|
||||
vi.mock('../../src/models/tickets/Tickets.db.js', () => ({
|
||||
NachklangTicketsDB: {getConnection: vi.fn()}
|
||||
}));
|
||||
jest.mock('../../src/middleware/logger', () => ({
|
||||
vi.mock('../../src/middleware/logger.js', () => ({
|
||||
__esModule: true,
|
||||
default: {info: jest.fn(), warn: jest.fn(), error: jest.fn()}
|
||||
default: {info: vi.fn(), warn: vi.fn(), error: vi.fn()}
|
||||
}));
|
||||
|
||||
import * as EventsService from '../../src/models/calendar/events/events.service';
|
||||
import * as IcalService from '../../src/models/calendar/events/icalgenerator.service';
|
||||
import {MailService} from '../../src/common/common.mail';
|
||||
import logger from '../../src/middleware/logger';
|
||||
import {NachklangTicketsDB} from '../../src/models/tickets/Tickets.db';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../../src/models/tickets/tickets.confirmation-email';
|
||||
import * as EventsService from '../../src/models/calendar/events/events.service.js';
|
||||
import * as IcalService from '../../src/models/calendar/events/icalgenerator.service.js';
|
||||
import {MailService} from '../../src/common/common.mail.js';
|
||||
import logger from '../../src/middleware/logger.js';
|
||||
import {NachklangTicketsDB} from '../../src/models/tickets/Tickets.db.js';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../../src/models/tickets/tickets.confirmation-email.js';
|
||||
|
||||
const mockGetEvent = EventsService.getEventById as jest.Mock;
|
||||
const mockToIcal = IcalService.convertToIcal as jest.Mock;
|
||||
const mockSendMail = MailService.sendMail as jest.Mock;
|
||||
const mockLogger = logger as unknown as {info: jest.Mock; warn: jest.Mock; error: jest.Mock};
|
||||
const mockGetConnection = NachklangTicketsDB.getConnection as jest.Mock;
|
||||
const mockGetEvent = EventsService.getEventById as Mock;
|
||||
const mockToIcal = IcalService.convertToIcal as Mock;
|
||||
const mockSendMail = MailService.sendMail as Mock;
|
||||
const mockLogger = logger as unknown as {info: Mock; warn: Mock; error: Mock};
|
||||
const mockGetConnection = NachklangTicketsDB.getConnection as Mock;
|
||||
|
||||
const EVENT = {
|
||||
eventId: 42,
|
||||
@@ -47,7 +48,7 @@ const RECIPIENT = {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
mockGetEvent.mockResolvedValue(EVENT);
|
||||
mockToIcal.mockResolvedValue('BEGIN:VCALENDAR\nEND:VCALENDAR');
|
||||
mockSendMail.mockResolvedValue(true);
|
||||
@@ -97,7 +98,7 @@ describe('sendRedemptionConfirmation', () => {
|
||||
});
|
||||
|
||||
describe('recordConfirmationEmailResult', () => {
|
||||
const makeConn = () => ({query: jest.fn().mockResolvedValue(undefined), end: jest.fn().mockResolvedValue(undefined)});
|
||||
const makeConn = () => ({query: vi.fn().mockResolvedValue(undefined), end: vi.fn().mockResolvedValue(undefined)});
|
||||
|
||||
it('writes SENT when the mail was accepted', async () => {
|
||||
const conn = makeConn();
|
||||
@@ -122,7 +123,7 @@ describe('recordConfirmationEmailResult', () => {
|
||||
});
|
||||
|
||||
it('swallows a DB error rather than throwing', async () => {
|
||||
const conn = {query: jest.fn().mockRejectedValue(new Error('db down')), end: jest.fn().mockResolvedValue(undefined)};
|
||||
const conn = {query: vi.fn().mockRejectedValue(new Error('db down')), end: vi.fn().mockResolvedValue(undefined)};
|
||||
mockGetConnection.mockResolvedValue(conn);
|
||||
|
||||
await expect(recordConfirmationEmailResult(7, true)).resolves.toBeUndefined();
|
||||
|
||||
@@ -3,21 +3,22 @@
|
||||
// exercised here; the shared send/record logic is covered by
|
||||
// confirmation-email.test.ts.
|
||||
|
||||
jest.mock('../../src/models/tickets/Tickets.db', () => ({
|
||||
NachklangTicketsDB: {getConnection: jest.fn()}
|
||||
import {vi, describe, it, expect, beforeEach, type Mock} from 'vitest';
|
||||
vi.mock('../../src/models/tickets/Tickets.db.js', () => ({
|
||||
NachklangTicketsDB: {getConnection: vi.fn()}
|
||||
}));
|
||||
jest.mock('../../src/models/tickets/tickets.confirmation-email', () => ({
|
||||
sendRedemptionConfirmation: jest.fn(),
|
||||
recordConfirmationEmailResult: jest.fn()
|
||||
vi.mock('../../src/models/tickets/tickets.confirmation-email.js', () => ({
|
||||
sendRedemptionConfirmation: vi.fn(),
|
||||
recordConfirmationEmailResult: vi.fn()
|
||||
}));
|
||||
|
||||
import {NachklangTicketsDB} from '../../src/models/tickets/Tickets.db';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../../src/models/tickets/tickets.confirmation-email';
|
||||
import {resendRedemptionConfirmation} from '../../src/models/tickets/admin/redemptions.admin.service';
|
||||
import {NachklangTicketsDB} from '../../src/models/tickets/Tickets.db.js';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../../src/models/tickets/tickets.confirmation-email.js';
|
||||
import {resendRedemptionConfirmation} from '../../src/models/tickets/admin/redemptions.admin.service.js';
|
||||
|
||||
const mockGetConnection = NachklangTicketsDB.getConnection as jest.Mock;
|
||||
const mockSend = sendRedemptionConfirmation as jest.Mock;
|
||||
const mockRecord = recordConfirmationEmailResult as jest.Mock;
|
||||
const mockGetConnection = NachklangTicketsDB.getConnection as Mock;
|
||||
const mockSend = sendRedemptionConfirmation as Mock;
|
||||
const mockRecord = recordConfirmationEmailResult as Mock;
|
||||
|
||||
const ACTIVE_ROW = {
|
||||
redemption_id: 5,
|
||||
@@ -34,15 +35,15 @@ const ACTIVE_ROW = {
|
||||
|
||||
// getRedemption issues: 1) SELECT redemptions, 2) SELECT redemption_guests
|
||||
const connFor = (redemptionRows: any[], guestRows: any[] = []) => ({
|
||||
query: jest
|
||||
query: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(redemptionRows)
|
||||
.mockResolvedValueOnce(guestRows),
|
||||
end: jest.fn().mockResolvedValue(undefined)
|
||||
end: vi.fn().mockResolvedValue(undefined)
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
mockSend.mockResolvedValue(true);
|
||||
});
|
||||
|
||||
|
||||
+15
-98
@@ -1,103 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
/* The API is native ESM ("type": "module" in package.json). nodenext makes
|
||||
tsc emit ESM, requires the ".js" suffix on relative imports, and treats
|
||||
CommonJS dependencies (express, mariadb, winston, ...) via default imports. */
|
||||
"module": "nodenext",
|
||||
"target": "es2024",
|
||||
"lib": ["es2024"],
|
||||
"types": ["node"],
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
"outDir": "./dist",
|
||||
"inlineSourceMap": true,
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
"inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["app.ts", "src/**/*.ts", "test/**/*.ts", "vitest.config.ts"]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import {defineConfig} from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ['test/**/*.test.ts'],
|
||||
environment: 'node',
|
||||
// feedback.ratelimit throws at import time without a salt (see
|
||||
// test/feedback/ratelimit.salt-guard.test.ts). Set one here so the suite
|
||||
// passes on a clean checkout without a local .env; the salt-guard test
|
||||
// deletes it explicitly before exercising the missing-salt path.
|
||||
env: {
|
||||
FEEDBACK_IP_SALT: 'vitest-salt'
|
||||
},
|
||||
reporters: [
|
||||
'default',
|
||||
['vitest-sonar-reporter', {outputFile: 'testResults/sonar-report.xml'}]
|
||||
],
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['text-summary', 'lcov'],
|
||||
reportsDirectory: 'coverage',
|
||||
include: ['app.ts', 'src/**/*.ts']
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user