From b0dcc7287821b2949823b0d25fbc737659681a8b Mon Sep 17 00:00:00 2001 From: Izaac Zavaleta Date: Sun, 1 Dec 2024 22:26:56 -0700 Subject: [PATCH] Check default limit values in UI while creating a Pod with the Form --- cypress/e2e/po/components/workloads/pod.po.ts | 14 +++++++ .../pods/pod-container-general.po.ts | 16 ++++++++ .../pods/pod-container-resources.po.ts | 34 +++++++++++++++++ .../workloads/pods/pod-container.po.ts | 12 ++++++ .../pages/explorer2/workloads/pods.spec.ts | 38 ++++++++++++++++++- 5 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 cypress/e2e/po/components/workloads/pods/pod-container-general.po.ts create mode 100644 cypress/e2e/po/components/workloads/pods/pod-container-resources.po.ts create mode 100644 cypress/e2e/po/components/workloads/pods/pod-container.po.ts diff --git a/cypress/e2e/po/components/workloads/pod.po.ts b/cypress/e2e/po/components/workloads/pod.po.ts index 7a23fdb6d86..3f9d90da7e3 100644 --- a/cypress/e2e/po/components/workloads/pod.po.ts +++ b/cypress/e2e/po/components/workloads/pod.po.ts @@ -2,12 +2,18 @@ import CreateEditViewPo from '@/cypress/e2e/po/components/create-edit-view.po'; import Kubectl from '@/cypress/e2e/po/components/kubectl.po'; import Shell from '@/cypress/e2e/po/components/shell.po'; import NameNsDescription from '@/cypress/e2e/po/components/name-ns-description.po'; +import { PodContainer } from '@/cypress/e2e/po/components/workloads/pods/pod-container.po'; +import ResourceDetailPo from '~/cypress/e2e/po/edit/resource-detail.po'; export default class PodPo extends CreateEditViewPo { constructor(selector = '.dashboard-root') { super(selector); } + resourceTitle() { + return this.self().find('masthead-resource-title'); + } + nameNsDescription() { return new NameNsDescription(this.self()); } @@ -26,4 +32,12 @@ export default class PodPo extends CreateEditViewPo { shell.openTerminal(); } + + containerButton() { + return new PodContainer(); + } + + saveCreateForm(): ResourceDetailPo { + return new ResourceDetailPo(this.self()); + } } diff --git a/cypress/e2e/po/components/workloads/pods/pod-container-general.po.ts b/cypress/e2e/po/components/workloads/pods/pod-container-general.po.ts new file mode 100644 index 00000000000..cfc8c79f143 --- /dev/null +++ b/cypress/e2e/po/components/workloads/pods/pod-container-general.po.ts @@ -0,0 +1,16 @@ +import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; +import ComponentPo from '@/cypress/e2e/po/components/component.po'; + +export class PodContainerGeneral extends ComponentPo { + constructor(selector = '.dashboard-root') { + super(selector); + } + + inputImageName() { + return new LabeledInputPo(cy.get('[placeholder="e.g. nginx:latest"]')); + } + + createButton() { + return this.self().find('[data-testid="form-save"]'); + } +} diff --git a/cypress/e2e/po/components/workloads/pods/pod-container-resources.po.ts b/cypress/e2e/po/components/workloads/pods/pod-container-resources.po.ts new file mode 100644 index 00000000000..d99629beffe --- /dev/null +++ b/cypress/e2e/po/components/workloads/pods/pod-container-resources.po.ts @@ -0,0 +1,34 @@ +import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; +import ComponentPo from '@/cypress/e2e/po/components/component.po'; + +export class PodContainerResources extends ComponentPo { + constructor(selector = '.dashboard-root') { + super(selector); + } + + clickResources() { + return this.self().get('[data-testid="btn-resources"]').first() + .scrollIntoView() + .click(); + } + + inputCpuReservation() { + return new LabeledInputPo(cy.get('[data-testid="cpu-reservation"]')); + } + + inputMemoryReservation() { + return new LabeledInputPo(cy.get('[data-testid="memory-reservation"]')); + } + + inputCpuLimit() { + return new LabeledInputPo(cy.get('[data-testid="cpu-limit"]')); + } + + inputMemoryLimit() { + return new LabeledInputPo(cy.get('[data-testid="memory-limit"]')); + } + + inputGpuLimit() { + return new LabeledInputPo(cy.get('[data-testid="gpu-limit"]')); + } +} diff --git a/cypress/e2e/po/components/workloads/pods/pod-container.po.ts b/cypress/e2e/po/components/workloads/pods/pod-container.po.ts new file mode 100644 index 00000000000..281a4374fcf --- /dev/null +++ b/cypress/e2e/po/components/workloads/pods/pod-container.po.ts @@ -0,0 +1,12 @@ +import { PodContainerGeneral } from '@/cypress/e2e/po/components/workloads/pods/pod-container-general.po'; +import { PodContainerResources } from '@/cypress/e2e/po/components/workloads/pods/pod-container-resources.po'; + +export class PodContainer { + resources() { + return new PodContainerResources('[data-testid="btn-resources"]'); + } + + general() { + return new PodContainerGeneral('[data-testid="btn-general"]'); + } +} diff --git a/cypress/e2e/tests/pages/explorer2/workloads/pods.spec.ts b/cypress/e2e/tests/pages/explorer2/workloads/pods.spec.ts index 505038e8e81..126117049eb 100644 --- a/cypress/e2e/tests/pages/explorer2/workloads/pods.spec.ts +++ b/cypress/e2e/tests/pages/explorer2/workloads/pods.spec.ts @@ -200,7 +200,7 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer2', '@adminUser'] }, ( // delete namespace (this will also delete all pods in it) cy.deleteRancherResource('v1', 'namespaces', nsName1); cy.deleteRancherResource('v1', 'namespaces', nsName2); - }); + }) }); describe('Should open a terminal', () => { @@ -281,6 +281,42 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer2', '@adminUser'] }, ( }); }); + describe('When creating a pod using the web Form', () => { + const singlePodName = Cypress._.uniqueId(Date.now().toString()); + + it(`should have the default input units displayed`, () => { + workloadsPodPage.goTo(); + workloadsPodPage.createPod(); + + const podDetails = new PodPo(); + + podDetails.nameNsDescription().name().set(singlePodName); + + const podDetailsGeneral = podDetails.containerButton().general(); + + podDetailsGeneral.inputImageName().set('nginx:alpine'); + const podDetailsResources = podDetails.containerButton().resources(); + + podDetailsResources.clickResources(); + + podDetailsResources.inputCpuLimit().getAttributeValue('placeholder').should('contain', 'e.g. 1000'); + podDetailsResources.inputCpuReservation().getAttributeValue('placeholder').should('contain', 'e.g. 1000'); + podDetailsResources.inputMemoryReservation().getAttributeValue('placeholder').should('contain', 'e.g. 128'); + podDetailsResources.inputMemoryLimit().getAttributeValue('placeholder').should('contain', 'e.g. 128'); + podDetailsResources.inputGpuLimit().getAttributeValue('placeholder').should('contain', 'e.g. 1'); + + podDetailsResources.inputCpuLimit().set('100'); + podDetailsResources.inputCpuReservation().set('100'); + podDetailsResources.inputMemoryLimit().set('128'); + podDetailsResources.inputMemoryLimit().set('128'); + podDetailsResources.inputGpuLimit().set('0'); + + podDetails.saveCreateForm().cruResource().saveOrCreate().click(); + workloadsPodPage.waitForPage(); + workloadsPodPage.sortableTable().rowElementWithName(singlePodName).scrollIntoView().should('be.visible'); + }); + }); + // describe.skip('[Vue3 Skip]: should delete pod', () => { // const podName = `pod-${ Date.now() }`;