How ortonikc/ortoni-report works
Main Components
• CLI Interface: Represented primarily by the files in src/cli (for example, cli.ts) and the overall entry point in src/ortoni-report.ts. This component accepts commands (like “show-report”) and options (such as the directory, file, or port).
• Helper Modules: Under src/helpers, these include:
– HTMLGenerator: Responsible for converting test information into HTML views.
– FileManager and DatabaseManager: For reading/writing report assets, managing storage (e.g., the “report-db” folder).
– ResultProcessor: Parses and processes the Playwright test results.
– ServerManager: Sets up/modifies servers.
• Utilities: In src/utils, functions such as expressServer.ts, attachFiles.ts, and groupProjects.ts support the core operations like starting an Express server, managing test attachments, and grouping tests logically.
• Views/Assets: The precompiled Handlebars templates (in dist/views) and CSS style sheets (in dist/style) are used by the HTMLGenerator to produce the final report interface.
• External Integration & Configuration: The project supports integration into Playwright via configuration files (as shown by the example configurations in the README) and interacts with the test results generated during a Playwright run.
Relationships and Data Flow
• Data Entry: Test results from Playwright (configured in playwright.config.ts or .js) are passed into the Ortoni Report system.
• Processing Pipeline: The CLI triggers the main report generation process that calls on:
• The ResultProcessor (to interpret the raw test data).
• The HTMLGenerator (to produce HTML components based on Handlebars templates in the dist/views folder).
• FileManager and DatabaseManager (to handle saving and retrieving of report files and assets).
• Serving the Report: The Express server module (in src/utils/expressServer.ts, assisted by serverManager.ts) is spawned to serve the generated HTML report, listening on a configurable port (by default 2004) and providing live access via a browser.
• Output: A fully rendered HTML report that users can view in a browser with interactive navigation (sidebar, charts, and detailed test data).
Architectural Patterns and Design Principles
• Modularization: The project is clearly split into separate modules (CLI, Helpers, Utils), promoting single-responsibility and easier testing (with the tests folder containing integration/spec tests).
• Separation of Concerns: The HTML generation, file management, result processing, and server starting are handled by different modules.
• Template-based Rendering: Utilizing Handlebars templates (in dist/views) for dynamic HTML generation based on runtime test results.
• Extensibility: The configuration options (via playwright.config file examples) allow extensive customization of themes, report titles, and metadata.
Technologies & Frameworks
• Node.js and TypeScript (evident through tsconfig.json, tsup.config.ts, and source file extensions).
• Express (to serve the report on a local web server) as shown in the CLI commands and expressServer.ts.
• Handlebars (in dist/views) for templating.
• Playwright integration (as indicated by sample configuration and the README) for test data input.
Essential Elements
• Clear labels for each component (CLI, Helpers, Utils, Views, Deployment/Server).
• Annotation of relationships, such as “Calls”, “Processes”, or “Serves” between components.