ortoni-report 1.1.2 → 1.1.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.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,76 +1,16 @@
1
- const isOpenClass = "modal-is-open";
2
- const openingClass = "modal-is-opening";
3
- const closingClass = "modal-is-closing";
4
- const scrollbarWidthCssVar = "--pico-scrollbar-width";
5
- const animationDuration = 400; // ms
6
- let visibleModal = null;
7
-
8
- // Toggle modal
9
- function toggleModal(event) {
10
- event.preventDefault();
11
- const modal = document.getElementById(event.currentTarget.dataset.target);
12
- if (!modal) return;
13
- if (modal) {
14
- if (modal.open) {
15
- closeModal(modal);
16
- } else {
17
- openModal(modal);
18
- }
19
- }
20
- }
21
-
22
- // Open modal
23
- function openModal(modal) {
24
- const html = document.documentElement;
25
- const scrollbarWidth = getScrollbarWidth();
26
- if (scrollbarWidth) {
27
- html.style.setProperty(scrollbarWidthCssVar, `${scrollbarWidth}px`);
28
- }
29
- html.classList.add(isOpenClass, openingClass);
30
- setTimeout(function () {
31
- visibleModal = modal;
32
- html.classList.remove(openingClass);
33
- }, animationDuration);
34
- modal.showModal();
1
+ // Functions to open and close a modal
2
+ function openModal() {
3
+ let modal = document.getElementsByClassName("modal")[0];
4
+ modal.classList.add("is-active")
35
5
  }
36
6
 
37
- // Close modal
38
- function closeModal(modal) {
39
- visibleModal = null;
40
- const html = document.documentElement;
41
- html.classList.add(closingClass);
42
- setTimeout(function () {
43
- html.classList.remove(closingClass, isOpenClass);
44
- html.style.removeProperty(scrollbarWidthCssVar);
45
- modal.close();
46
- }, animationDuration);
7
+ function closeModal() {
8
+ let modal = document.getElementsByClassName("modal")[0];
9
+ modal.classList.remove("is-active")
47
10
  }
48
-
49
- // Close with a click outside
50
- document.addEventListener("click", function (event) {
51
- if (visibleModal === null) return;
52
- const modalContent = visibleModal.querySelector("article");
53
- const isClickInside = modalContent.contains(event.target);
54
- if (!isClickInside) {
55
- closeModal(visibleModal);
11
+ // Add a keyboard event to close all modals
12
+ document.addEventListener('keydown', (event) => {
13
+ if (event.key === "Escape") {
14
+ closeModal();
56
15
  }
57
- });
58
-
59
- // Close with Esc key
60
- document.addEventListener("keydown", function (event) {
61
- if (event.key === "Escape" && visibleModal) {
62
- closeModal(visibleModal);
63
- }
64
- });
65
-
66
- // Get scrollbar width
67
- function getScrollbarWidth() {
68
- const scrollbarWidth =
69
- window.innerWidth - document.documentElement.clientWidth;
70
- return scrollbarWidth;
71
- }
72
-
73
- // Is scrollbar visible
74
- function isScrollbarVisible() {
75
- return document.body.scrollHeight > screen.height;
76
- }
16
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatDate = exports.normalizeFilePath = exports.msToTime = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ function msToTime(duration) {
9
+ const milliseconds = Math.floor((duration % 1000));
10
+ const seconds = Math.floor((duration / 1000) % 60);
11
+ const minutes = Math.floor((duration / (1000 * 60)) % 60);
12
+ const hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
13
+ let result = '';
14
+ if (hours > 0) {
15
+ result += (hours < 10 ? "0" + hours : hours) + "h:";
16
+ }
17
+ if (minutes > 0 || hours > 0) { // Include minutes if hours are included
18
+ result += (minutes < 10 ? "0" + minutes : minutes) + "m:";
19
+ }
20
+ if (seconds > 0 || minutes > 0 || hours > 0) { // Include seconds if minutes or hours are included
21
+ result += (seconds < 10 ? "0" + seconds : seconds) + "s";
22
+ }
23
+ if (milliseconds > 0) {
24
+ result += ":" + (milliseconds < 100 ? "0" + milliseconds : milliseconds) + "ms";
25
+ }
26
+ return result;
27
+ }
28
+ exports.msToTime = msToTime;
29
+ function normalizeFilePath(filePath) {
30
+ // Normalize the path to handle different separators
31
+ const normalizedPath = path_1.default.normalize(filePath);
32
+ // Get the base name of the file (removes any leading directories)
33
+ return path_1.default.basename(normalizedPath);
34
+ }
35
+ exports.normalizeFilePath = normalizeFilePath;
36
+ function formatDate(date) {
37
+ const day = String(date.getDate()).padStart(2, '0');
38
+ const month = date.toLocaleString('default', { month: 'short' });
39
+ const year = date.getFullYear();
40
+ const time = date.toLocaleTimeString();
41
+ return `${day}-${month}-${year} ${time}`;
42
+ }
43
+ exports.formatDate = formatDate;
44
+ ;
package/package.json CHANGED
@@ -1,49 +1,47 @@
1
- {
2
- "name": "ortoni-report",
3
- "version": "1.1.2",
4
- "description": "Playwright Report By LetCode with Koushik",
5
- "scripts": {
6
- "test": "npx playwright test",
7
- "build": "tsup",
8
- "release": "npm publish",
9
- "lint": "tsc"
10
- },
11
- "files": [
12
- "dist",
13
- "README.md",
14
- "CHANGELOG.md"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/ortoniKC/ortoni-report"
19
- },
20
- "keywords": [
21
- "playwright report",
22
- "playwright letcode",
23
- "letcode koushik",
24
- "ortoni report",
25
- "ortoni-report",
26
- "playwright html"
27
- ],
28
- "author": "Koushik Chatterjee (LetCode with Koushik)",
29
- "license": "GPL-3.0-only",
30
- "bugs": {
31
- "url": "https://github.com/ortoniKC/ortoni-report/issues"
32
- },
33
- "homepage": "https://github.com/ortoniKC/ortoni-report#readme",
34
- "dependencies": {
35
- "colors": "^1.4.0",
36
- "handlebars": "^4.7.8",
37
- "hiq": "^4.2.3",
38
- "rimraf": "^5.0.7"
39
- },
40
- "devDependencies": {
41
- "@playwright/test": "^1.44.1",
42
- "@types/node": "^20.14.2",
43
- "tsup": "^6.5.0",
44
- "typescript": "^4.9.4"
45
- },
46
- "main": "dist/ortoni-report.js",
47
- "module": "dist/ortoni-report.mjs",
48
- "types": "dist/ortoni-report.d.ts"
49
- }
1
+ {
2
+ "name": "ortoni-report",
3
+ "version": "1.1.4",
4
+ "description": "Playwright Report By LetCode with Koushik",
5
+ "scripts": {
6
+ "test": "npx playwright test",
7
+ "build": "tsup",
8
+ "release": "npm publish",
9
+ "lint": "tsc"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "CHANGELOG.md"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/ortoniKC/ortoni-report"
19
+ },
20
+ "keywords": [
21
+ "playwright report",
22
+ "playwright letcode",
23
+ "letcode koushik",
24
+ "ortoni report",
25
+ "ortoni-report",
26
+ "playwright html"
27
+ ],
28
+ "author": "Koushik Chatterjee (LetCode with Koushik)",
29
+ "license": "GPL-3.0-only",
30
+ "bugs": {
31
+ "url": "https://github.com/ortoniKC/ortoni-report/issues"
32
+ },
33
+ "homepage": "https://github.com/ortoniKC/ortoni-report#readme",
34
+ "dependencies": {
35
+ "colors": "^1.4.0",
36
+ "handlebars": "^4.7.8"
37
+ },
38
+ "devDependencies": {
39
+ "@playwright/test": "^1.44.1",
40
+ "@types/node": "^20.14.2",
41
+ "tsup": "^6.5.0",
42
+ "typescript": "^4.9.4"
43
+ },
44
+ "main": "dist/ortoni-report.js",
45
+ "module": "dist/ortoni-report.mjs",
46
+ "types": "dist/ortoni-report.d.ts"
47
+ }
package/readme.md CHANGED
@@ -4,54 +4,86 @@ We are excited to announce the release of OrtoniReport (Playwright report - unof
4
4
 
5
5
  [Click here to check the live Demo](https://ortoni.netlify.app/)
6
6
 
7
-
8
- ![Ortoni Report](https://github.com/ortoniKC/ortoni-report/assets/58769833/f96b7697-8ec0-4c6d-a681-b305e6d5843a)
7
+ ![Ortoni-Report](https://github.com/ortoniKC/ortoni-report/assets/58769833/e88f33d4-eb5c-41c7-b90a-f8a283af0058)
9
8
 
10
9
  ## Features
11
10
 
12
- 1. **Hierarchical Grouping:**
11
+ 1. **Hierarchical Grouping:**
12
+
13
13
  - Test results are now grouped hierarchically by file name, suite name, and project name, allowing for a clear and organized view of your test structure.
14
-
14
+
15
15
  2. **Detailed Breakdown:**
16
+
16
17
  - Each suite displays a sub-category for project names, with individual test cases listed under their respective projects.
17
18
 
18
19
  3. **Test Result Display:**
19
- - Display results including status (passed, failed, skipped), duration, errors, logs, and screenshots.
20
+
21
+ - Display results including status (passed, failed, skipped), duration, errors, logs, and screenshots.
20
22
  - Organize test results by suite, project, and test script.
21
23
 
22
24
  4. **Summary Statistics:**
25
+
23
26
  - Provide summary statistics for total tests, passed tests, failed tests, skipped tests, and flaky tests.
27
+ - Success Rate of test suite.
24
28
 
25
29
  5. **Chart Visualization:**
26
- - Visualize test results using a doughnut chart to represent the distribution of passed, failed, and skipped tests.
30
+
31
+ - Visualize test results using a doughnut chart to represent the distribution of passed, failed, skipped and flaky tests.
27
32
 
28
33
  6. **Project Information:**
34
+
29
35
  - Include project name, author name, and test type information in the report.
30
36
 
31
37
  7. **Search Functionality:**
38
+
32
39
  - Search bar to filter and display specific tests based on user input.
33
40
 
34
41
  8. **Reset Functionality:**
42
+
35
43
  - Allow users to reset the search bar to show all tests when cleared.
36
44
 
37
45
  9. **Customization:**
46
+
38
47
  - Customize project name, author name, and test type displayed in the report.
39
- - Dark/Light theme based on the user browser/system setting.
48
+ - Dark/Light theme based on the user toggle.
40
49
 
41
50
  10. **Responsive Design:**
51
+
42
52
  - Design the report layout to be responsive and adaptable to different screen sizes.
43
53
 
44
54
  11. **Accessibility:**
55
+
45
56
  - Ensure accessibility by providing appropriate HTML attributes and semantic structure.
46
57
 
47
58
  12. **Ease of Use:**
59
+
48
60
  - Enable easy navigation between test results and summary sections.
49
61
 
50
- These features collectively enhance the readability, usability, and accessibility of the test report, providing valuable insights into test execution and results.
62
+ 13. **Success Rate**
63
+ - The success rate in this project is calculated based on the outcomes of the tests executed using Playwright. The calculation considers tests that pass initially as well as tests that initially fail but pass upon retry
64
+ - Success Rate Formula
65
+ The success rate (successRate) is calculated using the following formula:
66
+ ```
67
+ const successRate: string = (((passedTests + flakyTests) / totalTests) * 100).toFixed(2);
68
+ ```
69
+ 14. **Project Filtering**: Implemented filtering of tests by projects (e.g., chromium, firefox) to streamline test result views.
70
+
71
+ 15. **Screenshots**: Implemented screenshot attachment as base64 images for enhanced report details
72
+
73
+ These features collectively enhance the readability, usability, and accessibility of the test report, providing valuable insights into test execution and results.
51
74
 
52
75
  ### Configurable Report Generation
76
+
53
77
  - **Flexible Configuration:** The reporter can be easily configured within your Playwright configuration file. Example:
54
78
  ```JS/TS
79
+ import {OrtoniReportConfig} from "ortoni-report";
80
+ let reportConfig: OrtoniReportConfig = {
81
+ projectName: "Ortoni",
82
+ testType: "Regression",
83
+ authorName: "Koushik",
84
+ preferredTheme: "light"
85
+ };
86
+
55
87
  reporter: [["ortoni-report",
56
88
  {
57
89
  projectName: 'LetCode Playwright Report',
@@ -61,15 +93,13 @@ These features collectively enhance the readability, usability, and accessibilit
61
93
  ["dot"]],
62
94
  ```
63
95
 
64
- ### Screenshot Handling
65
- - **Screenshot Storage:** Screenshots are now saved in a structured directory within the root of your project, ensuring that visual evidence is easily accessible.
66
- - **Automatic Directory Creation:** The reporter automatically creates necessary directories for storing screenshots.
67
-
68
96
  ### Comprehensive Test Details
97
+
69
98
  - **Rich Test Information:** Each test result includes the test title, status, duration, errors, steps, logs, and screenshot paths.
70
99
  - **Color-coded Status:** Test statuses are color-coded (green for passed, red for failed, yellow for skipped) for quick visual identification.
71
100
 
72
101
  ### Handlebars Template Integration
102
+
73
103
  - **Customizable Reports:** The HTML report is generated using Handlebars templates, allowing for easy customization and styling.
74
104
  - **JSON Helper:** A custom Handlebars helper for JSON stringification is included to handle complex data structures.
75
105
 
@@ -85,9 +115,15 @@ npm install ortoni-report
85
115
 
86
116
  Configure OrtoniReport in your `playwright.config.ts`:
87
117
 
88
- ``` javascript/typescript
118
+ ```javascript/typescript
89
119
  import { defineConfig } from '@playwright/test';
90
-
120
+ import {OrtoniReportConfig} from "ortoni-report";
121
+ let reportConfig: OrtoniReportConfig = {
122
+ projectName: "Ortoni",
123
+ testType: "Regression",
124
+ authorName: "Koushik",
125
+ preferredTheme: "light"
126
+ };
91
127
  export default defineConfig({
92
128
  reporter: [["ortoni-report",
93
129
  {
@@ -111,9 +147,11 @@ export default defineConfig({
111
147
  - **Advanced Filtering:** Additional filtering options to allow users to focus on specific subsets of test results.
112
148
 
113
149
  ## Change Logs:
150
+
114
151
  [log](https://github.com/ortoniKC/ortoni-report/blob/main/changelog.md)
115
152
 
116
153
  ## License:
154
+
117
155
  [LICENSE](https://github.com/ortoniKC/ortoni-report/blob/main/LICENSE.md)
118
156
 
119
157
  ## Feedback and Contributions