Skip to content
Snippets Groups Projects
Unverified Commit 54ffe92a authored by Uladzimir Havenchyk's avatar Uladzimir Havenchyk Committed by GitHub
Browse files

fix broken test about resizing column by readonly user (#47916)


* fix broken test about resizing column by readonly user

* Update e2e/test/scenarios/question/saved.cy.spec.js

Co-authored-by: default avatarNemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>

---------

Co-authored-by: default avatarNemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
parent 49cfe358
No related branches found
No related tags found
No related merge requests found
......@@ -251,44 +251,31 @@ describe("scenarios > question > saved", () => {
});
});
it(
"'read-only' user should be able to resize column width (metabase#9772)",
{ tags: "@flaky" },
() => {
cy.signIn("readonly");
visitQuestion(ORDERS_QUESTION_ID);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Tax")
.closest(".test-TableInteractive-headerCellData")
.as("headerCell")
.then($cell => {
const originalWidth = $cell[0].getBoundingClientRect().width;
// Retries the assertion a few times to ensure it waits for DOM changes
// More context: https://github.com/metabase/metabase/pull/21823#discussion_r855302036
function assertColumnResized(attempt = 0) {
cy.get("@headerCell").then($newCell => {
const newWidth = $newCell[0].getBoundingClientRect().width;
if (newWidth === originalWidth && attempt < 3) {
cy.wait(100);
assertColumnResized(++attempt);
} else {
expect(newWidth).to.be.gt(originalWidth);
}
});
}
cy.wrap($cell)
.find(".react-draggable")
.trigger("mousedown", 0, 0, { force: true })
.trigger("mousemove", 100, 0, { force: true })
.trigger("mouseup", 100, 0, { force: true });
assertColumnResized();
});
},
);
it("'read-only' user should be able to resize column width (metabase#9772)", () => {
cy.signIn("readonly");
visitQuestion(ORDERS_QUESTION_ID);
cy.findAllByTestId("header-cell")
.filter(":contains(Tax)")
.as("headerCell")
.then($cell => {
const originalWidth = $cell[0].getBoundingClientRect().width;
cy.wrap(originalWidth).as("originalWidth");
});
cy.get("@headerCell")
.find(".react-draggable")
.trigger("mousedown", { which: 1 })
.trigger("mousemove", { clientX: 100, clientY: 0 })
.trigger("mouseup", { force: true });
cy.get("@originalWidth").then(originalWidth => {
cy.get("@headerCell").should($newCell => {
const newWidth = $newCell[0].getBoundingClientRect().width;
expect(newWidth).to.be.gt(originalWidth);
});
});
});
it("should always be possible to view the full title text of the saved question", () => {
visitQuestion(ORDERS_QUESTION_ID);
......
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