Delete old server and improve project configuration
Changes:
- Delete old server files from project root
- /app.ts
- /jamiDaemon.ts
- /routes/
- /rollup.config.js
- /jamiServerConfig.json
- /*.env
- Remake tsconfig.json for client, common, and server
- Delete root /tsconfig.json
- Make subproject tsconfig.json files standalone
- Improve consistency between tsconfig.json files
- Move Cypress and Sentry tests to client/
- Update README.md, Dockerfile and .dockerignore
- Remove extra symlink
- Remove mentions and links to old server (e.g. ports)
- Remove boilerplate project in test/, which has nothing to do with tests
- Update package.json to remove scripts for old server
- Update .gitignores to be consistent with their folder contents
GitLab: #109
Change-Id: Ie575113288c973115c3236e030b02d1a54e3510c
diff --git a/client/.env.development b/client/.env.development
index 503c414..9eacc2e 100644
--- a/client/.env.development
+++ b/client/.env.development
@@ -1,5 +1,2 @@
ESLINT_NO_DEV_ERRORS=true
VITE_API_URL=http://localhost:5000
-
-# This is the url to the temporary socket server in `jami-web/routes/fakeServerForWebRTC.js`
-VITE_SOCKET_URL=
diff --git a/client/.gitignore b/client/.gitignore
index 567609b..5b9d5d8 100644
--- a/client/.gitignore
+++ b/client/.gitignore
@@ -1 +1,3 @@
-build/
+sentry.config.json
+sentry-client.config.json
+sentry-server.config.json
diff --git a/client/README.md b/client/README.md
index 404ef57..adfd192 100644
--- a/client/README.md
+++ b/client/README.md
@@ -49,6 +49,16 @@
The translations are handled by [i18next](https://www.i18next.com/)
+## Sentry
+
+- uncomment the line `// import config from "./sentry-server.config.json" assert { type: "json" };` in `./sentry.js`
+
+- uncomment the line `// import config from "../sentry-client.config.json"` and the init config`Sentry.init(...` in `./client/index.js`
+
+- uncomment the lines `// import { sentrySetUp } from './sentry.js'` and `sentrySetUp(app)` in `./app.ts`
+
+- add `sentry-client.config.json` file in `client` and `sentry-server.config.json` (ask them to an admin) in your project root
+
## Learn More
You can learn more in the [Vite documentation](https://vitejs.dev/guide/).
diff --git a/client/cypress.config.ts b/client/cypress.config.ts
new file mode 100644
index 0000000..a938d8b
--- /dev/null
+++ b/client/cypress.config.ts
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+import { defineConfig } from 'cypress';
+
+export default defineConfig({
+ e2e: {
+ setupNodeEvents(_on, _config) {
+ // implement node event listeners here
+ },
+ },
+});
diff --git a/client/cypress/fixtures/example.json b/client/cypress/fixtures/example.json
new file mode 100644
index 0000000..02e4254
--- /dev/null
+++ b/client/cypress/fixtures/example.json
@@ -0,0 +1,5 @@
+{
+ "name": "Using fixtures to represent data",
+ "email": "hello@cypress.io",
+ "body": "Fixtures are a great way to mock data for responses to routes"
+}
diff --git a/client/cypress/support/commands.ts b/client/cypress/support/commands.ts
new file mode 100644
index 0000000..1bc5b73
--- /dev/null
+++ b/client/cypress/support/commands.ts
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+
+/// <reference types="cypress" />
+// ***********************************************
+// This example commands.ts shows you how to
+// create various custom commands and overwrite
+// existing commands.
+//
+// For more comprehensive examples of custom
+// commands please read more here:
+// https://on.cypress.io/custom-commands
+// ***********************************************
+//
+//
+// -- This is a parent command --
+// Cypress.Commands.add('login', (email, password) => { ... })
+//
+//
+// -- This is a child command --
+// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
+//
+//
+// -- This is a dual command --
+// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
+//
+//
+// -- This will overwrite an existing command --
+// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
+//
+// declare global {
+// namespace Cypress {
+// interface Chainable {
+// login(email: string, password: string): Chainable<void>
+// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
+// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
+// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
+// }
+// }
+// }
diff --git a/client/cypress/support/e2e.ts b/client/cypress/support/e2e.ts
new file mode 100644
index 0000000..cc5cc3c
--- /dev/null
+++ b/client/cypress/support/e2e.ts
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+
+// ***********************************************************
+// This example support/e2e.ts is processed and
+// loaded automatically before your test files.
+//
+// This is a great place to put global configuration and
+// behavior that modifies Cypress.
+//
+// You can change the location of this file or turn off
+// automatically serving support files with the
+// 'supportFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/configuration
+// ***********************************************************
+
+// Import commands.js using ES2015 syntax:
+import './commands';
+
+// Alternatively you can use CommonJS syntax:
+// require('./commands')
diff --git a/client/package.json b/client/package.json
index 9bed075..e8e26f0 100644
--- a/client/package.json
+++ b/client/package.json
@@ -1,6 +1,6 @@
{
"name": "jami-web-client",
- "version": "0.1.0",
+ "version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
@@ -9,6 +9,7 @@
"build": "tsc && vite build",
"clean": "rm -rf dist",
"test": "jest src",
+ "test:cypress": "cypress open",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"format": "prettier --write src",
@@ -33,13 +34,13 @@
"@mui/lab": "^5.0.0-alpha.99",
"@mui/material": "^5.10.5",
"@reduxjs/toolkit": "^1.8.5",
+ "@sentry/node": "^7.13.0",
"@sentry/react": "^7.11.1",
"@sentry/tracing": "^7.11.1",
"@tanstack/react-query": "^4.3.4",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.4.3",
- "@types/jest": "^28.1.8",
"axios": "^0.27.2",
"check-password-strength": "^2.0.7",
"dayjs": "^1.11.5",
@@ -62,11 +63,12 @@
"react-waypoint": "^10.3.0"
},
"devDependencies": {
- "@types/node": "^18.7.13",
+ "@types/jest": "^28.1.8",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/react-modal": "^3.13.1",
"@vitejs/plugin-react": "^2.1.0",
+ "cypress": "^10.8.0",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"i18next-parser": "^6.5.0",
diff --git a/client/sentry.js b/client/sentry.js
new file mode 100644
index 0000000..5dd25f6
--- /dev/null
+++ b/client/sentry.js
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+import * as Sentry from '@sentry/node';
+import * as Tracing from '@sentry/tracing';
+// import config from "./sentry-server.config.json" assert { type: "json" };
+
+export function sentrySetUp(app) {
+ Sentry.init({
+ integrations: [
+ // enable HTTP calls tracing
+ new Sentry.Integrations.Http({ tracing: true }),
+ // enable Express.js middleware tracing
+ new Tracing.Integrations.Express({ app }),
+ ],
+ });
+
+ // RequestHandler creates a separate execution context using domains, so that every
+ // transaction/span/breadcrumb is attached to its own Hub instance
+ app.use(Sentry.Handlers.requestHandler());
+ // TracingHandler creates a trace for every incoming request
+ app.use(Sentry.Handlers.tracingHandler());
+
+ app.get('/debug-sentry', function mainHandler(_req, _res) {
+ throw new Error('My first Sentry error!');
+ });
+
+ // The error handler must be before any other error middleware and after all controllers
+ // app.use(Sentry.Handlers.errorHandler());
+ app.use(
+ Sentry.Handlers.errorHandler({
+ shouldHandleError(error) {
+ // Capture all 404 and 500 errors
+ if (error.status === 404 || error.status === 500) {
+ return true;
+ }
+ return false;
+ },
+ })
+ );
+ // Optional fallthrough error handler
+ app.use(function onError(_err, _req, res, _next) {
+ // The error id is attached to `res.sentry` to be returned
+ // and optionally displayed to the user for support.
+ res.statusCode = 500;
+ res.end(res.sentry + '\n');
+ });
+}
diff --git a/client/tsconfig.json b/client/tsconfig.json
index 3a83682..c37e9c4 100644
--- a/client/tsconfig.json
+++ b/client/tsconfig.json
@@ -1,14 +1,21 @@
{
- "extends": "../tsconfig",
"compilerOptions": {
- /* Specify what JSX code is generated. */
- "jsx": "react-jsx",
- /* Specify a set of bundled library declaration files that describe the target runtime environment. */
+ "target": "esnext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
- /* Specify an output folder for all emitted files. */
- "outDir": "dist",
- /* Specify type package names to be included without being referenced in a source file. */
- "types": ["@testing-library/jest-dom", "@types/jest", "node", "vite/client", "vite-plugin-svgr/client"]
+ "jsx": "react-jsx",
+ "useDefineForClassFields": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "types": ["@testing-library/jest-dom", "@types/jest", "node", "vite/client", "vite-plugin-svgr/client"],
+ "resolveJsonModule": true,
+ "allowJs": true, // TODO: Set this to false
+ "noEmit": true,
+ "isolatedModules": true,
+ "allowSyntheticDefaultImports": true,
+ "esModuleInterop": false,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "skipLibCheck": true
},
"include": ["src"]
}