E2e test: addDockerHost to a specific team (#1116)

* Add optional argument to addDockerHost for teams
This commit is contained in:
RachelElysia 2021-06-17 10:09:12 -04:00 committed by GitHub
parent 6b59a40dbc
commit eaef007982
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -6,7 +6,7 @@ if (Cypress.env("FLEET_TIER") === "basic") {
cy.seedBasic();
cy.setupSMTP();
cy.seedQueries();
cy.addDockerHost();
cy.addDockerHost("oranges");
cy.logout();
});
afterEach(() => {

View file

@ -234,16 +234,25 @@ Cypress.Commands.add("addUser", (username, options = {}) => {
);
});
Cypress.Commands.add("addDockerHost", () => {
// Ability to add a docker host to a team using args if ran after seedBasic()
Cypress.Commands.add("addDockerHost", (team = "") => {
const serverPort = new URL(Cypress.config().baseUrl).port;
// Get enroll secret
let enrollSecretURL = "/api/v1/fleet/spec/enroll_secret";
if (team === "apples") {
enrollSecretURL = "/api/v1/fleet/teams/1/secrets";
} else if (team === "oranges") {
enrollSecretURL = "/api/v1/fleet/teams/2/secrets";
}
cy.request({
url: "/api/v1/fleet/spec/enroll_secret",
url: enrollSecretURL,
auth: {
bearer: window.localStorage.getItem("FLEET::auth_token"),
},
}).then(({ body }) => {
const enrollSecret = body.specs.secrets[0].secret;
const enrollSecret =
team === "" ? body.specs.secrets[0].secret : body.secrets[0].secret;
// Start up docker-compose with enroll secret
cy.exec(