The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
import Color from "color";
const { H } = cy;
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
const BIG_NUMBER_AGGREGATION = [
"aggregation-options",
["*", ["count"], 10000],
{ name: "Mega Count", "display-name": "Mega Count" },
];
const AGGREGATIONS = [
["count"],
["sum", ["field", ORDERS.TOTAL, null]],
BIG_NUMBER_AGGREGATION,
];
describe("scenarios > visualizations > trend chart (SmartScalar)", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
});
it("should allow data settings to be changed and display should reflect changes", () => {
H.createQuestion(
{
name: "13710",
query: {
"source-table": ORDERS_ID,
aggregation: AGGREGATIONS,
breakout: [
["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
],
},
display: "smartscalar",
},
{ visitQuestion: true },
);
H.openVizSettingsSidebar();
cy.findByTestId("chartsettings-sidebar").findByText("Data").click();
// primary number
cy.findByTestId("scalar-container").findByText("344");
cy.findByTestId("chartsettings-sidebar")
.findByDisplayValue("Count")
.click();
H.popover().within(() => {
cy.findAllByRole("option").should("have.length", AGGREGATIONS.length);
// selected should be highlighted
cy.findByRole("option", { name: "Count" }).should(
"have.attr",
"aria-selected",
"true",
);
// unselected item should not be highlighted
cy.findByRole("option", { name: "Sum of Total" })
.should("have.attr", "aria-selected", "false")
.click();
});
// comparisons
// default should be previous period (since we have a dateUnit);
// a single comparison renders as one inline row with the full value
cy.findByTestId("scalar-container").findByText("30,759.47");
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("-32.67% MoM");
cy.findByText("(45,683.68)");
});
// previous value
cy.findByTestId("chartsettings-sidebar")
.findByText("Previous month")
.click();
H.menu().findByText("Previous value").click();
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("-32.67% vs. Mar");
cy.findByText("(45,683.68)");
});
// periods ago
cy.findByTestId("chartsettings-sidebar")
.findByText("Previous value")
.click();
H.menu().within(() => {
// should clamp over input to maxPeriodsAgo
cy.get("input").click().type("100");
cy.get("input").should("have.value", 48);
// should clamp under input to 2
cy.get("input").click().type("0");
cy.get("input").should("have.value", 2);
// should not allow decimal input (ignores dot input)
cy.get("input").click().type("1.2");
cy.get("input").should("have.value", 12);
// should allow valid input
cy.get("input").click().type("3{enter}");
});
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("-41.13% vs. Jan");
cy.findByText("(52,249.59)");
});
// static number
cy.findByTestId("chartsettings-sidebar").findByText("3 months ago").click();
H.menu().within(() => {
cy.findByText("Custom value…").click();
// Test the back button
cy.findByLabelText("Back").click();
cy.findByText("Custom value…").click();
cy.findByLabelText("Label").type("My Goal");
cy.findByLabelText("Value").type("{selectall}42000");
cy.button("Done").click();
});
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("-26.76% vs. My Goal").should("exist"); // down percentage
cy.findByText("(42,000)").should("exist"); // goal
});
cy.findByTestId("chartsettings-sidebar").findByText("(My Goal)").click();
H.menu().within(() => {
cy.findByLabelText("Back").should("exist");
cy.findByLabelText("Label").should("have.value", "My Goal");
cy.findByLabelText("Value").should("have.value", "42000");
cy.button("Back").click();
});
// another column
H.menu().findByText("Value from another column…").click();
H.selectDropdown().findByText("Mega Count").click();
H.menu().button("Done").click();
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("-99.11% vs. Mega Count").should("exist"); // down percentage
cy.findByText("(3,440,000)").should("exist"); // goal
});
cy.findByTestId("chartsettings-sidebar").findByText("(Mega Count)").click();
H.menu().findByRole("textbox", { name: "Column" }).click();
H.popover().findByText("Count").click();
H.menu().button("Done").click();
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("+8,841.71% vs. Count").should("exist"); // up percentage
cy.findByText("(344)").should("exist"); // goal
});
});
it("should handle up to 3 comparisons", () => {
H.createQuestion(
{
query: {
"source-table": ORDERS_ID,
aggregation: AGGREGATIONS,
breakout: [
["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
],
},
display: "smartscalar",
},
{ visitQuestion: true },
);
H.openVizSettingsSidebar();
cy.findByTestId("comparison-list").children().should("have.length", 1);
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("-34.72% MoM").should("exist");
cy.findByText("(527)").should("exist");
});
cy.button("Add comparison").click();
cy.findByTestId("comparison-list").children().should("have.length", 2);
H.menu().findByText("months ago").click();
cy.findAllByTestId("scalar-previous-value").should("have.length", 2);
cy.findByTestId("scalar-comparison-list").within(() => {
cy.findByText("vs. Feb").should("exist");
cy.findByText("-36.65% (543)").should("exist");
});
cy.button("Add comparison").click();
cy.findByTestId("comparison-list").children().should("have.length", 3);
H.menu().findByText("Previous value").click();
cy.findAllByTestId("scalar-previous-value").should("have.length", 3);
cy.findByTestId("scalar-comparison-list").within(() => {
cy.findByText("vs. Mar").should("exist");
cy.findAllByText("-34.72% (527)").should("have.length", 2);
});
cy.button("Add comparison").should("be.disabled");
// eslint-disable-next-line metabase/no-unsafe-element-filtering
cy.findByTestId("comparison-list")
.children()
.last()
.findByLabelText("Remove")
.click();
cy.findByTestId("comparison-list").children().should("have.length", 2);
cy.findByTestId("comparison-list")
.findByText("Previous value")
.should("not.exist");
cy.findAllByTestId("scalar-previous-value").should("have.length", 2);
cy.findByTestId("scalar-comparison-list")
.findByText("vs. Mar")
.should("not.exist");
cy.button("Add comparison").should("be.enabled");
});
it("should allow selecting more than 1 comparison (metabase#50686)", () => {
const questionDetails = {
name: "50686",
display: "smartscalar",
native: {
query:
"select 100 as total, 110 as forecast, 80 as last_year, now() as now",
},
};
H.createNativeQuestion(questionDetails, { visitQuestion: true });
// Default comparison (a single one renders inline)
H.queryBuilderMain().findByText("(No data)");
// Add another comparison
H.openVizSettingsSidebar();
cy.button("Add comparison").click();
H.popover().findByText("Value from another column…").click();
H.popover().findByText("FORECAST").click();
H.popover().button("Done").click();
H.queryBuilderMain().within(() => {
// First comparison still exists
cy.findByText("N/A (No data)");
// New comparison has been added
cy.findByText("-9.09% (110)");
cy.contains("vs. FORECAST");
});
});
it("should reset 'another column' comparison when it becomes invalid", () => {
cy.intercept("POST", "/api/dataset").as("dataset");
H.createQuestion(
{
query: {
"source-table": ORDERS_ID,
aggregation: AGGREGATIONS,
breakout: [
["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
],
},
display: "smartscalar",
visualization_settings: {
"scalar.field": "Count",
"scalar.comparisons": [
{
id: "1",
type: "anotherColumn",
column: "Mega Count",
label: "Mega Count",
},
{
id: "2",
type: "staticNumber",
value: 400000,
label: "Goal",
},
],
},
},
{ visitQuestion: true },
);
H.openVizSettingsSidebar();
// Selecting the main column ("Mega Count") to be the comparison column
// The "Another column (Mega Count)" comparison should disappear
cy.findByTestId("chartsettings-sidebar").within(() => {
cy.findByText("(Mega Count)").should("exist");
cy.findByDisplayValue("Count").click();
});
H.popover().findByText("Mega Count").click();
cy.findByTestId("scalar-value").should("have.text", "3,440,000");
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("Sum of Total").should("not.exist");
cy.findByText("+760% vs. Goal").should("exist");
cy.findByText("(400,000)").should("exist");
});
// Replacing "Custom value (Goal)" with "Another column (Count)"
// Setting the main column to "Count"
// The single invalid comparison should be reset to "previous period"
cy.findByTestId("chartsettings-sidebar")
.findByText(/Custom value/)
.click();
H.menu().button("Back").click();
H.menu().findByText("Value from another column…").click();
H.popover().findByText("Count").click();
H.popover().button("Done").click();
cy.findByTestId("chartsettings-field-picker")
.findByRole("textbox")
.should("have.value", "Mega Count")
.click();
H.popover().findByText("Count").click();
cy.findByTestId("scalar-value").should("have.text", "344");
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("Count").should("not.exist");
cy.findByText("-34.72% MoM").should("exist");
cy.findByText("(527)").should("exist");
});
cy.findByTestId("chartsettings-sidebar")
.findByText("Previous month")
.click();
H.menu().findByText("Value from another column…").click();
H.popover().findByText("Sum of Total").click();
H.popover().button("Done").click();
cy.findByTestId("chartsettings-sidebar")
.findByDisplayValue("Count")
.click();
H.popover().findByText("Mega Count").click();
// Removing the comparison column ("Sum of Total") from the query
// The comparison should be reset to "previous period"
H.summarize();
H.rightSidebar().findByLabelText("Sum of Total").icon("close").click();
cy.wait("@dataset");
cy.findByTestId("scalar-value").should("have.text", "3,440,000");
cy.findByTestId("scalar-previous-value").within(() => {
cy.findByText("Sum of Total").should("not.exist");
cy.findByText("-34.72% MoM").should("exist");
cy.findByText("(5,270,000)").should("exist");
});
// Removing the remaining numeric column, so only Count is left
// to ensure we no longer offer the "Value from another column…" option
H.rightSidebar().within(() => {
cy.findByLabelText("Count").icon("close").click();
cy.button("Done").click();
});
cy.wait("@dataset");
H.openVizSettingsSidebar();
cy.findByTestId("chartsettings-sidebar").within(() => {
cy.findByText("Sum of Total").should("not.exist");
cy.findByText("Previous month").should("exist").click();
});
H.menu().findByText("Previous value").should("be.visible");
H.menu().findByText("Value from another column…").should("not.exist");
});
it("should allow display settings to be changed and display should reflect changes", () => {
H.createQuestion(
{
name: "13710",
query: {
"source-table": ORDERS_ID,
aggregation: AGGREGATIONS,
breakout: [
["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
],
},
display: "smartscalar",
},
{ visitQuestion: true },
);
// scalar.switch_positive_negative setting changes the comparison sentiment color
const assertComparisonColor = (cssVariable) => {
cy.document().then((doc) => {
const expectedColor = Color(
getComputedStyle(doc.documentElement)
.getPropertyValue(cssVariable)
.trim(),
)
.rgb()
.string();
cy.findByTestId("scalar-previous-value")
.findByText("-34.72% MoM")
.should("have.css", "color", expectedColor);
});
};
assertComparisonColor("--mb-color-feedback-negative-strong");
H.openVizSettingsSidebar();
cy.findByTestId("chartsettings-sidebar").within(() => {
cy.findByText("Display").click();
cy.findByLabelText("Switch positive / negative colors?").click({
force: true,
});
});
assertComparisonColor("--mb-color-feedback-positive-strong");
// open the metric column's formatting (now in a popover, since the date
// column is also configurable)
H.leftSidebar().findByTestId("Count-settings-button").click();
// style
cy.findByTestId("scalar-container").findByText("344");
cy.findByLabelText("Style").click();
H.popover().findByText("Percent").click();
cy.findByTestId("scalar-container").findByText("34,400%");
// separator style
cy.findByLabelText("Separator style").click();
H.popover().findByText("100’000.00").click();
cy.findByTestId("scalar-container").findByText("34’400%");
// decimal places
cy.findByLabelText("Number of decimal places").click().type("4").blur();
cy.findByTestId("scalar-container").findByText("34’400.0000%");
// negative decimal places flip to positive
cy.findByLabelText("Number of decimal places")
.click()
.clear()
.type("-3")
.blur();
cy.findByTestId("scalar-container").findByText("34’400.000%");
// non-integer decimal places round to nearest integer
cy.findByLabelText("Number of decimal places")
.click()
.clear()
.type("2.4")
.blur();
cy.findByTestId("scalar-container").findByText("34’400.00%");
// negative non-integer decimal places round to nearest integer and flip to positive
cy.findByLabelText("Number of decimal places")
.click()
.clear()
.type("-3.8")
.blur();
cy.findByTestId("scalar-container").findByText("34’400.0000%");
// multiply by a number
cy.findByLabelText("Multiply by a number").click().type("2").blur();
cy.findByTestId("scalar-container").findByText("68’800.0000%");
// add a prefix
// a long value auto-compacts to fit the card, so match the affixes only
cy.findByLabelText("Add a prefix").click().type("Woah: ").blur();
cy.findByTestId("scalar-container").should("contain", "Woah: ");
// add a suffix
cy.findByLabelText("Add a suffix").click().type(" ! cool").blur();
cy.findByTestId("scalar-container")
.should("contain", "Woah: ")
.and("contain", " ! cool");
// scalar.compact_primary_number setting
cy.findByTestId("chartsettings-sidebar").within(() => {
cy.findByText("Data").click();
cy.findByDisplayValue("Count").click();
});
H.popover().findByRole("option", { name: "Mega Count" }).click();
cy.findByTestId("chartsettings-sidebar").findByText("Display").click();
// the single inline comparison always shows the full value; the setting
// only affects the primary number
cy.findByTestId("scalar-container").findByText("3,440,000");
cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");
cy.findByTestId("chartsettings-sidebar")
.findByLabelText("Compact number")
.click({ force: true });
cy.findByTestId("scalar-container").findByText("3.4M");
cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");
cy.findByTestId("chartsettings-sidebar")
.findByLabelText("Compact number")
.click({ force: true });
cy.findByTestId("scalar-container").findByText("3,440,000");
cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");
cy.log("scalar.show_comparison_value setting");
cy.findByTestId("chartsettings-sidebar")
.findByLabelText("Show comparison value")
.should("be.checked")
.click({ force: true });
cy.findByTestId("scalar-previous-value")
.should("contain", "-34.72% MoM")
.and("not.contain", "5,270,000");
cy.findByTestId("chartsettings-sidebar")
.findByLabelText("Show comparison value")
.should("not.be.checked")
.click({ force: true });
cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");
});
it("should work regardless of column order (metabase#13710)", () => {
H.createQuestion(
{
name: "13710",
query: {
"source-table": ORDERS_ID,
breakout: [
["field", ORDERS.QUANTITY, null],
["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
],
},
display: "smartscalar",
},
{ visitQuestion: true },
);
cy.log("Reported failing on v0.35 - v0.37.0.2");
cy.log("Bug: showing blank visualization");
cy.findByTestId("scalar-value").contains("100");
});
it("should gracefully handle errors (metabase#42948)", () => {
H.createNativeQuestion(
{
name: "42948",
native: {
query:
"SELECT DATE '2024-05-21' AS created_at, 5 as v\nUNION ALL SELECT DATE '2024-05-20' , 4\nUNION ALL SELECT DATE '2024-05-19' , 3\nORDER BY created_at",
},
display: "smartscalar",
visualization_settings: {
"scalar.field": "v",
"scalar.comparisons": [
{
id: "1",
type: "periodsAgo",
value: "this will cause an error because it is not a number",
},
],
},
},
{ visitQuestion: true },
);
// check that error/warning is showing up
cy.icon("warning").realHover();
H.queryBuilderMain().findByText(
"No integer value supplied for periods ago comparison.",
);
// check that we can switch to the table view and the data is shown
cy.findByLabelText("Switch to data").click();
H.queryBuilderMain().within(() => {
cy.findByText("CREATED_AT").should("be.visible");
cy.findByText("V").should("be.visible");
});
// check that we can switch visualizations and no longer have the error show
H.openVizTypeSidebar();
cy.findByTestId("Line-button").click();
H.cartesianChartCircle().should("have.length", 3);
cy.icon("warning").should("not.exist");
});
it("should keep full date granularity for native questions and let users pick a coarser granularity (metabase#69525)", () => {
H.createNativeQuestion(
{
name: "69525",
native: {
query:
"SELECT CAST('2023-06-30 12:00:00' AS TIMESTAMP) AS parsed_date, 733.93 AS amount\nUNION ALL SELECT CAST('2024-06-30 12:00:00' AS TIMESTAMP), 794.29",
},
display: "smartscalar",
},
{ visitQuestion: true },
);
cy.log("the full date is shown by default, not collapsed to the year");
cy.findByTestId("scalar-period")
.findByText("June 30, 2024, 12:00 PM")
.should("be.visible");
H.openVizSettingsSidebar();
cy.findByTestId("chartsettings-sidebar").findByText("Display").click();
H.leftSidebar().findByTestId("PARSED_DATE-settings-button").click();
cy.log("the date format controls are available for the full date");
H.popover().within(() => {
cy.findByText("Date granularity").should("be.visible");
cy.findByText("Date style").should("be.visible");
cy.findByText("Show the time").should("be.visible");
});
cy.log(
"a coarser granularity collapses the date and hides format controls",
);
H.popover().findByDisplayValue("Full date").click();
H.popover().findByRole("option", { name: "Year" }).click();
cy.findByTestId("scalar-period").findByText("2024").should("be.visible");
H.popover().within(() => {
cy.findByText("Date granularity").should("be.visible");
cy.findByText("Date style").should("not.exist");
cy.findByText("Show the time").should("not.exist");
});
cy.log("quarter and month granularities keep the relevant period");
H.popover().findByDisplayValue("Year").click();
H.popover().findByRole("option", { name: "Quarter and year" }).click();
cy.findByTestId("scalar-period").findByText("Q2 2024").should("be.visible");
H.popover().findByDisplayValue("Quarter and year").click();
H.popover().findByRole("option", { name: "Month and year" }).click();
cy.findByTestId("scalar-period")
.findByText("June 2024")
.should("be.visible");
cy.log("switching back to the full date restores everything");
H.popover().findByDisplayValue("Month and year").click();
H.popover().findByRole("option", { name: "Full date" }).click();
cy.findByTestId("scalar-period")
.findByText("June 30, 2024, 12:00 PM")
.should("be.visible");
H.popover().within(() => {
cy.findByText("Date style").should("be.visible");
cy.findByText("Show the time").should("be.visible");
});
});
it("should support quick-filter drill thru (metabase#46168)", () => {
H.createQuestion(
{
name: "46168",
query: {
"source-table": ORDERS_ID,
aggregation: AGGREGATIONS,
breakout: [
["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
],
},
display: "smartscalar",
},
{ visitQuestion: true },
);
cy.findByTestId("scalar-period")
.findByText("Apr 2029")
.should("be.visible");
cy.findByTestId("scalar-container").findByText("344").click();
H.popover().within(() => {
// Validate expected filter options
cy.findByText("Filter by this value").should("be.visible");
cy.findByText(">").should("be.visible");
cy.findByText("<").should("be.visible");
cy.findByText("=").should("be.visible");
cy.findByText("≠").should("be.visible");
// Apply the drill
cy.findByText(">").click();
});
// Validate that the filter was applied
cy.findByTestId("scalar-period")
.findByText("Mar 2029")
.should("be.visible");
cy.findByTestId("scalar-container").findByText("527").should("be.visible");
});
});
describe("scenarios > visualizations > trend chart on dashboards and public questions", () => {
const TREND_QUERY = {
"source-table": ORDERS_ID,
aggregation: [["count"]],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
};
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
});
it("should navigate to the question by clicking the dashcard title", () => {
H.createQuestionAndDashboard({
questionDetails: {
name: "Trend title nav",
query: TREND_QUERY,
display: "smartscalar",
},
cardDetails: { size_x: 8, size_y: 4 },
}).then(({ body: { dashboard_id } }) => {
H.visitDashboard(dashboard_id);
});
// a real pointer press: regressions here (e.g. the link re-rendering
// mid-press) do not reproduce with synthetic clicks
cy.findByTestId("scalar-title").findByText("Trend title nav").realClick();
cy.location("pathname").should("match", /^\/question\//);
H.queryBuilderHeader()
.findByDisplayValue("Trend title nav")
.should("be.visible");
});
it("should list every comparison on a dashcard tall enough for them (metabase#84105)", () => {
const questionDetails = {
name: "Trend with three comparisons",
query: TREND_QUERY,
display: "smartscalar",
visualization_settings: {
"scalar.comparisons": [
{ id: "1", type: "previousPeriod" },
{ id: "2", type: "periodsAgo", value: 2 },
{ id: "3", type: "periodsAgo", value: 3 },
],
},
};
H.createQuestionAndDashboard({
questionDetails,
cardDetails: { size_x: 12, size_y: 8 },
}).then(({ body: { dashboard_id, card_id } }) => {
H.updateDashboardCards({
dashboard_id,
cards: [
{ card_id, row: 0, col: 0, size_x: 12, size_y: 8 },
{ card_id, row: 8, col: 0, size_x: 12, size_y: 3 },
],
});
H.visitDashboard(dashboard_id);
});
cy.log("the tall card lists every comparison");
H.getDashboardCard(0).within(() => {
cy.findByTestId("scalar-comparison-list")
.findAllByTestId("scalar-previous-value")
.should("have.length", 3)
.each(($line) => {
cy.wrap($line).should("be.visible");
});
cy.findByText("+2").should("not.exist");
});
cy.log("the short card keeps the first comparison and a badge");
H.getDashboardCard(1).within(() => {
cy.findByTestId("scalar-comparison-list").should("not.exist");
cy.findByTestId("scalar-previous-value").should("be.visible");
cy.findByText("+2").should("be.visible");
});
});
it("should open the description tooltip and comparison panel with keyboard navigation", () => {
H.createQuestionAndDashboard({
questionDetails: {
name: "Trend keyboard",
description: "Trend keyboard description",
query: TREND_QUERY,
display: "smartscalar",
visualization_settings: {
"scalar.comparisons": [
{ id: "1", type: "previousPeriod" },
{ id: "2", type: "periodsAgo", value: 2 },
],
},
},
cardDetails: { size_x: 8, size_y: 4 },
}).then(({ body: { dashboard_id } }) => {
H.visitDashboard(dashboard_id);
});
// the hover-hidden description icon is the next tab stop after the
// title link; focusing it reveals it and opens its tooltip
cy.findByTestId("scalar-title").findByTestId("legend-label").focus();
cy.realPress("Tab");
cy.focused().should("have.css", "opacity", "1");
cy.findByRole("tooltip")
.findByText("Trend keyboard description")
.should("be.visible");
// the comparison row is the tab stop after the icon
cy.realPress("Tab");
cy.findByTestId("scalar-previous-value").should("have.focus");
cy.findByRole("tooltip")
.findByText("vs. previous month")
.should("be.visible");
// moving keyboard focus back to the title link shows a visible ring
cy.realPress(["Shift", "Tab"]);
cy.realPress(["Shift", "Tab"]);
cy.findByTestId("scalar-title")
.findByTestId("legend-label")
.should("have.focus")
.then(($link) => {
const styles = getComputedStyle($link[0]);
const brandColor = getComputedStyle(
$link[0].ownerDocument.documentElement,
)
.getPropertyValue("--mb-color-core-brand")
.trim();
expect(styles.outlineStyle).to.equal("solid");
expect(parseFloat(styles.outlineWidth)).to.be.greaterThan(0);
expect(Color(styles.outlineColor).hex()).to.equal(
Color(brandColor).hex(),
);
});
});
it("should show the full comparison list in public question views", () => {
H.createQuestion({
name: "Public trend",
query: TREND_QUERY,
display: "smartscalar",
visualization_settings: {
"scalar.comparisons": [
{ id: "1", type: "previousPeriod" },
{ id: "2", type: "periodsAgo", value: 2 },
{ id: "3", type: "staticNumber", value: 500, label: "Goal" },
],
},
}).then(({ body: { id } }) => {
H.visitPublicQuestion(id);
});
// the standalone question view lists every comparison instead of the
// dashboard-style compact row with a "+N" badge
cy.findByTestId("scalar-comparison-list")
.children()
.should("have.length", 3);
cy.findByTestId("scalar-period").should("have.text", "Apr 2029");
cy.findByTestId("scalar-content").findByText("+2").should("not.exist");
});
});