diff --git a/cypress/integration/basic/admin.spec.ts b/cypress/integration/basic/admin.spec.ts index 7394684227..f68ff29817 100644 --- a/cypress/integration/basic/admin.spec.ts +++ b/cypress/integration/basic/admin.spec.ts @@ -6,7 +6,7 @@ if (Cypress.env("FLEET_TIER") === "basic") { cy.seedBasic(); cy.setupSMTP(); cy.seedQueries(); - cy.addDockerHost(); + cy.addDockerHost("oranges"); cy.logout(); }); afterEach(() => { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 42636ff3f9..2e977bc6df 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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(