Skip to content
Snippets Groups Projects
Unverified Commit f88fbc72 authored by Gustavo Saiani's avatar Gustavo Saiani Committed by GitHub
Browse files

Pin model if created from scratch (#26069)

parent b3d4cd24
No related merge requests found
...@@ -269,8 +269,14 @@ function QueryBuilder(props) { ...@@ -269,8 +269,14 @@ function QueryBuilder(props) {
const handleCreate = useCallback( const handleCreate = useCallback(
async card => { async card => {
const questionWithUpdatedCard = question.setCard(card).setPinned(false); const shouldBePinned = Boolean(card.dataset);
const questionWithUpdatedCard = question
.setCard(card)
.setPinned(shouldBePinned);
await apiCreateQuestion(questionWithUpdatedCard); await apiCreateQuestion(questionWithUpdatedCard);
setRecentlySaved("created"); setRecentlySaved("created");
}, },
[question, apiCreateQuestion, setRecentlySaved], [question, apiCreateQuestion, setRecentlySaved],
......
import { restore } from "__support__/e2e/helpers"; import { restore, visitCollection } from "__support__/e2e/helpers";
const modelName = "A name";
describe("scenarios > models > create", () => { describe("scenarios > models > create", () => {
beforeEach(() => { beforeEach(() => {
...@@ -26,7 +28,7 @@ describe("scenarios > models > create", () => { ...@@ -26,7 +28,7 @@ describe("scenarios > models > create", () => {
cy.findByText("Save").click(); cy.findByText("Save").click();
cy.findByPlaceholderText("What is the name of your model?").type("A name"); cy.findByPlaceholderText("What is the name of your model?").type(modelName);
cy.findByText("Save").click(); cy.findByText("Save").click();
...@@ -34,6 +36,8 @@ describe("scenarios > models > create", () => { ...@@ -34,6 +36,8 @@ describe("scenarios > models > create", () => {
// After saving, we land on view mode for the model // After saving, we land on view mode for the model
cy.findByText("Summarize"); cy.findByText("Summarize");
checkIfPinned();
}); });
}); });
...@@ -42,3 +46,14 @@ function goFromHomePageToNewNativeQueryModelPage() { ...@@ -42,3 +46,14 @@ function goFromHomePageToNewNativeQueryModelPage() {
cy.findByText("Model").click(); cy.findByText("Model").click();
cy.findByText("Use a native query").click(); cy.findByText("Use a native query").click();
} }
function checkIfPinned() {
visitCollection("root");
cy.findByText(modelName)
.closest("a")
.find(".Icon-ellipsis")
.click({ force: true });
cy.findByText("Unpin").should("be.visible");
}
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