"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DbTestResultTransformer = void 0;
const common_utils_1 = require("../../common-utils");
const lodash_1 = __importDefault(require("lodash"));
class DbTestResultTransformer {
    constructor(options) {
        this._options = options;
    }
    transform(testResult) {
        const suiteUrl = (0, common_utils_1.getUrlWithBase)(testResult.url, this._options.baseHost);
        const metaInfoFull = lodash_1.default.merge(lodash_1.default.cloneDeep(testResult.meta), {
            url: (0, common_utils_1.getRelativeUrl)(suiteUrl) ?? '',
            file: testResult.file,
            sessionId: testResult.sessionId
        });
        const metaInfo = lodash_1.default.omitBy(metaInfoFull, lodash_1.default.isEmpty);
        return {
            suitePath: testResult.testPath,
            suiteName: lodash_1.default.last(testResult.testPath),
            name: testResult.browserId,
            suiteUrl,
            metaInfo,
            history: testResult.history,
            description: testResult.description,
            error: (0, common_utils_1.getError)(testResult.error),
            skipReason: testResult.skipReason,
            imagesInfo: testResult.imagesInfo ?? [],
            screenshot: Boolean(testResult.screenshot),
            multipleTabs: testResult.multipleTabs,
            status: testResult.status,
            timestamp: testResult.timestamp ?? Date.now()
        };
    }
}
exports.DbTestResultTransformer = DbTestResultTransformer;
//# sourceMappingURL=db.js.map