Skip to content
Snippets Groups Projects
Unverified Commit ab4ae529 authored by Sloan Sparger's avatar Sloan Sparger Committed by GitHub
Browse files

Fix admin landing page e2e test flakes (#37653)

parent 73ff8b97
No related branches found
No related tags found
No related merge requests found
......@@ -286,53 +286,36 @@ describeEE("formatting > whitelabel", () => {
describe("Landing Page", () => {
beforeEach(() => {
cy.intercept("PUT", "/api/setting/landing-page").as("putLandingPage");
});
it("should allow users to provide internal urls", () => {
cy.intercept("GET", "/api/setting").as("getSettings");
cy.signInAsAdmin();
cy.visit("/admin/settings/whitelabel");
cy.location("origin").then(origin => {
// test root / path
testValidLandingPageInput({ input: "/", expected: origin + "/" });
// test relative url
testValidLandingPageInput({
input: "/test-1",
expected: origin + "/test-1",
});
});
// test no input
testValidLandingPageInput({ input: "", expected: origin + "/" });
it("should allow users to provide internal urls", () => {
cy.findByTestId("landing-page").click().clear().type("/test-1").blur();
cy.wait(["@putLandingPage", "@getSettings"]);
// test absolute url matching the page's origin
testValidLandingPageInput({
input: origin + "/test-2",
expected: origin + "/test-2",
});
});
cy.findByTestId("landing-page-error").should("not.exist");
cy.findByRole("navigation").findByText("Exit admin").click();
cy.url().should("include", "/test-1");
});
it("should not allow users to provide external urls", () => {
cy.signInAsAdmin();
cy.visit("/admin/settings/whitelabel");
cy.findByTestId("landing-page").click().clear().type("/test-2").blur();
cy.wait(["@putLandingPage", "@getSettings"]);
cy.location("origin").then(origin => {
// first set to a valid value
testValidLandingPageInput({ input: "/", expected: origin + "/" });
// test that setting invalid value errors and is not persisted
cy.visit("/admin/settings/whitelabel");
cy.findByTestId("landing-page")
.click()
.type("{selectAll}" + "{backspace}" + "https://google.com")
.blur();
cy.findByTestId("landing-page-error")
.findByText("This field must be a relative URL.")
.should("exist");
cy.findByText("Exit admin").click();
cy.url().should("eq", origin + "/");
});
// set to valid value then test invalid value is not persisted
cy.findByTestId("landing-page")
.click()
.clear()
.type("https://google.com")
.blur();
cy.findByTestId("landing-page-error")
.findByText("This field must be a relative URL.")
.should("exist");
cy.findByRole("navigation").findByText("Exit admin").click();
cy.url().should("include", "/test-2");
});
});
});
......@@ -355,20 +338,3 @@ const helpLink = () => popover().findByRole("link", { name: "Help" });
const getHelpLinkCustomDestinationInput = () =>
cy.findByPlaceholderText("Enter a URL it should go to");
const testValidLandingPageInput = ({ input, expected }) => {
cy.visit("/admin/settings/whitelabel");
const field = cy.findByTestId("landing-page");
field.click().clear();
if (input) {
field.type(input);
}
field.blur();
cy.findByTestId("landing-page").click().clear();
cy.wait("@putLandingPage");
cy.findByTestId("landing-page-error").should("not.exist");
cy.findByText("Exit admin").click();
cy.url().should("eq", expected);
};
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