Skip to content
Snippets Groups Projects
Unverified Commit 6c9099bf authored by Kamil Mielnik's avatar Kamil Mielnik Committed by GitHub
Browse files

Fix flaky question management e2e test (#42444)

* Fix flaky question management test

* Update assertions order to reduce probability of a flake

* Use explicit assertions

* Change assertion order

* Decrease flakiness
parent 7ce86613
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,8 @@ describe(
.click()
.type("1")
.blur();
assertOnRequest("updateQuestion");
assertRequestNot403("updateQuestion");
assertNoPermissionsError();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders1");
});
......@@ -71,7 +72,8 @@ describe(
.type("foo", { delay: 0 })
.blur();
assertOnRequest("updateQuestion");
assertRequestNot403("updateQuestion");
assertNoPermissionsError();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("foo");
......@@ -91,16 +93,17 @@ describe(
});
moveQuestionTo(/Personal Collection/);
assertOnRequest("updateQuestion");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("37.65");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains(
`Question moved to ${getPersonalCollectionName(
USERS[user],
)}`,
);
assertRequestNot403("updateQuestion");
cy.findAllByRole("status")
.contains(
`Question moved to ${getPersonalCollectionName(
USERS[user],
)}`,
)
.should("exist");
assertNoPermissionsError();
cy.findAllByRole("gridcell").contains("37.65");
navigationSidebar().within(() => {
// Highlight "Your personal collection" after move
......@@ -135,7 +138,7 @@ describe(
cy.get("header").findByText(NEW_COLLECTION_NAME);
});
it("should be able to move models", () => {
it("should be able to move models", { tags: "@flaky" }, () => {
// TODO: Currently nodata users can't turn a question into a model
cy.skipOn(user === "nodata");
......@@ -153,14 +156,17 @@ describe(
});
moveQuestionTo(/Personal Collection/);
assertOnRequest("updateQuestion");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("37.65");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains(
`Model moved to ${getPersonalCollectionName(USERS[user])}`,
);
assertRequestNot403("updateQuestion");
cy.findAllByRole("status")
.contains(
`Model moved to ${getPersonalCollectionName(
USERS[user],
)}`,
)
.should("exist");
assertNoPermissionsError();
cy.findAllByRole("gridcell").contains("37.65");
navigationSidebar().within(() => {
// Highlight "Your personal collection" after move
......@@ -185,7 +191,8 @@ describe(
"It will also be removed from the filter that uses it to populate values.",
).should("not.exist");
clickButton("Archive");
assertOnRequest("updateQuestion");
assertRequestNot403("updateQuestion");
assertNoPermissionsError();
cy.wait("@getItems"); // pinned items
cy.wait("@getItems"); // unpinned items
cy.location("pathname").should("eq", "/collection/root");
......@@ -447,11 +454,13 @@ function clickButton(name) {
cy.button(name).should("not.be.disabled").click();
}
function assertOnRequest(xhr_alias) {
function assertRequestNot403(xhr_alias) {
cy.wait("@" + xhr_alias).then(xhr => {
expect(xhr.status).not.to.eq(403);
});
}
function assertNoPermissionsError() {
cy.findByText("Sorry, you don’t have permission to see that.").should(
"not.exist",
);
......@@ -459,8 +468,11 @@ function assertOnRequest(xhr_alias) {
function turnIntoModel() {
openQuestionActions();
cy.findByText("Turn into a model").click();
cy.findByText("Turn this into a model").click();
cy.findByRole("dialog").contains("Turn into a model").click();
cy.findByRole("dialog").contains("Turn this into a model").click();
assertRequestNot403("updateQuestion");
cy.findAllByRole("status").contains("This is a model now.").should("exist");
assertNoPermissionsError();
}
function findPickerItem(name) {
......
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