/** @odoo-module */ import { Component, useState, xml } from "@odoo/owl"; import { Tag } from "../core/tag"; import { Test } from "../core/test"; import { subscribeToURLParams } from "../core/url"; import { formatHumanReadable, formatTime, getTypeOf, ordinal } from "../hoot_utils"; import { HootLink } from "./hoot_link"; import { HootTechnicalValue } from "./hoot_technical_value"; /** * @typedef {{ * open: boolean; * slots: any; * test: Test; * }} TestResultProps */ /** @extends {Component} */ export class HootTestResult extends Component { static components = { HootLink, HootTechnicalValue }; static props = { open: Boolean, slots: { type: Object, shape: { default: Object, }, }, test: Test, }; static template = xml`
run:
[ ]
Error while running test ""
Source:
                                
Cause:
                                    
`; Tag = Tag; formatHumanReadable = formatHumanReadable; formatTime = formatTime; getTypeOf = getTypeOf; ordinal = ordinal; setup() { subscribeToURLParams("*"); this.logs = useState(this.props.test.logs); this.results = useState(this.props.test.results); this.state = useState({ showCode: false, showDetails: this.props.open, }); } getClassName() { if (this.logs.error) { return "bg-fail-900"; } switch (this.props.test.status) { case Test.ABORTED: { return "bg-abort-900"; } case Test.FAILED: { if (this.props.test.config.todo) { return "bg-todo-900"; } else { return "bg-fail-900"; } } case Test.PASSED: { if (this.logs.warn) { return "bg-abort-900"; } else if (this.props.test.config.todo) { return "bg-todo-900"; } else { return "bg-pass-900"; } } default: { return "bg-skip-900"; } } } toggleCode() { this.state.showCode = !this.state.showCode; } toggleDetails() { this.state.showDetails = !this.state.showDetails; } }