Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Use collection in breadcrumbs for nested questions (#67154)

Romeo Van Snick269891d61c2c
diff --git a/e2e/support/helpers/e2e-bi-basics-helpers.js b/e2e/support/helpers/e2e-bi-basics-helpers.js
index ca42a95b78a..30aad0a156c 100644
--- a/e2e/support/helpers/e2e-bi-basics-helpers.js
+++ b/e2e/support/helpers/e2e-bi-basics-helpers.js
@@ -79,21 +79,7 @@ export function assertQueryBuilderRowCount(count) {
* @param {string} lhsSampleColumn join's LHS sample column name
* @param {string} rhsSampleColumn join's RHS sample column name
*/
-export function assertJoinValid({
- lhsTable,
- rhsTable,
- lhsSampleColumn,
- rhsSampleColumn,
-}) {
- // Ensure the QB shows `${lhsTable} + ${rhsTable}` in the header
- // The check is optional for cases when a table name isn't clear (e.g. a multi-stage ad-hoc question)
- if (lhsTable && rhsTable) {
- cy.findByTestId("question-table-badges").within(() => {
- cy.findByText(lhsTable).should("be.visible");
- cy.findByText(rhsTable).should("be.visible");
- });
- }
-
+export function assertJoinValid({ lhsSampleColumn, rhsSampleColumn }) {
// Ensure the results have columns from both tables
queryBuilderMain().within(() => {
tableHeaderColumn(lhsSampleColumn).should("be.visible");
diff --git a/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js b/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js
index 77a01bba532..15d97e8c6a5 100644
--- a/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js
@@ -91,10 +91,8 @@ describe("issue 12928", () => {
H.visualize();
- cy.get("@joinedQuestionId").then((joinedQuestionId) => {
+ cy.get("@joinedQuestionId").then(() => {
H.assertJoinValid({
- lhsTable: SOURCE_QUESTION_NAME,
- rhsTable: JOINED_QUESTION_NAME,
lhsSampleColumn: "Products → Category",
rhsSampleColumn: `${JOINED_QUESTION_NAME} - Products → Category → Category`,
});
diff --git a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
index d6f2ccf7af8..c283252bea6 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
@@ -1414,3 +1414,35 @@ describe("issue 13347", () => {
});
});
});
+
+describe("issue #47005", () => {
+ beforeEach(() => {
+ H.restore();
+ H.restore("postgres-12");
+ cy.signInAsNormalUser();
+
+ H.createQuestion({
+ name: "Question A",
+ query: {
+ "source-table": ORDERS_ID,
+ },
+ }).then(({ body: question }) => {
+ H.createQuestion(
+ {
+ name: "Question B",
+ query: {
+ "source-table": "card__" + question.id,
+ },
+ },
+ { visitQuestion: true },
+ );
+ });
+ });
+
+ it("should show the collection of the base question in breadcrumbs (metabase#47005)", () => {
+ cy.findAllByTestId("head-crumbs-container")
+ .filter(":contains(Question A)")
+ .findByText("Our analytics")
+ .should("be.visible");
+ });
+});
diff --git a/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/SourceQuestionBreadcrumbs.tsx b/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/SourceQuestionBreadcrumbs.tsx
index fb204a46913..c593a04a9a9 100644
--- a/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/SourceQuestionBreadcrumbs.tsx
+++ b/frontend/src/metabase/query_builder/components/view/ViewHeader/components/QuestionDataSource/SourceQuestionBreadcrumbs.tsx
@@ -7,7 +7,6 @@ import * as Lib from "metabase-lib";
import Question from "metabase-lib/v1/Question";
import { getQuestionIdFromVirtualTableId } from "metabase-lib/v1/metadata/utils/saved-questions";
-import { DataSourceCrumbs } from "./DataSourceCrumbs";
import { SourceModelBreadcrumbs } from "./SourceModelBreadcrumbs";
interface Props {
@@ -37,15 +36,11 @@ export function SourceQuestionBreadcrumbs({
return null;
}
- if (sourceQuestion.type() === "model" || sourceQuestion.type() === "metric") {
- return (
- <SourceModelBreadcrumbs
- question={sourceQuestion}
- variant={variant}
- {...props}
- />
- );
- }
-
- return <DataSourceCrumbs question={question} variant={variant} {...props} />;
+ return (
+ <SourceModelBreadcrumbs
+ question={sourceQuestion}
+ variant={variant}
+ {...props}
+ />
+ );
}