-
Notifications
You must be signed in to change notification settings - Fork 25
EVG-19948: Support EC2 On-Demand on provider settings page #2071
Changes from 3 commits
59193d0
645c0ad
0a127e1
d0b2fa3
84cbbb2
fb25c9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,4 +165,81 @@ describe("provider section", () => { | |
cy.contains("button", "Add region settings").should("exist"); | ||
}); | ||
}); | ||
|
||
describe("ec2 on-demand", () => { | ||
beforeEach(() => { | ||
cy.visit("/distro/ubuntu1604-parent/settings/provider"); | ||
}); | ||
|
||
it("shows and hides fields correctly", () => { | ||
// VPC options. | ||
cy.dataCy("use-vpc").should("be.checked"); | ||
cy.contains("Default VPC Subnet ID").should("exist"); | ||
cy.contains("VPC Subnet Prefix").should("exist"); | ||
|
||
cy.dataCy("use-vpc").uncheck({ force: true }); | ||
cy.contains("Default VPC Subnet ID").should("not.exist"); | ||
cy.contains("VPC Subnet Prefix").should("not.exist"); | ||
Comment on lines
+181
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to take advantage asserting visibility if showing/hiding is a theme of the test. |
||
}); | ||
|
||
it("successfully updates ec2 on-demand provider fields", () => { | ||
cy.dataCy("provider-select").contains("EC2 On Demand"); | ||
|
||
// Correct section is displayed. | ||
cy.dataCy("ec2-on-demand-provider-settings").should("exist"); | ||
cy.dataCy("region-select").contains("us-east-1"); | ||
|
||
// Change field values. | ||
cy.selectLGOption("Region", "us-west-1"); | ||
cy.getInputByLabel("EC2 AMI ID").as("amiInput"); | ||
cy.get("@amiInput").clear(); | ||
cy.get("@amiInput").type("ami-1234560"); | ||
cy.getInputByLabel("SSH Key Name").as("keyNameInput"); | ||
cy.get("@keyNameInput").clear(); | ||
cy.get("@keyNameInput").type("my ssh key"); | ||
cy.getInputByLabel("User Data").type("<powershell></powershell>"); | ||
cy.getInputByLabel("Merge with existing user data").check({ | ||
force: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably better to not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
}); | ||
save(); | ||
cy.validateToast("success"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's helpful to include the toast copy because it helps document the test and leaves a breadcrumb to the hook. |
||
|
||
// Revert fields to original values. | ||
cy.selectLGOption("Region", "us-east-1"); | ||
cy.get("@amiInput").clear(); | ||
cy.get("@amiInput").type("ami-0000"); | ||
cy.get("@keyNameInput").clear(); | ||
cy.get("@keyNameInput").type("mci"); | ||
cy.getInputByLabel("User Data").clear(); | ||
cy.getInputByLabel("Merge with existing user data").uncheck({ | ||
force: true, | ||
}); | ||
save(); | ||
cy.validateToast("success"); | ||
}); | ||
|
||
it("can add and delete region settings", () => { | ||
cy.dataCy("ec2-on-demand-provider-settings").should("exist"); | ||
|
||
// Add item for new region. | ||
cy.contains("button", "Add region settings").click(); | ||
cy.contains("button", "Add region settings").should("not.exist"); | ||
|
||
// Save new region. | ||
cy.selectLGOption("Region", "us-west-1"); | ||
cy.getInputByLabel("EC2 AMI ID").type("ami-1234"); | ||
cy.getInputByLabel("Instance Type").type("m5.xlarge"); | ||
cy.contains("button", "Add security group").click(); | ||
cy.getInputByLabel("Security Group ID").type("security-group-1234"); | ||
save(); | ||
cy.validateToast("success"); | ||
|
||
// Revert to original state by deleting the new region. | ||
cy.dataCy("delete-item-button").first().click(); | ||
save(); | ||
cy.validateToast("success"); | ||
|
||
cy.contains("button", "Add region settings").should("exist"); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's reliable to use
force
when making assertions on components related to the test description. Usingforce
prevents testing if theuse-vpc
button is actually available to click. Ifuse-vpc
is disabled or hidden, this code will pass through. I thinkforce
usage is okay when setting the page up in a particular state to begin testing because those assertions are less important then.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
force
is pretty much required for LG checkboxes since they have a styling that makes them hidden and unclickable