Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(nx/server): set up e2e
Elian Dorane18613148b0a
diff --git a/_regroup/package.json b/_regroup/package.jsonindex f7ffc2fa68..43e6cea17e 100644--- a/_regroup/package.json+++ b/_regroup/package.json@@ -24,7 +24,7 @@"client:coverage": "cross-env TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db TRILIUM_INTEGRATION_TEST=memory vitest --root src/public/app --coverage","test:playwright": "playwright test --workers 1","test:integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts",- "test:integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts",+ "test:integration-mem-db": "cross-env nodemon src/main.ts","test:integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts","dev:watch-dist": "tsx ./bin/watch-dist.ts","dev:format-check": "eslint -c eslint.format.config.js .",diff --git a/_regroup/playwright.config.ts b/_regroup/playwright.config.tsindex 04bc7aaec4..f5ac29541d 100644--- a/_regroup/playwright.config.ts+++ b/_regroup/playwright.config.ts@@ -27,9 +27,6 @@ export default defineConfig({reporter: "html",/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */use: {- /* Base URL to use in actions like `await page.goto('/')`. */- baseURL: SERVER_URL,-/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */trace: "on-first-retry"},diff --git a/apps/client-e2e/src/example.spec.ts b/apps/client-e2e/src/example.spec.tsdeleted file mode 100644index fa8f1f3351..0000000000--- a/apps/client-e2e/src/example.spec.ts+++ /dev/null@@ -1,8 +0,0 @@-import { test, expect } from '@playwright/test';--test('has title', async ({ page }) => {- await page.goto('/');-- // Expect h1 to contain a substring.- expect(await page.locator('h1').innerText()).toContain('Welcome');-});diff --git a/apps/desktop-e2e/.spec.swcrc b/apps/desktop-e2e/.spec.swcrcdeleted file mode 100644index 3b52a5376b..0000000000--- a/apps/desktop-e2e/.spec.swcrc+++ /dev/null@@ -1,22 +0,0 @@-{- "jsc": {- "target": "es2017",- "parser": {- "syntax": "typescript",- "decorators": true,- "dynamicImport": true- },- "transform": {- "decoratorMetadata": true,- "legacyDecorator": true- },- "keepClassNames": true,- "externalHelpers": true,- "loose": true- },- "module": {- "type": "es6"- },- "sourceMaps": true,- "exclude": []-}diff --git a/apps/desktop-e2e/eslint.config.mjs b/apps/desktop-e2e/eslint.config.mjsdeleted file mode 100644index 724052a2e2..0000000000--- a/apps/desktop-e2e/eslint.config.mjs+++ /dev/null@@ -1,5 +0,0 @@-import baseConfig from "../../eslint.config.mjs";--export default [- ...baseConfig-];diff --git a/apps/desktop-e2e/jest.config.ts b/apps/desktop-e2e/jest.config.tsdeleted file mode 100644index 25564ee814..0000000000--- a/apps/desktop-e2e/jest.config.ts+++ /dev/null@@ -1,24 +0,0 @@-/* eslint-disable */-import { readFileSync } from 'fs';--// Reading the SWC compilation config for the spec files-const swcJestConfig = JSON.parse(- readFileSync(`${__dirname}/.spec.swcrc`, 'utf-8')-);--// Disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves-swcJestConfig.swcrc = false;--export default {- displayName: '@triliumnext/desktop-e2e',- preset: '../../jest.preset.js',- globalSetup: '<rootDir>/src/support/global-setup.ts',- globalTeardown: '<rootDir>/src/support/global-teardown.ts',- setupFiles: ['<rootDir>/src/support/test-setup.ts'],- testEnvironment: 'node',- transform: {- '^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],- },- moduleFileExtensions: ['ts', 'js', 'html'],- coverageDirectory: 'test-output/jest/coverage',-};diff --git a/apps/desktop-e2e/package.json b/apps/desktop-e2e/package.jsondeleted file mode 100644index 37556fa95c..0000000000--- a/apps/desktop-e2e/package.json+++ /dev/null@@ -1,25 +0,0 @@-{- "name": "@triliumnext/desktop-e2e",- "version": "0.0.1",- "private": true,- "nx": {- "implicitDependencies": [- "@triliumnext/desktop"- ],- "targets": {- "e2e": {- "executor": "@nx/jest:jest",- "outputs": [- "{projectRoot}/test-output/jest/coverage"- ],- "options": {- "jestConfig": "apps/desktop-e2e/jest.config.ts",- "passWithNoTests": true- },- "dependsOn": [- "@triliumnext/desktop:build"- ]- }- }- }-}diff --git a/apps/desktop-e2e/src/desktop/desktop.spec.ts b/apps/desktop-e2e/src/desktop/desktop.spec.tsdeleted file mode 100644index 52572d00fd..0000000000--- a/apps/desktop-e2e/src/desktop/desktop.spec.ts+++ /dev/null@@ -1,10 +0,0 @@-import axios from 'axios';--describe('GET /', () => {- it('should return a message', async () => {- const res = await axios.get(`/`);-- expect(res.status).toBe(200);- expect(res.data).toEqual({ message: 'Hello API' });- });-})diff --git a/apps/desktop-e2e/src/support/global-setup.ts b/apps/desktop-e2e/src/support/global-setup.tsdeleted file mode 100644index d18e0f2947..0000000000--- a/apps/desktop-e2e/src/support/global-setup.ts+++ /dev/null@@ -1,11 +0,0 @@-/* eslint-disable */-var __TEARDOWN_MESSAGE__: string;--module.exports = async function() {- // Start services that that the app needs to run (e.g. database, docker-compose, etc.).- console.log('\nSetting up...\n');-- // Hint: Use `globalThis` to pass variables to global teardown.- globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';-};-diff --git a/apps/desktop-e2e/src/support/global-teardown.ts b/apps/desktop-e2e/src/support/global-teardown.tsdeleted file mode 100644index 67746cebd3..0000000000--- a/apps/desktop-e2e/src/support/global-teardown.ts+++ /dev/null@@ -1,7 +0,0 @@-/* eslint-disable */--module.exports = async function() {- // Put clean up logic here (e.g. stopping services, docker-compose, etc.).- // Hint: `globalThis` is shared between setup and teardown.- console.log(globalThis.__TEARDOWN_MESSAGE__);-};diff --git a/apps/desktop-e2e/src/support/test-setup.ts b/apps/desktop-e2e/src/support/test-setup.tsdeleted file mode 100644index c803356a28..0000000000--- a/apps/desktop-e2e/src/support/test-setup.ts+++ /dev/null@@ -1,9 +0,0 @@-/* eslint-disable */-import axios from 'axios';--module.exports = async function() {- // Configure axios for tests to use.- const host = process.env.HOST ?? 'localhost';- const port = process.env.PORT ?? '3000';- axios.defaults.baseURL = `http://${host}:${port}`;-};diff --git a/apps/desktop-e2e/tsconfig.json b/apps/desktop-e2e/tsconfig.jsondeleted file mode 100644index 2e98c0f609..0000000000--- a/apps/desktop-e2e/tsconfig.json+++ /dev/null@@ -1,14 +0,0 @@-{- "extends": "../../tsconfig.base.json",- "compilerOptions": {- "outDir": "out-tsc/@triliumnext/desktop-e2e",- "esModuleInterop": true,- "noUnusedLocals": false,- "noImplicitAny": false- },- "include": [- "jest.config.ts",- "src/**/*.ts"- ],- "references": []-}diff --git a/apps/server-e2e/.env b/apps/server-e2e/.envnew file mode 100644index 0000000000..f13f7d757a--- /dev/null+++ b/apps/server-e2e/.env@@ -0,0 +1,3 @@+TRILIUM_INTEGRATION_TEST=memory+TRILIUM_PORT=8082+TRILIUM_DATA_DIR=apps/server/spec/db\ No newline at end of filediff --git a/apps/client-e2e/eslint.config.mjs b/apps/server-e2e/eslint.config.mjssimilarity index 100%rename from apps/client-e2e/eslint.config.mjsrename to apps/server-e2e/eslint.config.mjsdiff --git a/apps/client-e2e/package.json b/apps/server-e2e/package.jsonsimilarity index 50%rename from apps/client-e2e/package.jsonrename to apps/server-e2e/package.jsonindex 1ada09ee32..631bc2bf59 100644--- a/apps/client-e2e/package.json+++ b/apps/server-e2e/package.json@@ -1,10 +1,11 @@{- "name": "@triliumnext/client-e2e",+ "name": "@triliumnext/server-e2e","version": "0.0.1","private": true,"nx": {"implicitDependencies": [- "@triliumnext/client"+ "@triliumnext/client",+ "@triliumnext/server"]}}diff --git a/apps/client-e2e/playwright.config.ts b/apps/server-e2e/playwright.config.tssimilarity index 80%rename from apps/client-e2e/playwright.config.tsrename to apps/server-e2e/playwright.config.tsindex cbedd67407..0e87606535 100644--- a/apps/client-e2e/playwright.config.ts+++ b/apps/server-e2e/playwright.config.ts@@ -3,7 +3,8 @@ import { nxE2EPreset } from '@nx/playwright/preset';import { workspaceRoot } from '@nx/devkit';// For CI, you may want to set BASE_URL to the deployed application.-const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';+const port = process.env['TRILIUM_PORT'];+const baseURL = process.env['BASE_URL'] || `http://localhost:${port}`;/*** Read environment variables from file.@@ -24,8 +25,8 @@ export default defineConfig({},/* Run your local dev server before starting the tests */webServer: {- command: 'npx nx run @triliumnext/client:serve-static',- url: 'http://localhost:4200',+ command: 'pnpm server:start-prod',+ url: baseURL,reuseExistingServer: !process.env.CI,cwd: workspaceRoot},@@ -35,16 +36,16 @@ export default defineConfig({use: { ...devices["Desktop Chrome"] },},- {- name: "firefox",- use: { ...devices["Desktop Firefox"] },- },+ // {+ // name: "firefox",+ // use: { ...devices["Desktop Firefox"] },+ // },++ // {+ // name: "webkit",+ // use: { ...devices["Desktop Safari"] },+ // },- {- name: "webkit",- use: { ...devices["Desktop Safari"] },- },-// Uncomment for mobile browsers support/* {name: 'Mobile Chrome',diff --git a/_regroup/e2e/help.spec.ts b/apps/server-e2e/src/help.spec.tssimilarity index 100%rename from _regroup/e2e/help.spec.tsrename to apps/server-e2e/src/help.spec.tsdiff --git a/_regroup/e2e/i18n.spec.ts b/apps/server-e2e/src/i18n.spec.tssimilarity index 100%rename from _regroup/e2e/i18n.spec.tsrename to apps/server-e2e/src/i18n.spec.tsdiff --git a/_regroup/e2e/layout/tab_bar.spec.ts b/apps/server-e2e/src/layout/tab_bar.spec.tssimilarity index 100%rename from _regroup/e2e/layout/tab_bar.spec.tsrename to apps/server-e2e/src/layout/tab_bar.spec.tsdiff --git a/_regroup/e2e/note_types/code.spec.ts b/apps/server-e2e/src/note_types/code.spec.tssimilarity index 100%rename from _regroup/e2e/note_types/code.spec.tsrename to apps/server-e2e/src/note_types/code.spec.tsdiff --git a/_regroup/e2e/note_types/mermaid.spec.ts b/apps/server-e2e/src/note_types/mermaid.spec.tssimilarity index 100%rename from _regroup/e2e/note_types/mermaid.spec.tsrename to apps/server-e2e/src/note_types/mermaid.spec.tsdiff --git a/_regroup/e2e/note_types/mindmap.spec.ts b/apps/server-e2e/src/note_types/mindmap.spec.tssimilarity index 100%rename from _regroup/e2e/note_types/mindmap.spec.tsrename to apps/server-e2e/src/note_types/mindmap.spec.tsdiff --git a/_regroup/e2e/note_types/note_map.spec.ts b/apps/server-e2e/src/note_types/note_map.spec.tssimilarity index 100%rename from _regroup/e2e/note_types/note_map.spec.tsrename to apps/server-e2e/src/note_types/note_map.spec.tsdiff --git a/_regroup/e2e/note_types/text.spec.ts b/apps/server-e2e/src/note_types/text.spec.tssimilarity index 100%rename from _regroup/e2e/note_types/text.spec.tsrename to apps/server-e2e/src/note_types/text.spec.tsdiff --git a/_regroup/e2e/shared_notes.spec.ts b/apps/server-e2e/src/shared_notes.spec.tssimilarity index 100%rename from _regroup/e2e/shared_notes.spec.tsrename to apps/server-e2e/src/shared_notes.spec.tsdiff --git a/_regroup/e2e/support/app.ts b/apps/server-e2e/src/support/app.tssimilarity index 100%rename from _regroup/e2e/support/app.tsrename to apps/server-e2e/src/support/app.tsdiff --git a/apps/client-e2e/tsconfig.json b/apps/server-e2e/tsconfig.jsonsimilarity index 100%rename from apps/client-e2e/tsconfig.jsonrename to apps/server-e2e/tsconfig.jsondiff --git a/apps/server/.start-prod.env b/apps/server/.start-prod.envnew file mode 100644index 0000000000..b5c2492430--- /dev/null+++ b/apps/server/.start-prod.env@@ -0,0 +1,2 @@+TRILIUM_ENV=production+TRILIUM_DATA_DIR=./apps/server/data\ No newline at end of filediff --git a/apps/server/package.json b/apps/server/package.jsonindex 8ac5e4a06b..1700422b78 100644--- a/apps/server/package.json+++ b/apps/server/package.json@@ -150,6 +150,10 @@"dependsOn": [ "build" ],"command": "bash apps/server/scripts/build-server.sh"},+ "start-prod": {+ "dependsOn": [ "build" ],+ "command": "node apps/server/dist/main.js"+ },"docker-build": {"dependsOn": ["build"diff --git a/apps/server/src/services/llm/index_service.ts b/apps/server/src/services/llm/index_service.tsindex 8d4adae9dc..7006a13b15 100644--- a/apps/server/src/services/llm/index_service.ts+++ b/apps/server/src/services/llm/index_service.ts@@ -54,7 +54,7 @@ class IndexService {return;}- const aiEnabled = await options.getOptionBool('aiEnabled');+ const aiEnabled = options.getOptionOrNull('aiEnabled') === "true";if (!aiEnabled) {log.info("Index service: AI features disabled, skipping initialization");return;diff --git a/package.json b/package.jsonindex 08f25f2596..4c659cec31 100644--- a/package.json+++ b/package.json@@ -9,7 +9,7 @@"client:build": "nx build client","server:build": "nx build server","server:start": "nx run-many --target=serve --projects=client,server --parallel",- "server:start-prod": "pnpm server:build && cross-env TRILIUM_DATA_DIR=apps/server/data node apps/server/dist/main.js",+ "server:start-prod": "nx run @triliumnext/server:start-prod","electron:build": "nx build desktop","chore:ci-update-nightly-version": "tsx ./scripts/update-nightly-version.ts","chore:update-build-info": "tsx ./scripts/update-build-info.ts",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 15a15b4e9f..a8a3f359f2 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -287,8 +287,6 @@ importers:specifier: 0.7.2version: 0.7.2- apps/client-e2e: {}-apps/desktop:dependencies:'@electron/remote':@@ -351,7 +349,7 @@ importers:version: 1.0.2copy-webpack-plugin:specifier: 13.0.0- version: 13.0.0([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected])))+ version: 13.0.0([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))electron:specifier: 35.1.5version: 35.1.5@@ -359,8 +357,6 @@ importers:specifier: ^7.1.1version: 7.1.3- apps/desktop-e2e: {}-apps/server:dependencies:'@highlightjs/cdn-assets':@@ -531,7 +527,7 @@ importers:version: 1.4.7copy-webpack-plugin:specifier: 13.0.0- version: 13.0.0([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected])))+ version: 13.0.0([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))csrf-csrf:specifier: 3.1.0version: 3.1.0@@ -702,7 +698,7 @@ importers:version: 1.0.1webpack:specifier: 5.99.6- version: 5.99.6(@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected]))+ version: 5.99.6(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])ws:specifier: 8.18.1version: 8.18.1([email protected])([email protected])@@ -713,6 +709,8 @@ importers:specifier: 3.2.0version: 3.2.0+ apps/server-e2e: {}+packages/commons:dependencies:'@swc/helpers':@@ -15284,14 +15282,14 @@ snapshots:serialize-javascript: 6.0.2webpack: 5.98.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])- [email protected]([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected]))):+ [email protected]([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])):dependencies:glob-parent: 6.0.2normalize-path: 3.0.0schema-utils: 4.3.2serialize-javascript: 6.0.2tinyglobby: 0.2.13- webpack: 5.99.6(@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected]))+ webpack: 5.99.6(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])dependencies:@@ -20550,14 +20548,14 @@ snapshots:'@swc/core': 1.5.29(@swc/[email protected])esbuild: 0.19.12- [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected]))):+ [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])):dependencies:'@jridgewell/trace-mapping': 0.3.25jest-worker: 27.5.1schema-utils: 4.3.2serialize-javascript: 6.0.2terser: 5.39.0- webpack: 5.99.6(@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected]))+ webpack: 5.99.6(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])optionalDependencies:'@swc/core': 1.5.29(@swc/[email protected])esbuild: 0.19.12@@ -21232,7 +21230,7 @@ snapshots:- esbuild- uglify-js- [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected])):+ [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]):dependencies:'@types/eslint-scope': 3.7.7'@types/estree': 1.0.7@@ -21254,7 +21252,7 @@ snapshots:neo-async: 2.6.2schema-utils: 4.3.2tapable: 2.2.1- terser-webpack-plugin: 5.3.14(@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])([email protected])))+ terser-webpack-plugin: 5.3.14(@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))watchpack: 2.4.2webpack-sources: 3.2.3optionalDependencies:diff --git a/tsconfig.json b/tsconfig.jsonindex f8a33c8a92..6593e8fbc7 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -16,16 +16,13 @@"path": "./packages/turndown-plugin-gfm"},{- "path": "./apps/client-e2e"+ "path": "./apps/server-e2e"},{"path": "./apps/client"},{"path": "./apps/desktop"- },- {- "path": "./apps/desktop-e2e"}]}