Skip to content
Snippets Groups Projects
Unverified Commit 5317db6d authored by Phoomparin Mano's avatar Phoomparin Mano Committed by GitHub
Browse files

fix(sdk): summarize sdk component crashes with stage index errors (#50400)


* use -1 for stage index for breakout and aggregation list

* add e2e tests

* remove sum of total in e2e

* use test id matcher

* add issue to e2e name

Co-authored-by: default avatarKamil Mielnik <kamil@kamilmielnik.com>

* move stageIndex to a separate variable

---------

Co-authored-by: default avatarKamil Mielnik <kamil@kamilmielnik.com>
parent b378247c
No related branches found
No related tags found
No related merge requests found
...@@ -173,4 +173,24 @@ describeSDK("scenarios > embedding-sdk > interactive-question", () => { ...@@ -173,4 +173,24 @@ describeSDK("scenarios > embedding-sdk > interactive-question", () => {
getSdkRoot().contains("onBeforeSave is called"); getSdkRoot().contains("onBeforeSave is called");
getSdkRoot().contains("question saved as Sample Orders 4"); getSdkRoot().contains("question saved as Sample Orders 4");
}); });
it("should not crash when clicking on Summarize (metabase#50398)", () => {
visitInteractiveQuestionStory();
cy.wait("@cardQuery").then(({ response }) => {
expect(response?.statusCode).to.equal(202);
});
getSdkRoot().within(() => {
// Open the default summarization view in the sdk
cy.findByText("Summarize").click();
// Expect the default summarization view to be there.
cy.findByTestId("summarize-aggregation-item-list").should("be.visible");
});
cy.on("uncaught:exception", error => {
expect(error.message.includes("Stage 1 does not exist")).to.be.false;
});
});
}); });
...@@ -38,9 +38,6 @@ const SummarizeInner = ({ ...@@ -38,9 +38,6 @@ const SummarizeInner = ({
const [currentQuery, setCurrentQuery] = useState<Lib.Query>(question.query()); const [currentQuery, setCurrentQuery] = useState<Lib.Query>(question.query());
// yeah we need to change this
const stageIndex = Lib.stageCount(currentQuery);
const onApplyFilter = () => { const onApplyFilter = () => {
if (currentQuery) { if (currentQuery) {
onQueryChange(currentQuery); onQueryChange(currentQuery);
...@@ -55,6 +52,7 @@ const SummarizeInner = ({ ...@@ -55,6 +52,7 @@ const SummarizeInner = ({
onClose(); onClose();
}; };
const stageIndex = -1;
const hasAggregations = Lib.aggregations(currentQuery, stageIndex).length > 0; const hasAggregations = Lib.aggregations(currentQuery, stageIndex).length > 0;
return ( return (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment