Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 backported "Fix flaky question management e2e test" #42451

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions e2e/test/scenarios/question/question-management.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ describe(
.click()
.type("1")
.blur();
assertOnRequest("updateQuestion");
assertRequestNot403("updateQuestion");
assertNoPermissionsError();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders1");
});
Expand All @@ -70,7 +71,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");
Expand All @@ -94,16 +96,17 @@ describe(
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("My personal collection").click();
clickButton("Move");
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
Expand All @@ -130,7 +133,7 @@ describe(
cy.get("header").findByText(NEW_COLLECTION);
});

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");

Expand All @@ -152,14 +155,17 @@ describe(
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("My personal collection").click();
clickButton("Move");
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
Expand All @@ -184,7 +190,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");
Expand Down Expand Up @@ -473,20 +480,25 @@ 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",
);
}

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 findSelectedItem() {
Expand Down