/** @odoo-module */ import { Component, useState, xml } from "@odoo/owl"; import { Test } from "../core/test"; import { HootCopyButton } from "./hoot_copy_button"; import { HootLink } from "./hoot_link"; import { HootTagButton } from "./hoot_tag_button"; /** * @typedef {{ * canCopy?: boolean; * full?: boolean; * inert?: boolean; * showStatus?: boolean; * test: Test; * }} HootTestPathProps */ /** @extends {Component} */ export class HootTestPath extends Component { static components = { HootCopyButton, HootLink, HootTagButton }; static props = { canCopy: { type: Boolean, optional: true }, full: { type: Boolean, optional: true }, inert: { type: Boolean, optional: true }, showStatus: { type: Boolean, optional: true }, test: Test, }; static template = xml`
x
`; setup() { this.uiState = useState(this.env.ui); } getStatusInfo() { switch (this.props.test.status) { case Test.ABORTED: { return { className: "abort", text: "aborted" }; } case Test.FAILED: { if (this.props.test.config.todo) { return { className: "todo", text: "todo" }; } else { return { className: "fail", text: "failed" }; } } case Test.PASSED: { if (this.props.test.config.todo) { return { className: "todo", text: "todo" }; } else { return { className: "pass", text: "passed" }; } } default: { return { className: "skip", text: "skipped" }; } } } /** * @param {import("../core/suite").Suite} suite */ getSuiteInfo(suite) { let suites = 0; let tests = 0; let assertions = 0; for (const job of suite.jobs) { if (job instanceof Test) { tests++; assertions += job.lastResults?.assertions.length || 0; } else { suites++; } } return { id: suite.id, name: suite.name, parent: suite.parent?.name || null, suites, tests, assertions, }; } getTestPath() { const { selectedSuiteId } = this.uiState; const { test } = this.props; const path = test.path.slice(0, -1); if (this.props.full || !selectedSuiteId) { return path; } const index = path.findIndex((suite) => suite.id === selectedSuiteId) + 1; return path.slice(index); } }