From c1104e37e53489cfe7c34c0d6b25d3ecabdbcb6f Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Thu, 25 Jan 2024 10:21:02 +0100 Subject: [PATCH] ci(cypress): add maas cli commands --- cypress/support/commands.ts | 10 ++++++++++ cypress/support/e2e.ts | 1 + 2 files changed, 11 insertions(+) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 62270f420c7..fc2229e5ba0 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -50,6 +50,16 @@ Cypress.Commands.add("addMachine", (hostname = generateName()) => { }); }); +Cypress.Commands.add( + "addMachineCLI", + (hostname = generateName(), macAddress = generateMac()) => { + const maasCLICommand = `maas admin machines create hostname=${hostname} mac_addresses=${macAddress}`; + cy.exec(maasCLICommand).then((result) => { + expect(result.code).to.eq(0); + }); + } +); + Cypress.Commands.add("deleteMachine", (hostname: string) => { cy.visit(generateMAASURL("/machines")); cy.findByRole("combobox", { name: "Group by" }).select("No grouping"); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index c240aa14159..c95015387d4 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -10,6 +10,7 @@ declare global { namespace Cypress { interface Chainable { addMachine(hostname?: string): void; + addMachineCLI(hostname?: string, macAddress?: string): void; addMachines(hostname: string[]): void; deleteMachine(hostname: string): void; deletePool(pool: string): void;