Skip to content
Merged
90 changes: 90 additions & 0 deletions .github/workflows/jest-test.yml
Original file line number Diff line number Diff line change
@@ -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/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%)"
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@v4
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/coverage-summary.json
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/coverage-summary.json
flags: unittests
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""
></script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script>
<!-- <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script> -->
<link rel="shortcut icon" type="image/x-icon" href="./logo.png" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
Expand Down
21 changes: 12 additions & 9 deletions src/views/Dashboard/analyze.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ export default function Analyze() {
align="center"
mb="4"
>
<Spinner data-testid="loading-indicator" size="lg" />
<Spinner
data-testid="loading-indicator"
size="lg"
/>
</Flex>
<QuotesCarousel />
</Box>
Expand Down Expand Up @@ -325,15 +328,15 @@ export default function Analyze() {
MarkdownComponents
}
>
{prediction.analysis ||
{prediction?.analysis ||
"Analyse non disponible"}
</ReactMarkdown>
<ReactMarkdown
components={
MarkdownComponents
}
>
{prediction.piste_solution ||
{prediction?.piste_solution ||
"Non disponible"}
</ReactMarkdown>
</>
Expand All @@ -343,16 +346,16 @@ export default function Analyze() {
components={MarkdownComponents}
>
{`${
prediction.analysis
? prediction.analysis.substring(
prediction?.analysis
? prediction?.analysis.substring(
0,
310
)
: "Aucun contexte disponible"
}...`}
</ReactMarkdown>
)}
{prediction.analysis &&
{prediction?.analysis &&
prediction.analysis.length >
300 && (
<Button
Expand Down Expand Up @@ -393,7 +396,7 @@ export default function Analyze() {
<div>
<Image
src={
prediction.ndvi_heatmap
prediction?.ndvi_heatmap
}
alt="NDVI Heatmap"
mb={4}
Expand All @@ -404,7 +407,7 @@ export default function Analyze() {
<div>
<Image
src={
prediction.ndvi_ndwi_plot
prediction?.ndvi_ndwi_plot
}
alt="NDVI NDWI Plot"
mb={4}
Expand All @@ -415,7 +418,7 @@ export default function Analyze() {
<div>
<Image
src={
prediction.landcover_plot
prediction?.landcover_plot
}
alt="Landcover Plot"
maxW="100%"
Expand Down
Loading