From e3ed590652b3e104608c1feab8759ee587b4aecd Mon Sep 17 00:00:00 2001
From: A7640S <109904807+A7640S@users.noreply.github.com>
Date: Fri, 7 Feb 2025 18:02:36 +0000
Subject: [PATCH 1/5] Create jest-test.yml
---
.github/workflows/jest-test.yml | 90 +++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
create mode 100644 .github/workflows/jest-test.yml
diff --git a/.github/workflows/jest-test.yml b/.github/workflows/jest-test.yml
new file mode 100644
index 0000000..4fea64f
--- /dev/null
+++ b/.github/workflows/jest-test.yml
@@ -0,0 +1,90 @@
+# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
+
+name: Tests Jest & Couverture
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "dev" ]
+
+jobs:
+ test:
+ name: Tests et Couverture
+ runs-on: ubuntu-22.04
+
+ strategy:
+ matrix:
+ node-version: [20.x]
+ fail-fast: false
+
+ steps:
+ - name: Checkout du code
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Configuration de Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node-version }}
+ cache: 'npm'
+
+ - name: Cache des dépendances
+ uses: actions/cache@v3
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-node-
+
+ - name: Installation des dépendances
+ run: |
+ npm ci
+ npm install -g jest
+
+ - name: Exécution des tests
+ run: npm test -- --coverage --ci --testLocationInResults --json --outputFile=jest-results.json
+ continue-on-error: true
+
+ - name: Vérification du seuil de couverture
+ run: |
+ COVERAGE=$(cat coverage/lcov.info| jq -r '.total.lines.pct')
+ echo "Couverture actuelle : $COVERAGE%"
+ if (( $(echo "$COVERAGE < 80" | bc -l) )); then
+ echo "La couverture de code est inférieure à 80% ($COVERAGE%)"
+ exit 1
+ else
+ echo "✅ La couverture de code est supérieure à 80% ($COVERAGE%)"
+ fi
+
+
+
+ - name: Upload des résultats de test
+ uses: actions/upload-artifact@v3
+ with:
+ name: test-results
+ path: |
+ jest-results.json
+ coverage/
+
+ - name: Publication sur Codecov
+ uses: codecov/codecov-action@v4
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ slug: 223MapAction/app.Dashboard
+ file: ./coverage/lcov.info
+ flags: unittests
+ name: codecov-umbrella
+ fail_ci_if_error: true
+ verbose: true
+
+ - name: Commentaire sur la PR avec la couverture
+ if: github.event_name == 'pull_request'
+ uses: codecov/codecov-action@v4
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ file: ./coverage/lcov.info
+ flags: unittests
+ fail_ci_if_error: false
From 2447a611b1afaeac8dd10e37db04e33b80e34bcd Mon Sep 17 00:00:00 2001
From: A7640S <109904807+A7640S@users.noreply.github.com>
Date: Fri, 7 Feb 2025 18:07:53 +0000
Subject: [PATCH 2/5] Update jest-test.yml
---
.github/workflows/jest-test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/jest-test.yml b/.github/workflows/jest-test.yml
index 4fea64f..94efb68 100644
--- a/.github/workflows/jest-test.yml
+++ b/.github/workflows/jest-test.yml
@@ -62,7 +62,7 @@ jobs:
- name: Upload des résultats de test
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: test-results
path: |
From 06b6bb1330f5d46f70606c3350f5bd7ce0b9c9ed Mon Sep 17 00:00:00 2001
From: A7640S <109904807+A7640S@users.noreply.github.com>
Date: Fri, 7 Feb 2025 18:19:09 +0000
Subject: [PATCH 3/5] Update jest-test.yml
---
.github/workflows/jest-test.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/jest-test.yml b/.github/workflows/jest-test.yml
index 94efb68..778af5f 100644
--- a/.github/workflows/jest-test.yml
+++ b/.github/workflows/jest-test.yml
@@ -50,7 +50,7 @@ jobs:
- name: Vérification du seuil de couverture
run: |
- COVERAGE=$(cat coverage/lcov.info| jq -r '.total.lines.pct')
+ COVERAGE=$(cat coverage/coverage-summary.json| jq -r '.total.lines.pct')
echo "Couverture actuelle : $COVERAGE%"
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "La couverture de code est inférieure à 80% ($COVERAGE%)"
@@ -74,7 +74,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: 223MapAction/app.Dashboard
- file: ./coverage/lcov.info
+ file: ./coverage/coverage-summary.json
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
@@ -85,6 +85,6 @@ jobs:
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- file: ./coverage/lcov.info
+ file: ./coverage/coverage-summary.json
flags: unittests
fail_ci_if_error: false
From 3e85228882780405a7a4945fc221b47a8a686f05 Mon Sep 17 00:00:00 2001
From: immersir <129412569+immerSIR@users.noreply.github.com>
Date: Mon, 7 Apr 2025 11:33:03 +0000
Subject: [PATCH 4/5] Update analyze.jsx
---
src/views/Dashboard/analyze.jsx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/views/Dashboard/analyze.jsx b/src/views/Dashboard/analyze.jsx
index b55d38e..ff3b04a 100644
--- a/src/views/Dashboard/analyze.jsx
+++ b/src/views/Dashboard/analyze.jsx
@@ -325,7 +325,7 @@ export default function Analyze() {
MarkdownComponents
}
>
- {prediction.analysis ||
+ {prediction?.analysis ||
"Analyse non disponible"}
- {prediction.piste_solution ||
+ {prediction?.piste_solution ||
"Non disponible"}
>
@@ -343,7 +343,7 @@ export default function Analyze() {
components={MarkdownComponents}
>
{`${
- prediction.analysis
+ prediction?.analysis
? prediction.analysis.substring(
0,
310
@@ -352,7 +352,7 @@ export default function Analyze() {
}...`}
)}
- {prediction.analysis &&
+ {prediction?.analysis &&
prediction.analysis.length >
300 && (