Skip to content

Commit

Permalink
Check default limit values in UI while creating a Pod with the Form
Browse files Browse the repository at this point in the history
  • Loading branch information
izaac committed Dec 3, 2024
1 parent bb1f8c2 commit b0dcc72
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cypress/e2e/po/components/workloads/pod.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -26,4 +32,12 @@ export default class PodPo extends CreateEditViewPo {

shell.openTerminal();
}

containerButton() {
return new PodContainer();
}

saveCreateForm(): ResourceDetailPo {
return new ResourceDetailPo(this.self());
}
}
Original file line number Diff line number Diff line change
@@ -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"]');
}
}
Original file line number Diff line number Diff line change
@@ -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"]'));
}
}
12 changes: 12 additions & 0 deletions cypress/e2e/po/components/workloads/pods/pod-container.po.ts
Original file line number Diff line number Diff line change
@@ -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"]');
}
}
38 changes: 37 additions & 1 deletion cypress/e2e/tests/pages/explorer2/workloads/pods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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() }`;

Expand Down

0 comments on commit b0dcc72

Please sign in to comment.