UNPKG

html-reporter

Version:

Html-reporter and GUI for viewing and managing results of a tests run. Currently supports Testplane and Hermione.

126 lines 4.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SqliteTestResultAdapter = void 0; const lodash_1 = __importDefault(require("lodash")); const constants_1 = require("../../constants"); const common_utils_1 = require("../../common-utils"); const tryParseJson = (json) => { try { return JSON.parse(json); } catch { return undefined; } }; class SqliteTestResultAdapter { constructor(testResult, attempt) { this._testResult = testResult; this._parsedTestResult = { attempt }; } get assertViewResults() { // TODO: try to restore assertViewResults from imagesInfo return []; } get attempt() { return this._parsedTestResult.attempt; } get browserId() { return this._testResult[constants_1.DB_COLUMN_INDEXES.name]; } get description() { return this._testResult[constants_1.DB_COLUMN_INDEXES.description] ?? undefined; } get error() { if (!lodash_1.default.has(this._parsedTestResult, 'error')) { this._parsedTestResult.error = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.error]); } return this._parsedTestResult.error; } get errorDetails() { // TODO: implement returning error details return null; } get file() { if (!lodash_1.default.has(this._parsedTestResult, 'meta')) { this._parsedTestResult.meta = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.metaInfo]); } return this._parsedTestResult.meta?.file; } get fullName() { if (!lodash_1.default.has(this._parsedTestResult, 'fullName')) { this._parsedTestResult.fullName = this.testPath.join(constants_1.DEFAULT_TITLE_DELIMITER); } return this._parsedTestResult.fullName; } get history() { if (!lodash_1.default.has(this._parsedTestResult, 'history')) { this._parsedTestResult.history = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.history]); } return this._parsedTestResult.history; } get id() { return this.testPath.concat(this.browserId, this.attempt.toString()).join(' '); } get imageDir() { return (0, common_utils_1.getTestHash)(this); } get imagesInfo() { if (!lodash_1.default.has(this._parsedTestResult, 'imagesInfo')) { this._parsedTestResult.imagesInfo = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.imagesInfo]); } return this._parsedTestResult.imagesInfo; } get meta() { if (!lodash_1.default.has(this._parsedTestResult, 'meta')) { this._parsedTestResult.meta = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.metaInfo]) ?? {}; } return this._parsedTestResult.meta; } get multipleTabs() { return Boolean(this._testResult[constants_1.DB_COLUMN_INDEXES.multipleTabs]); } get screenshot() { return this.error?.screenshot; } get sessionId() { if (!lodash_1.default.has(this._parsedTestResult, 'meta')) { this._parsedTestResult.meta = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.metaInfo]); } return this._parsedTestResult.meta?.sessionId; } get skipReason() { return this._testResult[constants_1.DB_COLUMN_INDEXES.skipReason]; } get state() { return { name: this.testPath.at(-1) }; } get status() { return this._testResult[constants_1.DB_COLUMN_INDEXES.status]; } get testPath() { if (!lodash_1.default.has(this._parsedTestResult, 'testPath')) { this._parsedTestResult.testPath = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.suitePath]); } return this._parsedTestResult.testPath; } get timestamp() { return Number(this._testResult[constants_1.DB_COLUMN_INDEXES.timestamp]); } get url() { return this._testResult[constants_1.DB_COLUMN_INDEXES.suiteUrl]; } get duration() { return this._testResult[constants_1.DB_COLUMN_INDEXES.duration]; } get attachments() { if (!lodash_1.default.has(this._parsedTestResult, 'attachments')) { this._parsedTestResult.attachments = tryParseJson(this._testResult[constants_1.DB_COLUMN_INDEXES.attachments]); } return this._parsedTestResult.attachments; } } exports.SqliteTestResultAdapter = SqliteTestResultAdapter; //# sourceMappingURL=sqlite.js.map