plum-e2e 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +2 -0
- package/.prettierignore +21 -0
- package/.prettierrc +15 -0
- package/LICENSE +677 -0
- package/README.md +5 -0
- package/backend/Dockerfile +30 -0
- package/backend/README.md +0 -0
- package/backend/_scaffold/features/LoginPage.feature +6 -0
- package/backend/_scaffold/pages/LoginPage.js +22 -0
- package/backend/_scaffold/step_definitions/LoginSteps.js +9 -0
- package/backend/_scaffold/utils/constants.js +3 -0
- package/backend/_scaffold/utils/hooks.js +65 -0
- package/backend/_scaffold/utils/utils.js +10 -0
- package/backend/app.js +37 -0
- package/backend/config/scripts/create-settings.js +60 -0
- package/backend/config/scripts/generate-report.js +135 -0
- package/backend/config/scripts/run-tests.js +37 -0
- package/backend/cucumber.json +6 -0
- package/backend/package-lock.json +3403 -0
- package/backend/package.json +29 -0
- package/backend/playwright.config.js +97 -0
- package/backend/routes/cron.routes.js +127 -0
- package/backend/routes/reports.routes.js +42 -0
- package/backend/routes/schedules.routes.js +32 -0
- package/backend/routes/tests.routes.js +33 -0
- package/backend/server.js +39 -0
- package/backend/services/cronService.js +127 -0
- package/backend/services/envService.js +43 -0
- package/backend/services/reportService.js +50 -0
- package/backend/services/scheduleService.js +34 -0
- package/backend/services/testService.js +70 -0
- package/backend/websockets/socketHandler.js +46 -0
- package/bin/plum.js +188 -0
- package/docker-compose.yml +41 -0
- package/frontend/Dockerfile +26 -0
- package/frontend/README.md +0 -0
- package/frontend/jsconfig.json +13 -0
- package/frontend/package-lock.json +2894 -0
- package/frontend/package.json +26 -0
- package/frontend/postcss.config.js +23 -0
- package/frontend/src/app.css +35 -0
- package/frontend/src/app.html +28 -0
- package/frontend/src/lib/index.js +18 -0
- package/frontend/src/routes/+layout.svelte +34 -0
- package/frontend/src/routes/+page.svelte +188 -0
- package/frontend/src/routes/components/Navigation.svelte +53 -0
- package/frontend/src/routes/reports/+page.svelte +160 -0
- package/frontend/src/routes/scheduled-tests/+page.svelte +363 -0
- package/frontend/static/favicon.png +0 -0
- package/frontend/svelte.config.js +30 -0
- package/frontend/tailwind.config.js +44 -0
- package/frontend/vite.config.js +23 -0
- package/license-config.json +37 -0
- package/package.json +28 -0
- package/resources/comments-format.text +23 -0
- package/resources/gpl-3.0-license.txt +14 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plum-frontend",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite dev",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"prepare": "svelte-kit sync || echo ''"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@sveltejs/adapter-auto": "^4.0.0",
|
|
14
|
+
"@sveltejs/kit": "^2.16.0",
|
|
15
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
16
|
+
"autoprefixer": "^10.4.20",
|
|
17
|
+
"daisyui": "^4.12.23",
|
|
18
|
+
"postcss": "^8.5.1",
|
|
19
|
+
"svelte": "^5.0.0",
|
|
20
|
+
"tailwindcss": "^3.4.17",
|
|
21
|
+
"vite": "^6.0.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"socket.io-client": "^4.8.1"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of Plum.
|
|
3
|
+
*
|
|
4
|
+
* Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* Plum is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
plugins: {
|
|
20
|
+
tailwindcss: {},
|
|
21
|
+
autoprefixer: {}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is part of Plum.
|
|
3
|
+
|
|
4
|
+
Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
Plum is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
*/
|
|
17
|
+
@tailwind base;
|
|
18
|
+
@tailwind components;
|
|
19
|
+
@tailwind utilities;
|
|
20
|
+
|
|
21
|
+
html {
|
|
22
|
+
scroll-behavior: smooth;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
* {
|
|
26
|
+
font-family: 'Inter', sans-serif;
|
|
27
|
+
font-weight: 300;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
h1,
|
|
31
|
+
h2,
|
|
32
|
+
h3,
|
|
33
|
+
.poppins {
|
|
34
|
+
font-family: 'Poppins', sans-serif;
|
|
35
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
This file is part of Plum.
|
|
3
|
+
|
|
4
|
+
Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
Plum is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
-->
|
|
17
|
+
<!doctype html>
|
|
18
|
+
<html lang="en">
|
|
19
|
+
<head>
|
|
20
|
+
<meta charset="utf-8" />
|
|
21
|
+
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
|
22
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
23
|
+
%sveltekit.head%
|
|
24
|
+
</head>
|
|
25
|
+
<body data-sveltekit-preload-data="hover">
|
|
26
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of Plum.
|
|
3
|
+
*
|
|
4
|
+
* Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* Plum is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// place files you want to import through the `$lib` alias in this folder.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* This file is part of Plum.
|
|
3
|
+
*
|
|
4
|
+
* Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* Plum is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import '../app.css';
|
|
20
|
+
import Navigation from './components/Navigation.svelte';
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div class="layout">
|
|
24
|
+
<Navigation></Navigation>
|
|
25
|
+
<slot />
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.layout {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
min-height: 100vh; /* Full viewport height */
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* This file is part of Plum.
|
|
3
|
+
*
|
|
4
|
+
* Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* Plum is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { onMount } from 'svelte';
|
|
20
|
+
import { io } from 'socket.io-client';
|
|
21
|
+
|
|
22
|
+
let output = "Enter a test ID and click 'Run Test'...\n";
|
|
23
|
+
let socket;
|
|
24
|
+
let testCompleted = false;
|
|
25
|
+
let testID = '';
|
|
26
|
+
let outputRef;
|
|
27
|
+
let suites = [];
|
|
28
|
+
let latestReport = null;
|
|
29
|
+
|
|
30
|
+
onMount(async () => {
|
|
31
|
+
socket = io('http://localhost:3001');
|
|
32
|
+
|
|
33
|
+
socket.on('log', (data) => {
|
|
34
|
+
output += data + '\n';
|
|
35
|
+
scrollToBottom();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
socket.on('done', async () => {
|
|
39
|
+
output += '✅ Test completed!\n';
|
|
40
|
+
testCompleted = true;
|
|
41
|
+
scrollToBottom();
|
|
42
|
+
|
|
43
|
+
// Fetch the latest report **after** test completion
|
|
44
|
+
await fetchLatestReport();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Fetch test names from backend
|
|
48
|
+
try {
|
|
49
|
+
const response = await fetch('http://localhost:3001/tests');
|
|
50
|
+
const data = await response.json();
|
|
51
|
+
|
|
52
|
+
suites = data.suites.suites;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Error fetching test suites:', error);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
function runTest() {
|
|
59
|
+
const formattedTestID = testID.replace(/\sOR\s/gi, (match) => match.toLowerCase());
|
|
60
|
+
output = `Running test with ID: ${formattedTestID}...\n`;
|
|
61
|
+
testCompleted = false;
|
|
62
|
+
socket.emit('run-test', formattedTestID, 'manual-trigger');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function fetchLatestReport() {
|
|
66
|
+
const response = await fetch('http://localhost:3001/reports/latest');
|
|
67
|
+
const data = await response.json();
|
|
68
|
+
latestReport = data.latestReport;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function scrollToBottom() {
|
|
72
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
73
|
+
if (outputRef) outputRef.scrollTop = outputRef.scrollHeight;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function copyIdToTextbox(id) {
|
|
77
|
+
console.log('Selected Test ID:', id);
|
|
78
|
+
testID = id;
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<div class="flex flex-col md:flex-row w-full my-4">
|
|
83
|
+
<!-- Left Panel: Run Tests -->
|
|
84
|
+
<div
|
|
85
|
+
class="card bg-base-300 rounded-box grid flex-grow place-items-center md:w-1/2 w-full p-4 md:mr-2 md:ml-4 mb-4 md:mb-0"
|
|
86
|
+
>
|
|
87
|
+
<div class="card-body items-center text-center">
|
|
88
|
+
<h2 class="card-title">Run Tests</h2>
|
|
89
|
+
<p>Enter a test case/suite ID or select an ID from the Test List</p>
|
|
90
|
+
<label class="form-control w-full max-w-xs mt-4">
|
|
91
|
+
<input
|
|
92
|
+
type="text"
|
|
93
|
+
class="input input-bordered w-full max-w-xs"
|
|
94
|
+
bind:value={testID}
|
|
95
|
+
placeholder="Enter test ID"
|
|
96
|
+
/>
|
|
97
|
+
</label>
|
|
98
|
+
<div class="card-actions justify-end">
|
|
99
|
+
<button class="btn btn-primary" on:click={runTest}>Run</button>
|
|
100
|
+
{#if testCompleted}
|
|
101
|
+
<a href={`http://localhost:3001/reports/${latestReport}`} target="_blank">
|
|
102
|
+
<button class="btn btn-primary">View Report</button>
|
|
103
|
+
</a>
|
|
104
|
+
{/if}
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<pre
|
|
109
|
+
bind:this={outputRef}
|
|
110
|
+
class="bg-black rounded-box p-4 w-full overflow-auto whitespace-pre-wrap h-64 max-h-64">{output}</pre>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<!-- Right Panel: Test List -->
|
|
114
|
+
<div class="card bg-base-300 rounded-box md:w-1/2 w-full p-4 md:ml-2 md:mr-4">
|
|
115
|
+
<div class="card-body items-center text-center">
|
|
116
|
+
<h2 class="card-title sticky top-0 bg-base-300 z-10">Test List</h2>
|
|
117
|
+
<div class="mt-4">
|
|
118
|
+
{#each suites as suite, suiteIndex}
|
|
119
|
+
<div class="collapse bg-base-200 mb-4">
|
|
120
|
+
<input type="radio" name="my-accordion-1" id="collapse-{suiteIndex}" />
|
|
121
|
+
<label
|
|
122
|
+
for="collapse-{suiteIndex}"
|
|
123
|
+
class="collapse-title font-medium justify-start cursor-pointer"
|
|
124
|
+
>
|
|
125
|
+
{#if Array.isArray(suite.suiteId)}
|
|
126
|
+
{#each suite.suiteId as suiteId}
|
|
127
|
+
<div class="badge badge-primary mr-2">{suiteId}</div>
|
|
128
|
+
{/each}
|
|
129
|
+
{:else}
|
|
130
|
+
<div class="badge badge-primary mr-2">{suite.suiteId}</div>
|
|
131
|
+
{/if}
|
|
132
|
+
{suite.suiteName}
|
|
133
|
+
</label>
|
|
134
|
+
|
|
135
|
+
<div class="collapse-content">
|
|
136
|
+
<button
|
|
137
|
+
class="btn btn-active btn-ghost btn-xs"
|
|
138
|
+
on:click={() =>
|
|
139
|
+
copyIdToTextbox(Array.isArray(suite.suiteId) ? suite.suiteId[0] : suite.suiteId)}
|
|
140
|
+
>
|
|
141
|
+
Select Suite
|
|
142
|
+
</button>
|
|
143
|
+
|
|
144
|
+
<div class="card rounded-lg shadow-md mt-2">
|
|
145
|
+
<div class="overflow-x-auto">
|
|
146
|
+
<table class="table">
|
|
147
|
+
<thead>
|
|
148
|
+
<tr>
|
|
149
|
+
<th>ID</th>
|
|
150
|
+
<th>Test Case</th>
|
|
151
|
+
</tr>
|
|
152
|
+
</thead>
|
|
153
|
+
<tbody>
|
|
154
|
+
{#each suite.tests as test}
|
|
155
|
+
<tr>
|
|
156
|
+
<th>
|
|
157
|
+
{#if Array.isArray(test.id)}
|
|
158
|
+
{#each test.id as testId}
|
|
159
|
+
<button
|
|
160
|
+
class="btn btn-active btn-ghost btn-xs mr-1"
|
|
161
|
+
on:click={() => copyIdToTextbox(testId)}
|
|
162
|
+
>
|
|
163
|
+
{testId}
|
|
164
|
+
</button>
|
|
165
|
+
{/each}
|
|
166
|
+
{:else}
|
|
167
|
+
<button
|
|
168
|
+
class="btn btn-active btn-ghost btn-xs"
|
|
169
|
+
on:click={() => copyIdToTextbox(test.id)}
|
|
170
|
+
>
|
|
171
|
+
{test.id}
|
|
172
|
+
</button>
|
|
173
|
+
{/if}
|
|
174
|
+
</th>
|
|
175
|
+
<td>{test.testCase}</td>
|
|
176
|
+
</tr>
|
|
177
|
+
{/each}
|
|
178
|
+
</tbody>
|
|
179
|
+
</table>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
{/each}
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* This file is part of Plum.
|
|
3
|
+
*
|
|
4
|
+
* Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* Plum is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<div class="navbar bg-base-100">
|
|
19
|
+
<div class="navbar-start">
|
|
20
|
+
<div class="dropdown">
|
|
21
|
+
<div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
|
|
22
|
+
<svg
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
+
class="h-5 w-5"
|
|
25
|
+
fill="none"
|
|
26
|
+
viewBox="0 0 24 24"
|
|
27
|
+
stroke="currentColor"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
stroke-linecap="round"
|
|
31
|
+
stroke-linejoin="round"
|
|
32
|
+
stroke-width="2"
|
|
33
|
+
d="M4 6h16M4 12h8m-8 6h16"
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
</div>
|
|
37
|
+
<ul class="menu menu-sm dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow">
|
|
38
|
+
<li><a href="/">Home</a></li>
|
|
39
|
+
<li><a href="/reports">Reports</a></li>
|
|
40
|
+
<li><a href="/scheduled-tests">Scheduled Tests</a></li>
|
|
41
|
+
</ul>
|
|
42
|
+
</div>
|
|
43
|
+
<a href="/" class="btn btn-ghost text-xl">Plum</a>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="navbar-center hidden lg:flex">
|
|
46
|
+
<ul class="menu menu-horizontal px-1">
|
|
47
|
+
<li><a href="/">Home</a></li>
|
|
48
|
+
<li><a href="/reports">Reports</a></li>
|
|
49
|
+
<li><a href="/scheduled-tests">Scheduled Tests</a></li>
|
|
50
|
+
</ul>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="navbar-end"></div>
|
|
53
|
+
</div>
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* This file is part of Plum.
|
|
3
|
+
*
|
|
4
|
+
* Plum is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* Plum is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with Plum. If not, see https://www.gnu.org/licenses/.
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { onMount } from 'svelte';
|
|
20
|
+
|
|
21
|
+
let reports = [];
|
|
22
|
+
let currentPage = 1;
|
|
23
|
+
const itemsPerPage = 10;
|
|
24
|
+
|
|
25
|
+
async function fetchReports() {
|
|
26
|
+
const response = await fetch('http://localhost:3001/reports');
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
|
|
29
|
+
reports = data.reports.map((fileName) => {
|
|
30
|
+
// Updated regex to capture the trigger type and tags inside parentheses
|
|
31
|
+
const match = fileName.match(
|
|
32
|
+
/(PASS|FAIL)_cucumber_report_([^_]+)_\(([^)]+)\)_(\d{4})_(\d{2})_(\d{2})T(\d{2})_(\d{2})_(\d{2})_\d{3}Z\.html/
|
|
33
|
+
);
|
|
34
|
+
if (!match)
|
|
35
|
+
return {
|
|
36
|
+
fileName,
|
|
37
|
+
status: 'Unknown',
|
|
38
|
+
triggerType: 'Invalid Trigger',
|
|
39
|
+
tags: 'Invalid Tags',
|
|
40
|
+
date: 'Invalid Date'
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const [_, status, triggerType, tagsString, year, month, day, hour, minute, second] = match;
|
|
44
|
+
|
|
45
|
+
// Format date properly
|
|
46
|
+
const rawDate = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}Z`);
|
|
47
|
+
const formattedDate = rawDate.toLocaleString();
|
|
48
|
+
|
|
49
|
+
return { fileName, status, triggerType, tags: tagsString, date: formattedDate };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Calculate the start and end indices for pagination
|
|
54
|
+
function paginatedReports() {
|
|
55
|
+
const startIndex = (currentPage - 1) * itemsPerPage;
|
|
56
|
+
const endIndex = startIndex + itemsPerPage;
|
|
57
|
+
return reports.slice(startIndex, endIndex);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function goToPage(pageNumber) {
|
|
61
|
+
if (pageNumber < 1 || pageNumber > totalPages()) return;
|
|
62
|
+
currentPage = pageNumber;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function totalPages() {
|
|
66
|
+
return Math.ceil(reports.length / itemsPerPage);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
onMount(fetchReports);
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<div class="flex justify-center items-center w-full my-4">
|
|
73
|
+
<div class="card bg-base-300 rounded-box p-4">
|
|
74
|
+
<div class="card-body text-left">
|
|
75
|
+
<h2 class="card-title sticky top-0 bg-base-300 z-10">Reports</h2>
|
|
76
|
+
<div class="mt-4">
|
|
77
|
+
{#if reports.length > 0}
|
|
78
|
+
<div class="overflow-x-auto">
|
|
79
|
+
<table class="table">
|
|
80
|
+
<thead>
|
|
81
|
+
<tr>
|
|
82
|
+
<th>Status</th>
|
|
83
|
+
<th>Type</th>
|
|
84
|
+
<th>Tags</th>
|
|
85
|
+
<th>Date</th>
|
|
86
|
+
</tr>
|
|
87
|
+
</thead>
|
|
88
|
+
<tbody>
|
|
89
|
+
{#each paginatedReports() as report}
|
|
90
|
+
<tr
|
|
91
|
+
on:click={() =>
|
|
92
|
+
window.open(`http://localhost:3001/reports/${report.fileName}`, '_blank')}
|
|
93
|
+
style="cursor: pointer;"
|
|
94
|
+
>
|
|
95
|
+
<td>
|
|
96
|
+
<span
|
|
97
|
+
class="badge"
|
|
98
|
+
class:badge-success={report.status === 'PASS'}
|
|
99
|
+
class:badge-error={report.status === 'FAIL'}
|
|
100
|
+
>
|
|
101
|
+
{report.status}
|
|
102
|
+
</span>
|
|
103
|
+
</td>
|
|
104
|
+
<td>
|
|
105
|
+
{#if report.triggerType === 'manual-trigger'}
|
|
106
|
+
<span class="badge badge-primary">Manual Trigger</span>
|
|
107
|
+
{:else if report.triggerType === 'command-line-trigger'}
|
|
108
|
+
<span class="badge badge-primary">CLI Trigger</span>
|
|
109
|
+
{:else}
|
|
110
|
+
<span class="badge badge-secondary">Scheduled: {report.triggerType}</span>
|
|
111
|
+
{/if}
|
|
112
|
+
</td>
|
|
113
|
+
<td>
|
|
114
|
+
<span class="badge badge-neutral">
|
|
115
|
+
{report.tags}
|
|
116
|
+
</span>
|
|
117
|
+
</td>
|
|
118
|
+
<td>
|
|
119
|
+
{report.date}
|
|
120
|
+
</td>
|
|
121
|
+
</tr>
|
|
122
|
+
{/each}
|
|
123
|
+
</tbody>
|
|
124
|
+
</table>
|
|
125
|
+
</div>
|
|
126
|
+
<!-- Pagination Controls -->
|
|
127
|
+
<div class="flex justify-center mt-4">
|
|
128
|
+
<div class="btn-group">
|
|
129
|
+
<button
|
|
130
|
+
class="btn btn-ghost"
|
|
131
|
+
on:click={() => goToPage(currentPage - 1)}
|
|
132
|
+
disabled={currentPage === 1}
|
|
133
|
+
>
|
|
134
|
+
Previous
|
|
135
|
+
</button>
|
|
136
|
+
{#each Array(totalPages()) as _, i}
|
|
137
|
+
<button
|
|
138
|
+
class="btn mx-1"
|
|
139
|
+
on:click={() => goToPage(i + 1)}
|
|
140
|
+
class:btn-active={currentPage === i + 1}
|
|
141
|
+
>
|
|
142
|
+
{i + 1}
|
|
143
|
+
</button>
|
|
144
|
+
{/each}
|
|
145
|
+
<button
|
|
146
|
+
class="btn btn-primary"
|
|
147
|
+
on:click={() => goToPage(currentPage + 1)}
|
|
148
|
+
disabled={currentPage === totalPages()}
|
|
149
|
+
>
|
|
150
|
+
Next
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
{:else}
|
|
155
|
+
<p>No reports available.</p>
|
|
156
|
+
{/if}
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|