From df1a3dcbd1bf28e6003982f1e6db1af52ebf98b6 Mon Sep 17 00:00:00 2001 From: WasiqB Date: Mon, 23 Sep 2024 22:43:37 +0300 Subject: [PATCH] fix: :bug: fixed issue when file contains parent suite --- .github/ISSUE_TEMPLATE/bug.yml | 4 +- .gitignore | 1 + app/(app)/loading/page.tsx | 105 ++++++++++++++++----------------- lib/xml-parser.ts | 32 +++++----- package.json | 2 +- pnpm-lock.yaml | 16 ++--- 6 files changed, 80 insertions(+), 80 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index df3a2a0..aaa6f64 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -18,7 +18,9 @@ body: id: steps-to-reproduce attributes: label: 📃 Steps to reproduce the bug - description: We highly suggest including a screenshots and a bug report log (GitHub Gist link). + description: | + We highly suggest including the Error screenshots + and attach the file having issue. placeholder: Tell us the steps required to replicate your bug. validations: required: true diff --git a/.gitignore b/.gitignore index fd3dbb5..ba1a0b6 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts +.env \ No newline at end of file diff --git a/app/(app)/loading/page.tsx b/app/(app)/loading/page.tsx index 39caed1..721004e 100644 --- a/app/(app)/loading/page.tsx +++ b/app/(app)/loading/page.tsx @@ -1,27 +1,36 @@ +/* eslint-disable @stylistic/js/max-len */ 'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import { convertToJson, getTestResults } from '@/lib/xml-parser'; +import { Progress } from '@/components/ui/progress'; +import { + Card, + CardContent, + CardFooter, + CardHeader, + CardTitle, +} from '@/components/ui/card'; +import { Button } from '@/components/ui/button'; const LoadingPage = (): JSX.Element => { const [progress, setProgress] = useState(0); const [error, setError] = useState(null); - const [redirectTimer, setRedirectTimer] = useState(5); const router = useRouter(); useEffect(() => { const xmlContent = localStorage.getItem('xml-data'); - if (!xmlContent) { - setError('No XML data found'); - return; - } - setProgress(10); try { + setProgress(0); + if (!xmlContent) { + throw new Error('No XML data found'); + } + setProgress(25); const jsonData = convertToJson(xmlContent); - setProgress(30); - const testResult = getTestResults(jsonData); setProgress(50); + const testResult = getTestResults(jsonData); + setProgress(75); localStorage.setItem('json-data', JSON.stringify(testResult)); setProgress(100); router.push('/results'); @@ -32,58 +41,44 @@ const LoadingPage = (): JSX.Element => { } }, [router]); - useEffect(() => { - let timerInterval: NodeJS.Timeout; - - if (error) { - timerInterval = setInterval(() => { - setRedirectTimer((prevTimer) => { - if (prevTimer <= 1) { - clearInterval(timerInterval); - router.push('/'); - return 0; - } - return prevTimer - 1; - }); - }, 1000); - } - - return () => { - if (timerInterval) { - clearInterval(timerInterval); - } - }; - }, [error, router]); + const handleBack = (): void => { + router.push('/'); + }; - if (error) { - return ( -
-
-

Error

-

{error}

-

- Redirecting to home page in {redirectTimer} second - {redirectTimer > 1 ? 's' : ''}... -

-
-
+ const handleRaiseIssue = (): void => { + router.push( + 'https://github.com/WasiqB/ultra-reporter-app/issues/new?assignees=&labels=bug&projects=&template=bug.yml&title=%F0%9F%90%9B+New+Bug:' ); - } + }; return (
-
-

Processing XML

-
-
-
-

- Please wait while we process your XML file... -

-
+ + + Processing XML + + + + {error ? ( +
+

Error:

+

{error}

+
+ ) : ( +

+ Please wait while we process your XML file... +

+ )} +
+ {error && ( + + + + + )} +
); }; diff --git a/lib/xml-parser.ts b/lib/xml-parser.ts index 78b454e..7f34779 100644 --- a/lib/xml-parser.ts +++ b/lib/xml-parser.ts @@ -79,24 +79,26 @@ const getTestClasses = (classes: any): TestClass[] => { const getTestCases = (tests: any): TestCase[] => { const result: TestCase[] = []; - if (tests.length) { - for (const test of tests) { + if (tests) { + if (tests.length) { + for (const test of tests) { + result.push({ + name: test['name'], + started_at: test['started-at'], + finished_at: test['finished-at'], + duration_ms: test['duration-ms'], + test_classes: getTestClasses(test.class), + }); + } + } else { result.push({ - name: test['name'], - started_at: test['started-at'], - finished_at: test['finished-at'], - duration_ms: test['duration-ms'], - test_classes: getTestClasses(test.class), + name: tests['name'], + started_at: tests['started-at'], + finished_at: tests['finished-at'], + duration_ms: tests['duration-ms'], + test_classes: getTestClasses(tests.class), }); } - } else { - result.push({ - name: tests['name'], - started_at: tests['started-at'], - finished_at: tests['finished-at'], - duration_ms: tests['duration-ms'], - test_classes: getTestClasses(tests.class), - }); } return result; }; diff --git a/package.json b/package.json index 1b861a4..791f25a 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "postcss": "^8", "prettier": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.6", - "tailwindcss": "^3.4.1", + "tailwindcss": "^3.4.13", "typescript": "^5", "typescript-eslint": "^8.6.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3100c9d..e3730af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,7 +64,7 @@ importers: version: 2.5.2 tailwindcss-animate: specifier: ^1.0.7 - version: 1.0.7(tailwindcss@3.4.12) + version: 1.0.7(tailwindcss@3.4.13) xml2js: specifier: ^0.6.2 version: 0.6.2 @@ -130,8 +130,8 @@ importers: specifier: ^0.6.6 version: 0.6.6(prettier@3.3.3) tailwindcss: - specifier: ^3.4.1 - version: 3.4.12 + specifier: ^3.4.13 + version: 3.4.13 typescript: specifier: ^5 version: 5.6.2 @@ -2151,8 +2151,8 @@ packages: peerDependencies: tailwindcss: '>=3.0.0 || insiders' - tailwindcss@3.4.12: - resolution: {integrity: sha512-Htf/gHj2+soPb9UayUNci/Ja3d8pTmu9ONTfh4QY8r3MATTZOzmv6UYWF7ZwikEIC8okpfqmGqrmDehua8mF8w==} + tailwindcss@3.4.13: + resolution: {integrity: sha512-KqjHOJKogOUt5Bs752ykCeiwvi0fKVkr5oqsFNt/8px/tA8scFPIlkygsf6jXrfCqGHz7VflA6+yytWuM+XhFw==} engines: {node: '>=14.0.0'} hasBin: true @@ -4398,11 +4398,11 @@ snapshots: tailwind-merge@2.5.2: {} - tailwindcss-animate@1.0.7(tailwindcss@3.4.12): + tailwindcss-animate@1.0.7(tailwindcss@3.4.13): dependencies: - tailwindcss: 3.4.12 + tailwindcss: 3.4.13 - tailwindcss@3.4.12: + tailwindcss@3.4.13: dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2