plum-e2e 1.0.2 โ†’ 1.0.4

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.
Files changed (43) hide show
  1. package/.prettierrc +15 -15
  2. package/README.md +66 -5
  3. package/backend/_scaffold/pages/LoginPage.js +22 -22
  4. package/backend/_scaffold/step_definitions/LoginSteps.js +9 -9
  5. package/backend/_scaffold/utils/constants.js +3 -3
  6. package/backend/_scaffold/utils/hooks.js +65 -65
  7. package/backend/_scaffold/utils/utils.js +10 -10
  8. package/backend/app.js +37 -37
  9. package/backend/config/scripts/create-settings.js +60 -60
  10. package/backend/config/scripts/generate-report.js +135 -135
  11. package/backend/config/scripts/run-tests.js +37 -37
  12. package/backend/cucumber.json +6 -6
  13. package/backend/package.json +29 -29
  14. package/backend/playwright.config.js +97 -97
  15. package/backend/routes/cron.routes.js +127 -127
  16. package/backend/routes/reports.routes.js +42 -42
  17. package/backend/routes/schedules.routes.js +32 -32
  18. package/backend/routes/tests.routes.js +33 -33
  19. package/backend/server.js +39 -39
  20. package/backend/services/cronService.js +127 -127
  21. package/backend/services/envService.js +43 -43
  22. package/backend/services/reportService.js +50 -50
  23. package/backend/services/scheduleService.js +34 -34
  24. package/backend/services/testService.js +70 -70
  25. package/backend/websockets/socketHandler.js +46 -46
  26. package/bin/plum.js +198 -198
  27. package/docker-compose.yml +41 -41
  28. package/frontend/jsconfig.json +13 -13
  29. package/frontend/package.json +26 -26
  30. package/frontend/postcss.config.js +23 -23
  31. package/frontend/src/app.css +35 -35
  32. package/frontend/src/app.html +28 -28
  33. package/frontend/src/lib/index.js +18 -18
  34. package/frontend/src/routes/+layout.svelte +34 -34
  35. package/frontend/src/routes/+page.svelte +188 -188
  36. package/frontend/src/routes/components/Navigation.svelte +53 -53
  37. package/frontend/src/routes/reports/+page.svelte +160 -160
  38. package/frontend/src/routes/scheduled-tests/+page.svelte +363 -363
  39. package/frontend/svelte.config.js +30 -30
  40. package/frontend/tailwind.config.js +44 -44
  41. package/frontend/vite.config.js +23 -23
  42. package/license-config.json +37 -37
  43. package/package.json +32 -28
