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,30 @@
|
|
|
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
|
+
FROM mcr.microsoft.com/playwright:v1.41.1
|
|
19
|
+
WORKDIR /app
|
|
20
|
+
|
|
21
|
+
COPY package.json package-lock.json ./
|
|
22
|
+
RUN npm install
|
|
23
|
+
RUN npx playwright install --with-deps
|
|
24
|
+
|
|
25
|
+
COPY . .
|
|
26
|
+
|
|
27
|
+
RUN npm run create-env && sed -i 's/^IS_HEADLESS=false/IS_HEADLESS=true/' .env
|
|
28
|
+
|
|
29
|
+
EXPOSE 3001
|
|
30
|
+
CMD ["node", "server.js"]
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { SAMPLE_CONSTANT } = require('../utils/constants');
|
|
2
|
+
const Utils = require('../utils/utils');
|
|
3
|
+
|
|
4
|
+
class LoginPage {
|
|
5
|
+
constructor(page) {
|
|
6
|
+
this.page = page;
|
|
7
|
+
this.utils = new Utils(this.page);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async goToLoginPage() {
|
|
11
|
+
console.log(SAMPLE_CONSTANT);
|
|
12
|
+
await this.utils.goToPage(process.env.BASE_URL);
|
|
13
|
+
await this.page.waitForTimeout(3000);
|
|
14
|
+
throw Error();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async skipTest() {
|
|
18
|
+
test.skip();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = LoginPage;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
require('dotenv').config();
|
|
19
|
+
|
|
20
|
+
const { Before, After, setWorldConstructor } = require('@cucumber/cucumber');
|
|
21
|
+
const { chromium } = require('playwright');
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
const Utils = require('../utils/utils');
|
|
25
|
+
const LoginPage = require('../pages/LoginPage');
|
|
26
|
+
|
|
27
|
+
class CustomWorld {
|
|
28
|
+
constructor({ attach }) {
|
|
29
|
+
// Enable attaching files to reports
|
|
30
|
+
this.attach = attach;
|
|
31
|
+
|
|
32
|
+
// Instance
|
|
33
|
+
this.browser = null;
|
|
34
|
+
this.context = null;
|
|
35
|
+
this.page = null;
|
|
36
|
+
|
|
37
|
+
// Pages
|
|
38
|
+
this.loginPage = null;
|
|
39
|
+
this.utils = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setWorldConstructor(CustomWorld);
|
|
44
|
+
|
|
45
|
+
Before(async function () {
|
|
46
|
+
this.browser = await chromium.launch({ headless: process.env.IS_HEADLESS === 'true' });
|
|
47
|
+
this.context = await this.browser.newContext();
|
|
48
|
+
this.page = await this.context.newPage();
|
|
49
|
+
this.loginPage = new LoginPage(this.page);
|
|
50
|
+
this.utils = new Utils(this.page);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
After(async function (scenario) {
|
|
54
|
+
if (scenario.result.status === 'FAILED') {
|
|
55
|
+
const screenshotPath = path.join('reports/screenshots', `screenshot_${Date.now()}.png`);
|
|
56
|
+
await this.page.screenshot({ path: screenshotPath });
|
|
57
|
+
|
|
58
|
+
// Attach screenshot to the Cucumber report
|
|
59
|
+
const screenshotData = fs.readFileSync(screenshotPath);
|
|
60
|
+
this.attach(screenshotData, 'image/png');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Close the browser after each test
|
|
64
|
+
await this.browser.close();
|
|
65
|
+
});
|
package/backend/app.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
const express = require('express');
|
|
19
|
+
const cors = require('cors');
|
|
20
|
+
const app = express();
|
|
21
|
+
|
|
22
|
+
app.use(cors({ origin: '*' }));
|
|
23
|
+
app.use(express.json());
|
|
24
|
+
|
|
25
|
+
// Routes
|
|
26
|
+
const testRoutes = require('./routes/tests.routes');
|
|
27
|
+
const reportRoutes = require('./routes/reports.routes');
|
|
28
|
+
const cronRoutes = require('./routes/cron.routes');
|
|
29
|
+
const scheduleRoutes = require('./routes/schedules.routes');
|
|
30
|
+
|
|
31
|
+
app.use('/tests', testRoutes);
|
|
32
|
+
app.use('/reports', reportRoutes);
|
|
33
|
+
app.use('/cron-jobs', cronRoutes);
|
|
34
|
+
app.use('/reports', express.static('reports'));
|
|
35
|
+
app.use('/schedules', scheduleRoutes);
|
|
36
|
+
|
|
37
|
+
module.exports = app;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fse = require('fs-extra'); // fs-extra for directory copying
|
|
21
|
+
|
|
22
|
+
// Path to the settings.json file inside the backend/config directory
|
|
23
|
+
const settingsFilePath = path.join(process.cwd(), 'config', 'settings.json');
|
|
24
|
+
const scaffoldFolderPath = path.join(process.cwd(), '_scaffold');
|
|
25
|
+
const userTestsFolderPath = path.join(process.cwd(), 'tests');
|
|
26
|
+
|
|
27
|
+
// Check if the settings.json file exists
|
|
28
|
+
if (!fs.existsSync(settingsFilePath)) {
|
|
29
|
+
console.log('⚠️ settings.json not found. Creating it with default values...');
|
|
30
|
+
|
|
31
|
+
// Default content for settings.json
|
|
32
|
+
const settingsContent = JSON.stringify(
|
|
33
|
+
{
|
|
34
|
+
reportsHistory: 20,
|
|
35
|
+
cronJobSchedules: [
|
|
36
|
+
{ label: 'Every minute', value: '* * * * *' },
|
|
37
|
+
{ label: 'Every hour', value: '0 * * * *' },
|
|
38
|
+
{ label: 'Every midnight', value: '0 0 * * *' },
|
|
39
|
+
{ label: 'Every Sunday', value: '0 0 * * 0' }
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
null,
|
|
43
|
+
2
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Write the settings to the settings.json file
|
|
47
|
+
fs.writeFileSync(settingsFilePath, settingsContent, 'utf8');
|
|
48
|
+
console.log('✅ settings.json created with default values.');
|
|
49
|
+
} else {
|
|
50
|
+
console.log('⚠️ settings.json already exists. Skipping creation.');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check if the tests folder exists, if not, copy the scaffold folder as tests
|
|
54
|
+
if (!fs.existsSync(userTestsFolderPath)) {
|
|
55
|
+
console.log('🧪 `tests/` folder not found. Creating `tests/` from the scaffold folder...');
|
|
56
|
+
fse.copySync(scaffoldFolderPath, userTestsFolderPath);
|
|
57
|
+
console.log('✅ `tests/` folder created from scaffold.');
|
|
58
|
+
} else {
|
|
59
|
+
console.log('⚠️ `tests/` folder already exists. Skipping creation.');
|
|
60
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
const reporter = require('cucumber-html-reporter');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const { reportsHistory } = require('../settings.json');
|
|
22
|
+
|
|
23
|
+
/* -----------------------------------------------------
|
|
24
|
+
* Screenshot and Report Management
|
|
25
|
+
*
|
|
26
|
+
* Description:
|
|
27
|
+
* To avoid reports and screenshots extract
|
|
28
|
+
* status, tags, run name, and date.
|
|
29
|
+
* ------------------------------------------------------ */
|
|
30
|
+
|
|
31
|
+
const reportsDir = 'reports';
|
|
32
|
+
const screenshotsDir = path.join(reportsDir, 'screenshots');
|
|
33
|
+
const maxReports = reportsHistory;
|
|
34
|
+
|
|
35
|
+
// Ensure the reports and screenshots directories exist
|
|
36
|
+
if (!fs.existsSync(reportsDir)) {
|
|
37
|
+
fs.mkdirSync(reportsDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!fs.existsSync(screenshotsDir)) {
|
|
41
|
+
fs.mkdirSync(screenshotsDir, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Remove the oldest report depending on maxReport
|
|
45
|
+
const existingReports = fs
|
|
46
|
+
.readdirSync(reportsDir)
|
|
47
|
+
.filter((file) => file.startsWith('PASS_') || file.startsWith('FAIL_'))
|
|
48
|
+
.sort(
|
|
49
|
+
(a, b) =>
|
|
50
|
+
fs.statSync(path.join(reportsDir, b)).mtime - fs.statSync(path.join(reportsDir, a)).mtime
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
while (existingReports.length >= maxReports) {
|
|
54
|
+
const oldestReport = existingReports.pop();
|
|
55
|
+
fs.unlinkSync(path.join(reportsDir, oldestReport));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Remove the oldest screenshot depending on maxReport
|
|
59
|
+
const existingScreenshots = fs
|
|
60
|
+
.readdirSync(screenshotsDir)
|
|
61
|
+
.filter((file) => file.endsWith('.png') || file.endsWith('.jpg'))
|
|
62
|
+
.sort(
|
|
63
|
+
(a, b) =>
|
|
64
|
+
fs.statSync(path.join(screenshotsDir, b)).mtime -
|
|
65
|
+
fs.statSync(path.join(screenshotsDir, a)).mtime
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
while (existingScreenshots.length >= maxReports) {
|
|
69
|
+
const oldestScreenshot = existingScreenshots.pop();
|
|
70
|
+
fs.unlinkSync(path.join(screenshotsDir, oldestScreenshot));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* -----------------------------------------------------
|
|
74
|
+
* Generate the report name
|
|
75
|
+
*
|
|
76
|
+
* Description:
|
|
77
|
+
* This is where the reports page will
|
|
78
|
+
* extract status, tags, run name, and date.
|
|
79
|
+
* ------------------------------------------------------ */
|
|
80
|
+
|
|
81
|
+
const jsonReportFile = path.join(reportsDir, 'cucumber_report.json');
|
|
82
|
+
let status = 'PASS';
|
|
83
|
+
|
|
84
|
+
if (fs.existsSync(jsonReportFile)) {
|
|
85
|
+
const reportData = fs.readFileSync(jsonReportFile, 'utf8');
|
|
86
|
+
|
|
87
|
+
// Ensure the JSON is not empty
|
|
88
|
+
if (reportData) {
|
|
89
|
+
const parsedData = JSON.parse(reportData);
|
|
90
|
+
|
|
91
|
+
const hasFailures = parsedData.some((feature) =>
|
|
92
|
+
feature.elements.some((scenario) =>
|
|
93
|
+
scenario.steps.some((step) => step.result.status === 'failed')
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
if (hasFailures) {
|
|
98
|
+
status = 'FAIL';
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.log('Report file is empty or malformed');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let tag = process.env.TAG;
|
|
106
|
+
|
|
107
|
+
if (!tag) {
|
|
108
|
+
tag = '(@all-tests)';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (tag && !tag.startsWith('(') && !tag.endsWith(')')) {
|
|
112
|
+
tag = `(${tag})`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const timestamp = new Date().toISOString().replace(/[-:.]/g, '_');
|
|
116
|
+
const reportFileName = `${status}_cucumber_report_${process.env.TRIGGER}_${tag}_${timestamp}.html`;
|
|
117
|
+
|
|
118
|
+
const options = {
|
|
119
|
+
theme: 'bootstrap',
|
|
120
|
+
jsonFile: jsonReportFile,
|
|
121
|
+
output: path.join(reportsDir, reportFileName),
|
|
122
|
+
reportSuiteAsScenarios: true,
|
|
123
|
+
launchReport: true, // Automatically opens the report in a browser
|
|
124
|
+
metadata: {
|
|
125
|
+
'App Name': 'Plum',
|
|
126
|
+
'Test Environment': 'Local',
|
|
127
|
+
Browser: 'Chromium',
|
|
128
|
+
Platform: 'Ubuntu',
|
|
129
|
+
Parallel: 'Scenarios',
|
|
130
|
+
Executed: 'Local'
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
reporter.generate(options);
|
|
135
|
+
console.log(`Generated report: ${reportFileName}`);
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
const { execSync } = require('child_process');
|
|
19
|
+
const tag = process.env.TAG; // Read the TAG environment variable
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// Run the tests with the tag filter, only if a tag is provided
|
|
23
|
+
const cucumberCommand = tag
|
|
24
|
+
? `cucumber-js tests/features/**/*.feature --format json:reports/cucumber_report.json --tags "${tag}"`
|
|
25
|
+
: `cucumber-js tests/features/**/*.feature --format json:reports/cucumber_report.json`;
|
|
26
|
+
|
|
27
|
+
execSync(cucumberCommand, { stdio: 'inherit' });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Tests failed:', error.message);
|
|
30
|
+
} finally {
|
|
31
|
+
// Always run the report generation after tests (even if they fail)
|
|
32
|
+
try {
|
|
33
|
+
execSync('node config/scripts/generate-report.js', { stdio: 'inherit' });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error running report generation:', error.message);
|
|
36
|
+
}
|
|
37
|
+
}
|