From 207e680976fb85d8a548a8c0672ec869bacec3ca Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Fri, 28 Jul 2023 20:24:04 +0200 Subject: [PATCH 01/13] refactor: removed unused line --- .github/workflows/actions.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 92f4e398..aec534d7 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -15,7 +15,6 @@ jobs: steps: - uses: actions/checkout@v3 with: - node-version: "18" fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master @@ -42,7 +41,7 @@ jobs: uses: davelosert/vitest-coverage-report-action@v1.4.0 with: vite-config-path: "./vite.config.ts" - + release-please: name: Release Please needs: sonarcloud @@ -52,6 +51,5 @@ jobs: - name: Release Please Action uses: google-github-actions/release-please-action@v3 with: - node-version: "18" release-type: node package-name: release-please-action From 9783ce8b64b1eb3733297ed790642383003bc021 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:01:25 +0200 Subject: [PATCH 02/13] chore: sonarcloud properties --- sonar-project.properties | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..4d302959 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +sonar.projectKey=LeleDallas_Cards-Against-Humanity +sonar.organization=leledallas \ No newline at end of file From bc4477ddfda962ff79deb58910835e1a0b08fc24 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:06:11 +0200 Subject: [PATCH 03/13] fix: action runner --- .github/workflows/actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index aec534d7..896bdf8d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -25,7 +25,7 @@ jobs: run: | cd client npm ci - npm run test-coverage + npm run coverage env: CI: true API_URL: ${{ secrets.API_URL }} @@ -33,7 +33,7 @@ jobs: run: | cd server npm ci - npm run test-coverage + npm run coverage env: CI: true API_URL: ${{ secrets.API_URL }} From 6274aea5c34471209112e3d12b2fd834d54d8301 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:11:28 +0200 Subject: [PATCH 04/13] refactor: vite.config.ts path --- .github/workflows/actions.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 896bdf8d..22ff7638 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -29,6 +29,10 @@ jobs: env: CI: true API_URL: ${{ secrets.API_URL }} + - name: Vitest Coverage Report + uses: davelosert/vitest-coverage-report-action@v1.4.0 + with: + vite-config-path: "./client/vite.config.ts" - name: Run server tests & coverage run: | cd server @@ -37,10 +41,11 @@ jobs: env: CI: true API_URL: ${{ secrets.API_URL }} + - name: Vitest Coverage Report uses: davelosert/vitest-coverage-report-action@v1.4.0 with: - vite-config-path: "./vite.config.ts" + vite-config-path: "./server/vite.config.ts" release-please: name: Release Please From f99c31be99b22749837a2c8f551c30a80d268b69 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:52:27 +0200 Subject: [PATCH 05/13] refactor: remove api url --- .github/workflows/actions.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 22ff7638..2b9ed43d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -26,9 +26,6 @@ jobs: cd client npm ci npm run coverage - env: - CI: true - API_URL: ${{ secrets.API_URL }} - name: Vitest Coverage Report uses: davelosert/vitest-coverage-report-action@v1.4.0 with: @@ -38,10 +35,6 @@ jobs: cd server npm ci npm run coverage - env: - CI: true - API_URL: ${{ secrets.API_URL }} - - name: Vitest Coverage Report uses: davelosert/vitest-coverage-report-action@v1.4.0 with: From 241ff950afcaf16132b366287cdb112689dc9067 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Fri, 28 Jul 2023 22:23:50 +0200 Subject: [PATCH 06/13] fix: tsconfig path --- client/package-lock.json | 69 ++++++++++++++++++++++++++++++++-------- client/package.json | 3 +- client/vite.config.ts | 4 +-- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 3c05c263..d30b5423 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -21,7 +21,8 @@ "react-router-dom": "^6.9.0", "socket.io": "^4.6.1", "socket.io-client": "^4.6.1", - "styled-components": "^5.3.11" + "styled-components": "^5.3.9", + "vite-tsconfig-paths": "^4.2.0" }, "devDependencies": { "@faker-js/faker": "^7.6.0", @@ -2540,7 +2541,7 @@ "version": "0.17.16", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.16.tgz", "integrity": "sha512-aeSuUKr9aFVY9Dc8ETVELGgkj4urg5isYx8pLf4wlGgB0vTFjxJQdHnNH6Shmx4vYYrOTLCHtRI5i1XZ9l2Zcg==", - "dev": true, + "devOptional": true, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" @@ -2882,6 +2883,11 @@ "node": ">=4" } }, + "node_modules/globrex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", + "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==" + }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -3146,7 +3152,7 @@ "version": "2.12.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.0.tgz", "integrity": "sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==", - "dev": true, + "devOptional": true, "dependencies": { "has": "^1.0.3" }, @@ -3823,7 +3829,7 @@ "version": "3.3.6", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", - "dev": true, + "devOptional": true, "funding": [ { "type": "github", @@ -6738,7 +6744,7 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true + "devOptional": true }, "node_modules/pathe": { "version": "1.1.0", @@ -6759,7 +6765,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "devOptional": true }, "node_modules/picomatch": { "version": "2.3.1", @@ -6787,7 +6793,7 @@ "version": "8.4.21", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz", "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==", - "dev": true, + "devOptional": true, "funding": [ { "type": "opencollective", @@ -7704,7 +7710,7 @@ "version": "1.22.2", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", - "dev": true, + "devOptional": true, "dependencies": { "is-core-module": "^2.11.0", "path-parse": "^1.0.7", @@ -7746,7 +7752,7 @@ "version": "3.20.2", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.2.tgz", "integrity": "sha512-3zwkBQl7Ai7MFYQE0y1MeQ15+9jsi7XxfrqwTb/9EK8D9C9+//EBR4M+CuA1KODRaNbFez/lWxA5vhEGZp4MUg==", - "dev": true, + "devOptional": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -7986,7 +7992,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.10.0" } @@ -8121,7 +8127,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, + "devOptional": true, "engines": { "node": ">= 0.4" }, @@ -8250,6 +8256,25 @@ "node": ">=14" } }, + "node_modules/tsconfck": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/tsconfck/-/tsconfck-2.1.2.tgz", + "integrity": "sha512-ghqN1b0puy3MhhviwO2kGF8SeMDNhEbnKxjK7h6+fvY9JAxqvXi8y5NAHSQv687OVboS2uZIByzGd45/YxrRHg==", + "bin": { + "tsconfck": "bin/tsconfck.js" + }, + "engines": { + "node": "^14.13.1 || ^16 || >=18" + }, + "peerDependencies": { + "typescript": "^4.3.5 || ^5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -8275,7 +8300,7 @@ "version": "5.0.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", - "dev": true, + "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8387,7 +8412,7 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/vite/-/vite-4.2.1.tgz", "integrity": "sha512-7MKhqdy0ISo4wnvwtqZkjke6XN4taqQ2TBaTccLIpOKv7Vp2h4Y+NpmWCnGDeSvvn45KxvWgGyb0MkHvY1vgbg==", - "dev": true, + "devOptional": true, "dependencies": { "esbuild": "^0.17.5", "postcss": "^8.4.21", @@ -8455,6 +8480,24 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/vite-tsconfig-paths": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.2.0.tgz", + "integrity": "sha512-jGpus0eUy5qbbMVGiTxCL1iB9ZGN6Bd37VGLJU39kTDD6ZfULTTb1bcc5IeTWqWJKiWV5YihCaibeASPiGi8kw==", + "dependencies": { + "debug": "^4.1.1", + "globrex": "^0.1.2", + "tsconfck": "^2.1.0" + }, + "peerDependencies": { + "vite": "*" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, "node_modules/vitest": { "version": "0.30.1", "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.30.1.tgz", diff --git a/client/package.json b/client/package.json index 04c99bd7..bf185ee5 100644 --- a/client/package.json +++ b/client/package.json @@ -26,7 +26,8 @@ "react-router-dom": "^6.9.0", "socket.io": "^4.6.1", "socket.io-client": "^4.6.1", - "styled-components": "^5.3.9" + "styled-components": "^5.3.9", + "vite-tsconfig-paths": "^4.2.0" }, "devDependencies": { "@faker-js/faker": "^7.6.0", diff --git a/client/vite.config.ts b/client/vite.config.ts index ffa98cf9..c951029e 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -3,11 +3,11 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { resolve } from "path"; - +import tsconfigPaths from 'vite-tsconfig-paths' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [tsconfigPaths(), react()], test: { globals: true, environment: "jsdom", From 1893e15d56b6080637e7f157ebc5fe20e891f61b Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:56:59 +0200 Subject: [PATCH 07/13] fix(vitest): remove duplicated result on coverage --- client/vite.config.ts | 2 +- server/vite.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/vite.config.ts b/client/vite.config.ts index c951029e..28eb59fc 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ setupFiles: [resolve(__dirname, './setup.js')], coverage: { provider: "c8", - all: true, + // all: true, include: ["src/**/*.tsx", "src/**/*.ts"], exclude: ["src/main.tsx", "src/types", "src/vite-env.d.ts", "src/reducers.ts", "src/testReducer.ts"], }, diff --git a/server/vite.config.ts b/server/vite.config.ts index 5afb81c1..74803f9f 100644 --- a/server/vite.config.ts +++ b/server/vite.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ globals: true, coverage: { provider: "c8", - all: true, + // all: true, include: ["**/*.ts"], exclude: ["**/types/*.ts", "**/test/*.ts", "vite-env.d.ts", "vite.config.ts", "**/db/**/*.ts"], }, From b194d15661db911cfbb1b494a656ffbeacdaf155 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:06:14 +0200 Subject: [PATCH 08/13] fix(test): wrong path lowercase --- client/src/route/AppRoute.tsx | 12 ++++++------ client/test/CreateLobby.test.tsx | 2 +- client/test/CzarView.test.tsx | 2 +- client/test/Game.test.tsx | 2 +- client/test/GameScorer.test.tsx | 2 +- client/test/Home.test.tsx | 2 +- client/test/Lobby.test.tsx | 2 +- client/test/PlayerView.test.tsx | 2 +- client/test/Rules.test.tsx | 2 +- client/test/WaitingLobby.test.tsx | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/src/route/AppRoute.tsx b/client/src/route/AppRoute.tsx index 42b32404..c1c3e8d3 100644 --- a/client/src/route/AppRoute.tsx +++ b/client/src/route/AppRoute.tsx @@ -1,12 +1,12 @@ import { Route, Routes } from "react-router-dom"; import SocketContextComponent from "../context/SocketContextComponent"; import { ConfigProvider } from "antd"; -import Home from "../pages/Home/Home"; -import Lobby from "../pages/Lobby/Lobby"; -import Rules from "../pages/Rules/Rules"; -import CreateLobby from "../pages/Lobby/CreateLobby"; -import WaitingLobby from "../pages/Lobby/WaitingLobby"; -import Game from "../pages/Game/Game"; +import Home from "../Pages/Home/Home"; +import Lobby from "../Pages/Lobby/Lobby"; +import Rules from "../Pages/Rules/Rules"; +import CreateLobby from "../Pages/Lobby/CreateLobby"; +import WaitingLobby from "../Pages/Lobby/WaitingLobby"; +import Game from "../Pages/Game/Game"; import { Provider } from "react-redux"; import { store } from "../store/store"; import ErrorRoute from "./ErrorRoute"; diff --git a/client/test/CreateLobby.test.tsx b/client/test/CreateLobby.test.tsx index dc91a1f1..0ac499ad 100644 --- a/client/test/CreateLobby.test.tsx +++ b/client/test/CreateLobby.test.tsx @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'; import React from 'react'; import { expect, it, describe, vi } from 'vitest' import { fireEvent, render } from '@testing-library/react'; -import CreateLobby from "../src/pages/Lobby/CreateLobby" +import CreateLobby from "../src/Pages/Lobby/CreateLobby" import { BrowserRouter } from 'react-router-dom'; const mockedUseNavigate = vi.fn(); diff --git a/client/test/CzarView.test.tsx b/client/test/CzarView.test.tsx index abef929f..079605bf 100644 --- a/client/test/CzarView.test.tsx +++ b/client/test/CzarView.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { expect, it, describe, vi } from 'vitest' import { fireEvent, render, screen } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; -import CzarView from '../src/pages/Game/CzarView'; +import CzarView from '../src/Pages/Game/CzarView'; import { Provider } from 'react-redux'; import { store } from '../src/store/store'; import { SocketContextProvider } from '../src/context/SocketContext'; diff --git a/client/test/Game.test.tsx b/client/test/Game.test.tsx index 1e4b3b05..d4f4146f 100644 --- a/client/test/Game.test.tsx +++ b/client/test/Game.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { expect, it, describe, vi } from 'vitest' import { fireEvent, render, screen } from '@testing-library/react' import { BrowserRouter, MemoryRouter } from 'react-router-dom'; -import Game from '../src/pages/Game/Game'; +import Game from '../src/Pages/Game/Game'; import { act } from 'react-dom/test-utils'; import { Provider } from 'react-redux'; import { store } from '../src/store/store'; diff --git a/client/test/GameScorer.test.tsx b/client/test/GameScorer.test.tsx index 0383fa85..8d27de99 100644 --- a/client/test/GameScorer.test.tsx +++ b/client/test/GameScorer.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { expect, it, describe } from 'vitest' import { render } from '@testing-library/react' import { BrowserRouter } from 'react-router-dom'; -import GameScorer from '../src/pages/Game/GameScorer'; +import GameScorer from '../src/Pages/Game/GameScorer'; describe('Game Scorer', () => { diff --git a/client/test/Home.test.tsx b/client/test/Home.test.tsx index 98817095..e4f59fbe 100644 --- a/client/test/Home.test.tsx +++ b/client/test/Home.test.tsx @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'; import React from 'react'; import { expect, it, describe, vi, test } from 'vitest' import { fireEvent, render } from '@testing-library/react'; -import Home from '../src/pages/Home/Home'; +import Home from '../src/Pages/Home/Home'; import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import { store } from '../src/store/store'; diff --git a/client/test/Lobby.test.tsx b/client/test/Lobby.test.tsx index 293fb0ff..9b6575da 100644 --- a/client/test/Lobby.test.tsx +++ b/client/test/Lobby.test.tsx @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'; import React from 'react'; import { expect, it, describe, beforeEach, vi } from 'vitest' import { fireEvent, render, waitFor } from '@testing-library/react' -import Lobby from '../src/pages/Lobby/Lobby'; +import Lobby from '../src/Pages/Lobby/Lobby'; import { BrowserRouter } from 'react-router-dom'; const mockedUseNavigate = vi.fn(); diff --git a/client/test/PlayerView.test.tsx b/client/test/PlayerView.test.tsx index d00fe253..c66b2301 100644 --- a/client/test/PlayerView.test.tsx +++ b/client/test/PlayerView.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { expect, it, describe, vi } from 'vitest' import { fireEvent, render, screen } from '@testing-library/react'; import { BrowserRouter, MemoryRouter } from 'react-router-dom'; -import PlayerView from '../src/pages/Game/PlayerView'; +import PlayerView from '../src/Pages/Game/PlayerView'; import { testStore } from '../src/store/store'; import { Provider } from 'react-redux'; import { SocketContextProvider } from '../src/context/SocketContext'; diff --git a/client/test/Rules.test.tsx b/client/test/Rules.test.tsx index 5550475f..5f11a60c 100644 --- a/client/test/Rules.test.tsx +++ b/client/test/Rules.test.tsx @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'; import React from 'react'; import { expect, it, describe, beforeEach, vi } from 'vitest' import { fireEvent, render, waitFor } from '@testing-library/react' -import Rules from '../src/pages/Rules/Rules'; +import Rules from '../src/Pages/Rules/Rules'; import { BrowserRouter } from 'react-router-dom'; import * as reactDeviceDetect from 'react-device-detect' diff --git a/client/test/WaitingLobby.test.tsx b/client/test/WaitingLobby.test.tsx index 97f4fb89..54e8e2f2 100644 --- a/client/test/WaitingLobby.test.tsx +++ b/client/test/WaitingLobby.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { expect, it, describe, vi, test } from 'vitest' import { fireEvent, render, screen } from '@testing-library/react' import { BrowserRouter, MemoryRouter } from 'react-router-dom'; -import WaitingLobby from '../src/pages/Lobby/WaitingLobby'; +import WaitingLobby from '../src/Pages/Lobby/WaitingLobby'; import { Provider } from 'react-redux'; import { store } from '../src/store/store'; import { SocketContextProvider } from '../src/context/SocketContext'; From e7bfb6ccc6963d992237f88dabbdeee4f0d79128 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:11:36 +0200 Subject: [PATCH 09/13] chore(ci): removed vitest-coverage-report --- .github/workflows/actions.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 2b9ed43d..389fee03 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -26,19 +26,13 @@ jobs: cd client npm ci npm run coverage - - name: Vitest Coverage Report - uses: davelosert/vitest-coverage-report-action@v1.4.0 - with: - vite-config-path: "./client/vite.config.ts" + - name: Run server tests & coverage run: | cd server npm ci npm run coverage - - name: Vitest Coverage Report - uses: davelosert/vitest-coverage-report-action@v1.4.0 - with: - vite-config-path: "./server/vite.config.ts" + release-please: name: Release Please From d9bbf476b10654a4710493913869002bb9a17442 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:28:35 +0200 Subject: [PATCH 10/13] refactor(server): Connection condition --- server/db/services/database.service.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/server/db/services/database.service.ts b/server/db/services/database.service.ts index 86813fea..edc0bd17 100644 --- a/server/db/services/database.service.ts +++ b/server/db/services/database.service.ts @@ -1,20 +1,22 @@ -import * as mongoDB from "mongodb"; import * as dotenv from "dotenv"; +import { Collection, Db, MongoClient } from "mongodb"; -export const collections: { cards?: mongoDB.Collection } = {} +export const collections: { cards?: Collection } = {} export async function connectToDatabase() { dotenv.config(); - const client: mongoDB.MongoClient = new mongoDB.MongoClient(process.env.DB_CONN_STRING!); + if (process.env.DB_CONN_STRING) { + const client: MongoClient = new MongoClient(process.env.DB_CONN_STRING); - await client.connect(); + await client.connect(); - const db: mongoDB.Db = client.db(process.env.DB_NAME); + const db: Db = client.db(process.env.DB_NAME); - const cardsCollection: mongoDB.Collection = db.collection(process.env.CARDS_COLLECTION_NAME!); + const cardsCollection: Collection = db.collection(process.env.CARDS_COLLECTION_NAME!); - collections.cards = cardsCollection; - - console.log(`Successfully connected to database: ${db.databaseName} and collection: ${cardsCollection.collectionName}`); + collections.cards = cardsCollection; + + console.log(`Successfully connected to database: ${db.databaseName} and collection: ${cardsCollection.collectionName}`); + } } \ No newline at end of file From af057d0e87242c820791edd1add07d19d01f993c Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:49:29 +0200 Subject: [PATCH 11/13] chore(ci/cd): vitest-coverage-report --- .github/workflows/actions.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 389fee03..504fde82 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -26,13 +26,21 @@ jobs: cd client npm ci npm run coverage - + - name: Vitest Coverage Report + uses: davelosert/vitest-coverage-report-action@v2.1.0 + with: + working-directory: "./client/" + vite-config-path: "./vite.config.ts" - name: Run server tests & coverage run: | cd server npm ci npm run coverage - + - name: Vitest Coverage Report + uses: davelosert/vitest-coverage-report-action@v2.1.0 + with: + working-directory: "./server/" + vite-config-path: "./vite.config.ts" release-please: name: Release Please From 5f338130761792780962b7f518e7a0510ff906c4 Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 23:23:41 +0200 Subject: [PATCH 12/13] chore(ci/cd): reporter json-summary --- client/vite.config.ts | 1 + server/vite.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/client/vite.config.ts b/client/vite.config.ts index 28eb59fc..723ae143 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -15,6 +15,7 @@ export default defineConfig({ coverage: { provider: "c8", // all: true, + reporter: ['json-summary'], include: ["src/**/*.tsx", "src/**/*.ts"], exclude: ["src/main.tsx", "src/types", "src/vite-env.d.ts", "src/reducers.ts", "src/testReducer.ts"], }, diff --git a/server/vite.config.ts b/server/vite.config.ts index 74803f9f..63a74f71 100644 --- a/server/vite.config.ts +++ b/server/vite.config.ts @@ -6,6 +6,7 @@ export default defineConfig({ coverage: { provider: "c8", // all: true, + reporter: ['json-summary'], include: ["**/*.ts"], exclude: ["**/types/*.ts", "**/test/*.ts", "vite-env.d.ts", "vite.config.ts", "**/db/**/*.ts"], }, From 5c442be1fe35bf22218ce6bc82152a3560effa2e Mon Sep 17 00:00:00 2001 From: Dallas <71103219+LeleDallas@users.noreply.github.com> Date: Sat, 29 Jul 2023 23:33:09 +0200 Subject: [PATCH 13/13] refactor: update coverage lines --- client/test/PlayerView.test.tsx | 7 +------ client/vite.config.ts | 2 +- server/vite.config.ts | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/client/test/PlayerView.test.tsx b/client/test/PlayerView.test.tsx index c66b2301..a8870d26 100644 --- a/client/test/PlayerView.test.tsx +++ b/client/test/PlayerView.test.tsx @@ -135,10 +135,6 @@ describe('Player View', () => { score: new Map(), new_turn: false }; - const drawNew = vi.fn(); - const setSelected = vi.fn(); - const setPlayerHand = vi.fn(); - const setHasPlayed = vi.fn(); const state = { roomName: 'room1', isCzar: false }; const socketProvider = ({ children }) => ( @@ -151,8 +147,7 @@ describe('Player View', () => { ) render(, { wrapper: socketProvider }); - const card = screen.getByText(7); - fireEvent.click(card); + fireEvent.click(screen.getByText(1)); fireEvent.click(screen.getByText('Submit Response')); expect(screen.queryByText('1')).not.toBeInTheDocument() }); diff --git a/client/vite.config.ts b/client/vite.config.ts index 723ae143..4b09a6c7 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -15,7 +15,7 @@ export default defineConfig({ coverage: { provider: "c8", // all: true, - reporter: ['json-summary'], + reporter: ['text', 'json-summary', 'json'], include: ["src/**/*.tsx", "src/**/*.ts"], exclude: ["src/main.tsx", "src/types", "src/vite-env.d.ts", "src/reducers.ts", "src/testReducer.ts"], }, diff --git a/server/vite.config.ts b/server/vite.config.ts index 63a74f71..9335222d 100644 --- a/server/vite.config.ts +++ b/server/vite.config.ts @@ -6,7 +6,7 @@ export default defineConfig({ coverage: { provider: "c8", // all: true, - reporter: ['json-summary'], + reporter: ['text', 'json-summary', 'json'], include: ["**/*.ts"], exclude: ["**/types/*.ts", "**/test/*.ts", "vite-env.d.ts", "vite.config.ts", "**/db/**/*.ts"], },