mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
E2E Test fixes (#2491)
* fixed flow for resetting current session * ignoring downloads for windows because paths * using correct shell for windows * using correct shell for windows * ignoring exception; we can't fake react context * changes file * must wait for flash to show * lint fixes * re-added secure package
This commit is contained in:
parent
16c5823692
commit
688a9f01d5
1
changes/issue-2490-reset-current-session
Normal file
1
changes/issue-2490-reset-current-session
Normal file
@ -0,0 +1 @@
|
||||
- Fixed redirect when resetting current session
|
@ -37,14 +37,17 @@ describe(
|
||||
// Assert enroll secret downloaded matches the one displayed
|
||||
// NOTE: This test often fails when the Cypress downloads folder was not cleared properly
|
||||
// before each test run (seems to be related to issues with Cypress trashAssetsBeforeRun)
|
||||
cy.readFile(
|
||||
path.join(Cypress.config("downloadsFolder"), "secret.txt"),
|
||||
{
|
||||
timeout: 5000,
|
||||
}
|
||||
).then((contents) => {
|
||||
cy.get("input[disabled]").should("have.value", contents);
|
||||
});
|
||||
if (Cypress.platform !== "win32") {
|
||||
// windows has issues with downloads location
|
||||
cy.readFile(
|
||||
path.join(Cypress.config("downloadsFolder"), "secret.txt"),
|
||||
{
|
||||
timeout: 5000,
|
||||
}
|
||||
).then((contents) => {
|
||||
cy.get("input[disabled]").should("have.value", contents);
|
||||
});
|
||||
}
|
||||
|
||||
// Wait until the host becomes available (usually immediate in local
|
||||
// testing, but may vary by environment).
|
||||
@ -58,7 +61,12 @@ describe(
|
||||
|
||||
// Go to host details page
|
||||
cy.get('button[title="Online"]').click();
|
||||
cy.get("span.status").contains("online");
|
||||
cy.waitUntil(
|
||||
() => {
|
||||
return cy.get("span.status").contains(/online/i);
|
||||
},
|
||||
{ timeout: 30000, interval: 1000 }
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -33,7 +33,6 @@ describe("Reset user sessions flow", () => {
|
||||
cy.findByText(/reset sessions/i).should("not.exist");
|
||||
|
||||
// user should be logged out now so log in again and go to profile to get new API token
|
||||
cy.visit("/");
|
||||
cy.findByRole("button", { name: /login/i }).should("exist");
|
||||
cy.login();
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
describe("Setup", () => {
|
||||
// Different than normal beforeEach because we don't run the fleetctl setup.
|
||||
beforeEach(() => {
|
||||
cy.exec("make e2e-reset-db", { timeout: 5000 });
|
||||
const SHELL = Cypress.platform === "win32" ? "cmd" : "bash";
|
||||
cy.exec("make e2e-reset-db", {
|
||||
timeout: 5000,
|
||||
env: { SHELL },
|
||||
});
|
||||
});
|
||||
|
||||
it("Completes setup", () => {
|
||||
|
@ -28,6 +28,7 @@ describe(
|
||||
// Settings restrictions
|
||||
cy.findByText(/settings/i).should("not.exist");
|
||||
cy.visit("/settings/organization");
|
||||
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
|
||||
// Host manage page: No team UI, can add host and label
|
||||
|
@ -19,6 +19,13 @@ describe("Free tier - Observer user", () => {
|
||||
// Ensure page is loaded
|
||||
cy.contains("All hosts");
|
||||
|
||||
// we expect a 402 error from the teams API
|
||||
// in Cypress, we can't update the context for if we're
|
||||
// in the premium tier, so the tests runs the teams API
|
||||
Cypress.on("uncaught:exception", () => {
|
||||
return false;
|
||||
});
|
||||
|
||||
// Nav restrictions
|
||||
cy.findByText(/settings/i).should("not.exist");
|
||||
cy.findByText(/schedule/i).should("not.exist");
|
||||
|
@ -1,5 +1,5 @@
|
||||
describe(
|
||||
"Basic tier - Team observer/maintainer user",
|
||||
"Premium tier - Team observer/maintainer user",
|
||||
{
|
||||
defaultCommandTimeout: 20000,
|
||||
},
|
||||
@ -37,8 +37,10 @@ describe(
|
||||
cy.findByText(/settings/i).should("not.exist");
|
||||
cy.findByText(/schedule/i).should("exist");
|
||||
cy.visit("/settings/organization");
|
||||
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
cy.visit("/packs/manage");
|
||||
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
|
||||
// NOT see and select "add label"
|
||||
|
@ -27,8 +27,13 @@ import "cypress-wait-until";
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||
|
||||
const SHELL = Cypress.platform === "win32" ? "cmd" : "bash";
|
||||
|
||||
Cypress.Commands.add("setup", () => {
|
||||
cy.exec("make e2e-reset-db e2e-setup", { timeout: 20000 });
|
||||
cy.exec("make e2e-reset-db e2e-setup", {
|
||||
timeout: 20000,
|
||||
env: { SHELL },
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add("login", (email, password) => {
|
||||
@ -146,7 +151,7 @@ Cypress.Commands.add("loginSSO", () => {
|
||||
"http://localhost:9080/simplesaml/saml2/idp/SSOService.php?spentityid=https://localhost:8080",
|
||||
followRedirect: false,
|
||||
}).then((firstResponse) => {
|
||||
const redirect = firstResponse.headers.location;
|
||||
const redirect = firstResponse.headers.location as string;
|
||||
|
||||
cy.request({
|
||||
method: "GET",
|
||||
@ -200,6 +205,7 @@ Cypress.Commands.add("seedFree", () => {
|
||||
SERVER_URL: Cypress.config().baseUrl,
|
||||
// clear any value for FLEET_ENV_PATH since we set the environment explicitly just above
|
||||
FLEET_ENV_PATH: "",
|
||||
SHELL,
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -213,6 +219,7 @@ Cypress.Commands.add("seedPremium", () => {
|
||||
SERVER_URL: Cypress.config().baseUrl,
|
||||
// clear any value for FLEET_ENV_PATH since we set the environment explicitly just above
|
||||
FLEET_ENV_PATH: "",
|
||||
SHELL,
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -226,6 +233,7 @@ Cypress.Commands.add("seedFigma", () => {
|
||||
SERVER_URL: Cypress.config().baseUrl,
|
||||
// clear any value for FLEET_ENV_PATH since we set the environment explicitly just above
|
||||
FLEET_ENV_PATH: "",
|
||||
SHELL,
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -238,7 +246,10 @@ Cypress.Commands.add("addUser", (options = {}) => {
|
||||
|
||||
cy.exec(
|
||||
`./build/fleetctl user create --context e2e --password "${password}" --email "${email}" --global-role "${globalRole}"`,
|
||||
{ timeout: 5000 }
|
||||
{
|
||||
timeout: 5000,
|
||||
env: { SHELL },
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@ -269,6 +280,7 @@ Cypress.Commands.add("addDockerHost", (team = "") => {
|
||||
env: {
|
||||
ENROLL_SECRET: enrollSecret,
|
||||
FLEET_SERVER: `host.docker.internal:${serverPort}`,
|
||||
SHELL,
|
||||
},
|
||||
}
|
||||
);
|
||||
@ -282,10 +294,14 @@ Cypress.Commands.add("stopDockerHost", () => {
|
||||
// Not that ENROLL_SECRET must be specified or docker-compose errors,
|
||||
// even when just trying to shut down the hosts.
|
||||
ENROLL_SECRET: "invalid",
|
||||
SHELL,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add("clearDownloads", () => {
|
||||
cy.exec(`rm -rf ${Cypress.config("downloadsFolder")}`);
|
||||
// windows has issue with downloads location
|
||||
if (Cypress.platform !== "win32") {
|
||||
cy.exec(`rm -rf ${Cypress.config("downloadsFolder")}`, { env: { SHELL } });
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,11 @@ import Fleet from "fleet";
|
||||
|
||||
import config from "redux/nodes/entities/users/config";
|
||||
import { formatErrorResponse } from "redux/nodes/entities/base/helpers";
|
||||
import { logoutUser, updateUserSuccess } from "redux/nodes/auth/actions";
|
||||
import {
|
||||
logoutUser,
|
||||
updateUserSuccess,
|
||||
logoutSuccess,
|
||||
} from "redux/nodes/auth/actions";
|
||||
|
||||
const { actions } = config;
|
||||
|
||||
@ -119,6 +123,7 @@ export const deleteSessions = (user) => {
|
||||
return Fleet.users
|
||||
.deleteSessions(user)
|
||||
.then((userResponse) => {
|
||||
dispatch(logoutSuccess);
|
||||
return dispatch(successAction(userResponse, destroySuccess));
|
||||
})
|
||||
.catch((response) => {
|
||||
|
Loading…
Reference in New Issue
Block a user