-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add repro for #35711 * Format code
- Loading branch information
1 parent
af200d4
commit ef9fb05
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...est/scenarios/models/reproductions/35711-metadata-in-models-with-custom-fields.cy.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; | ||
import { openQuestionActions, popover, restore } from "e2e/support/helpers"; | ||
import type { FieldReference } from "metabase-types/api"; | ||
|
||
const { ORDERS_ID, ORDERS } = SAMPLE_DATABASE; | ||
|
||
const DISCOUNT_FIELD_REF: FieldReference = [ | ||
"field", | ||
ORDERS.DISCOUNT, | ||
{ | ||
"base-type": "type/Float", | ||
}, | ||
]; | ||
|
||
describe("issue 35711", () => { | ||
beforeEach(() => { | ||
restore(); | ||
cy.signInAsAdmin(); | ||
}); | ||
|
||
it("can edit metadata of a model with a custom column (metabase#35711)", () => { | ||
cy.createQuestion( | ||
{ | ||
type: "model", | ||
query: { | ||
"source-table": ORDERS_ID, | ||
expressions: { | ||
"Custom column": ["-", DISCOUNT_FIELD_REF, 1], | ||
}, | ||
limit: 5, // optimization | ||
}, | ||
}, | ||
{ visitQuestion: true }, | ||
); | ||
|
||
openQuestionActions(); | ||
popover().findByText("Edit metadata").click(); | ||
reorderTaxAndTotalColumns(); | ||
assertNoError(); | ||
|
||
cy.findByTestId("editor-tabs-query-name").click(); | ||
assertNoError(); | ||
}); | ||
}); | ||
|
||
function reorderTaxAndTotalColumns() { | ||
cy.findAllByTestId("header-cell").eq(4).should("have.text", "Tax"); | ||
cy.findAllByTestId("header-cell").eq(5).should("have.text", "Total"); | ||
|
||
// drag & drop the Total column 100 px to the left to switch it with Tax column | ||
cy.findAllByTestId("header-cell") | ||
.contains("Total") | ||
.then(totalColumn => { | ||
const rect = totalColumn[0].getBoundingClientRect(); | ||
cy.wrap(totalColumn) | ||
.trigger("mousedown") | ||
.trigger("mousemove", { clientX: rect.x - 100, clientY: rect.y }) | ||
.trigger("mouseup"); | ||
}); | ||
|
||
cy.findAllByTestId("header-cell").eq(4).should("have.text", "Total"); | ||
cy.findAllByTestId("header-cell").eq(5).should("have.text", "Tax"); | ||
} | ||
|
||
function assertNoError() { | ||
cy.button("Get Answer").should("not.exist"); | ||
cy.get("main") | ||
.findByText("There was a problem with your question") | ||
.should("not.exist"); | ||
cy.get(".cellData").should("contain", "37.65"); | ||
} |