Skip to content

Commit

Permalink
Update for review
Browse files Browse the repository at this point in the history
  • Loading branch information
n313893254 committed Jun 10, 2022
1 parent e5d4004 commit 8585d05
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
8 changes: 2 additions & 6 deletions cypress/pageobjects/image.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class ImagePage {
cy.get('.tab#labels').click();
keys.forEach((key, index) => {
cy.contains('Add Label').click();
cy.get('.kv-item.key input').eq(index + 2).type(key);
cy.get('.kv-item.value input').eq(index + 2).type(value.labels[key]);
cy.get('.kv-item.key input').eq(-1).type(key);
cy.get('.kv-item.value input').eq(-1).type(value.labels[key]);
});
}

Expand Down Expand Up @@ -125,10 +125,6 @@ export class ImagePage {
cy.contains(value.name).parentsUntil('tbody', 'tr').find('td.col-image-percentage-bar').contains(valid ? 'Completed' : '0%', { timeout: constants.timeout.uploadTimeout }).should('be.visible');
// state indicator for status of image upload status e.g. active or uploading
cy.contains(value.name).parentsUntil('tbody', 'tr').find('td.col-badge-state-formatter').contains(valid ? 'Active' : 'Failed', { timeout: constants.timeout.uploadTimeout }).should('be.visible');

if (valid) {
cy.contains(value.size || 'Size need to be string').should('be.visible');
}
}

// public checkImageInLH(imageName: string) {
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobjects/volume.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class VolumePage {
cy.intercept('POST', `v1/harvester/persistentvolumeclaims/*/${ volumeName }?action=export`).as('exportImage');
cy.get(this.exportImageActions).contains('Create').click();
cy.wait('@exportImage').then(res => {
expect(res.response?.statusCode).to.equal(200);
expect(res.response?.statusCode, `Check Export Image`).to.be.oneOf([200, 204]);
expect(cy.contains('Succeed'));
});
}
Expand Down
65 changes: 52 additions & 13 deletions cypress/testcases/image/images.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import YAML from 'js-yaml'
import { VmsPage } from "@/pageobjects/virtualmachine.po";
import { ImagePage } from "@/pageobjects/image.po";
import { generateName } from '@/utils/utils';
import { HCI } from '@/constants/types';

const vms = new VmsPage();
const image = new ImagePage();

describe('Auto setup image from cypress environment', () => {
it('Auto setup image from cypress environment', () => {
const imageEnv = Cypress.env('image');
const IMAGE_NAME = imageEnv.name;
const IMAGE_URL = imageEnv.url;

const value = {
name: IMAGE_NAME,
url: IMAGE_URL,
}

cy.login();

cy.request({
url: `v1/harvester/${HCI.IMAGE}s`,
headers: {
accept: 'application/json'
}
}).as('imageList')

cy.get('@imageList').should((res: any) => {
expect(res?.status, 'Check Image list').to.equal(200);
const images = res?.body?.data || []

const imageEnv = Cypress.env('image');

const name = imageEnv.name
const url = imageEnv.url
const imageFound = images.find((i:any) => i?.spec?.displayName === name)

if (imageFound) {
return
} else {
image.goToCreate();
image.create(value);
image.checkState(value);
}
})
})
})

/**
* 1. Create image with cloud image available for openSUSE. http://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.3/images/openSUSE-Leap-15.3.x86_64-NoCloud.qcow2
* 2. Click save
Expand All @@ -19,12 +62,12 @@ const image = new ImagePage();
* 5. User should be able to create a new image with same name.
*/
describe('Create an image with valid image URL', () => {
const IMAGE_NAME = 'auto-image-valid-url-test';
const IMAGE_URL = 'http://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.3/images/openSUSE-Leap-15.3.x86_64-NoCloud.qcow2';
const imageEnv = Cypress.env('image');
const IMAGE_NAME = generateName('auto-image-valid-url-test');
const IMAGE_URL = imageEnv.url;
const value = {
name: IMAGE_NAME,
url: IMAGE_URL,
size: '544 MB',
labels: {
y1: 'z1',
y2: 'z2'
Expand Down Expand Up @@ -106,8 +149,8 @@ describe('Create an image with valid image URL', () => {
* 1. image “img-1” will be deleted
*/
describe('Delete VM with exported image', () => {
const IMAGE_NAME = 'img-1';
const VM_NAME = 'vm-1';
const IMAGE_NAME = generateName('img-1');
const VM_NAME = generateName('vm-1');

it('Delete VM with exported image', () => {
cy.login();
Expand Down Expand Up @@ -137,14 +180,10 @@ describe('Delete VM with exported image', () => {
image.goToList();
image.checkState({
name: IMAGE_NAME,
size: '10 GB'
});

// delete VM
vms.delete(namespace, VM_NAME);

// delete IMAGE
image.delete(IMAGE_NAME);
});
});

Expand All @@ -157,8 +196,8 @@ describe('Delete VM with exported image', () => {
* 1. image “img-1” will be updated
*/
describe('Update image labels after deleting source VM', () => {
const IMAGE_NAME = 'img-1';
const VM_NAME = 'vm-1';
const IMAGE_NAME = generateName('img-1');
const VM_NAME = generateName('vm-1');

it('Update image labels after deleting source VM', () => {
cy.login();
Expand Down Expand Up @@ -273,8 +312,8 @@ describe('Update image labels after deleting source VM', () => {
* 1. Image should upload.
*/
describe('Create a ISO image via upload', () => {
const IMAGE_NAME = 'auto-image-iso-upload-test';
const VM_NAME = 'auto-image-iso-test-vm';
const IMAGE_NAME = generateName('auto-image-iso-upload-test');
const VM_NAME = generateName('auto-image-iso-test-vm');

it('Create a ISO image via upload', () => {
cy.login();
Expand Down

0 comments on commit 8585d05

Please sign in to comment.