package/.prettierrc CHANGED
@@ -1,15 +1,15 @@
1
- {
2
- "useTabs": true,
3
- "singleQuote": true,
4
- "trailingComma": "none",
5
- "printWidth": 100,
6
- "plugins": ["prettier-plugin-svelte"],
7
- "overrides": [
8
- {
9
- "files": "*.svelte",
10
- "options": {
11
- "parser": "svelte"
12
- }
13
- }
14
- ]
15
- }
1
+ {
2
+ "useTabs": true,
3
+ "singleQuote": true,
4
+ "trailingComma": "none",
5
+ "printWidth": 100,
6
+ "plugins": ["prettier-plugin-svelte"],
7
+ "overrides": [
8
+ {
9
+ "files": "*.svelte",
10
+ "options": {
11
+ "parser": "svelte"
12
+ }
13
+ }
14
+ ]
15
+ }
package/README.md CHANGED
@@ -1,5 +1,66 @@
1
- ![alt-text="social-preview"](https://repository-images.githubusercontent.com/936477779/e928fce3-6d4c-4609-92a0-0a1091c99752)
2
-
3
- **_Pre-requisite:_**
4
-
5
- **_I. How to Run:_**
1
+ ![alt-text="social-preview"](https://repository-images.githubusercontent.com/936477779/e928fce3-6d4c-4609-92a0-0a1091c99752)
2
+
3
+ <p align="center">
4
+ ๐Ÿ“– <a href="https://github.com/silverlunah/plum/wiki">Wiki</a> |
5
+ ๐Ÿ“ฆ <a href="https://www.npmjs.com/package/plum-e2e">npm</a>
6
+ </p>
7
+
8
+ ## Welcome to Plum!
9
+
10
+ Plum makes setting up your testing framework easy. In just a few seconds, you can run the scaffold tests and write your own tests!
11
+
12
+ By combining [Playwright](https://playwright.dev) and [Cucumber](https://cucumber.io), tests are easy to write and read. The code follows a POM (Page Object Model) structure, making it scalable and easy for developers to understand, while Cucumber test cases are written in [Gherkin](https://cucumber.io/docs/gherkin/) format, making them accessible to non-developers as well.
13
+
14
+ You can view, run, schedule tests in a simple UI and even view the history of your runs in the Report page!
15
+
16
+ **_Pre-requisite:_**
17
+
18
+ 1. Install Docker and ensure the Docker daemon is running.
19
+
20
+ ## For Users
21
+
22
+ For normal users. People that want to use Plum as a test environment for their website.
23
+
24
+ **_I. How to Run:_**
25
+
26
+ 1. `npm install -g plum-e2e`
27
+ 2. Create your project directory. Example: `mkdir my-test-folder`
28
+ 3. Go inside the folder you created `cd my-test-folder`
29
+ 4. Run `plum init`
30
+ 1. This will initialize Plum and will create your base files:
31
+ 1. `\tests` folder: This include sample test cases for [SauceLabs](https://www.saucedemo.com/v1/)
32
+ 2. `.env` file: Your starting .env file. You can set the BASE_URL to your own site after you're done with the scaffold tests.
33
+ 5. There are two ways to start testing:
34
+ 1. By running the server. Run:<br/> `plum start to start the server`
35
+ 2. Without running the server. Recommended while you're writing your tests. Run:<br/> `plum dev <@test-id>`. If no test ID is included, it will run all tests
36
+
37
+ ## Basic Structure
38
+
39
+ After you run `plum init`, these files will be created inside your project directory.
40
+
41
+ <pre>
42
+ โ• โ• tests
43
+ โ•‘ โ• โ• features : Cucumber feature files, contains your test cases
44
+ โ•‘ โ• โ• step_definitions : Reference to steps in the feature files
45
+ โ•‘ โ• โ• pages : Contains functions used in step_definitions
46
+ โ•‘ โ•šโ• utils : Utility files (Constants, utility codes, etc.)
47
+ โ•šโ• env. : Your .env file
48
+ </pre>
49
+
50
+ ## Tutorial
51
+
52
+ 1. For a complete guide on how to write tests, visit our [Wiki](https://github.com/silverlunah/plum/wiki)
53
+ 2. An easy way to learn is to check the scaffold files starting from the Feature files -> Step Definitions -> Page files and utils/hooks.js for the CustomWorld and Before hook page class initialization. Those are the main files you need to write a test case.
54
+
55
+ ## For Developers/Contributors
56
+
57
+ For people that want to contribute to the project
58
+
59
+ 1. Clone the project `git clone https://github.com/silverlunah/plum.git`
60
+ 2. `cd plum`
61
+ 3. Initialize the project by:<br/>`npm run init`
62
+ 4. Check if its running:<br/> `docker compose up --build -d`
63
+
64
+ ## Other
65
+
66
+ Plum is completely free to use! But if you want to share some love, here's my [PayPal](https://www.paypal.me/silverlunah) or [Wise](<[https://www.paypal.me/silverlunah](https://wise.com/pay/me/janneserjosee)>)
@@ -1,22 +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;
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;
@@ -1,9 +1,9 @@
1
- const { Given, When, Then } = require('@cucumber/cucumber');
2
-
3
- Given('I am in Demo Sauce Login page', async function () {
4
- await this.loginPage.goToLoginPage();
5
- });
6
-
7
- Given('I fail this test', async function () {
8
- throw new Error('err');
9
- });
1
+ const { Given, When, Then } = require('@cucumber/cucumber');
2
+
3
+ Given('I am in Demo Sauce Login page', async function () {
4
+ await this.loginPage.goToLoginPage();
5
+ });
6
+
7
+ Given('I fail this test', async function () {
8
+ throw new Error('err');
9
+ });
@@ -1,3 +1,3 @@
1
- module.exports = {
2
- SAMPLE_CONSTANT: 'this is a constant'
3
- };
1
+ module.exports = {
2
+ SAMPLE_CONSTANT: 'this is a constant'
3
+ };
@@ -1,65 +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
- });
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
+ });
@@ -1,10 +1,10 @@
1
- class Utils {
2
- constructor(page) {
3
- this.page = page;
4
- }
5
- async goToPage(url) {
6
- await this.page.goto(url);
7
- }
8
- }
9
-
10
- module.exports = Utils;
1
+ class Utils {
2
+ constructor(page) {
3
+ this.page = page;
4
+ }
5
+ async goToPage(url) {
6
+ await this.page.goto(url);
7
+ }
8
+ }
9
+
10
+ module.exports = Utils;
package/backend/app.js CHANGED
@@ -1,37 +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;
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;
@@ -1,60 +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
- }
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
+ }