-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
frontend/packages/kubevirt-plugin/integration-tests/tests/vm.dashboard.scenario.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { browser, ExpectedConditions as until } from 'protractor'; | ||
import { testName } from '@console/internal-integration-tests/protractor.conf'; | ||
import { | ||
addLeakableResource, | ||
createResources, | ||
removeLeakedResources, | ||
} from '@console/shared/src/test-utils/utils'; | ||
import { VirtualMachineModel } from '../../src/models'; | ||
import { | ||
vmDetailsName, | ||
vmDetailsNamespace, | ||
vmDetailsNode, | ||
vmDetailsIPAddress, | ||
vmStatus, | ||
vmInventoryNICs, | ||
vmInventoryDisks, | ||
} from '../views/dashboard.view'; | ||
import { getVMManifest, hddDisk, multusNetworkInterface, multusNAD } from './utils/mocks'; | ||
import { VirtualMachine } from './models/virtualMachine'; | ||
import { | ||
VM_STATUS, | ||
VM_BOOTUP_TIMEOUT_SECS, | ||
VM_ACTION, | ||
VM_IMPORT_TIMEOUT_SECS, | ||
TAB, | ||
VM_STOP_TIMEOUT_SECS, | ||
NOT_AVAILABLE, | ||
PAGE_LOAD_TIMEOUT_SECS, | ||
} from './utils/consts'; | ||
|
||
describe('Test VM dashboard', () => { | ||
const leakedResources = new Set<string>(); | ||
const testVM = getVMManifest('URL', testName, null, 'foo'); | ||
|
||
let vm: VirtualMachine; | ||
|
||
afterAll(async () => { | ||
removeLeakedResources(leakedResources); | ||
}); | ||
|
||
beforeAll(async () => { | ||
createResources([multusNAD, testVM]); | ||
addLeakableResource(leakedResources, testVM); | ||
vm = new VirtualMachine(testVM.metadata); | ||
await vm.navigateToDashboard(); | ||
try { | ||
await browser.wait( | ||
until.not(until.textToBePresentInElement(vmStatus, VM_STATUS.Off)), | ||
PAGE_LOAD_TIMEOUT_SECS, | ||
); | ||
} catch (ex) { | ||
// continue, this is optional condition | ||
// we want to wait for import to start but in some cases it may have already completed | ||
} | ||
await browser.wait( | ||
until.textToBePresentInElement(vmStatus, VM_STATUS.Off), | ||
VM_IMPORT_TIMEOUT_SECS, | ||
); | ||
}, VM_IMPORT_TIMEOUT_SECS); | ||
|
||
it('Inventory card', async () => { | ||
expect(vmInventoryNICs.getText()).toEqual('1 NIC'); | ||
expect(vmInventoryNICs.$('a').getAttribute('href')).toMatch( | ||
new RegExp(`.*/k8s/ns/${vm.namespace}/${VirtualMachineModel.plural}/${vm.name}/nics`), | ||
); | ||
expect(vmInventoryDisks.getText()).toEqual('2 Disks'); | ||
expect(vmInventoryDisks.$('a').getAttribute('href')).toMatch( | ||
new RegExp(`.*/k8s/ns/${vm.namespace}/${VirtualMachineModel.plural}/${vm.name}/disks`), | ||
); | ||
|
||
await vm.addDisk(hddDisk); | ||
await vm.addNIC(multusNetworkInterface); | ||
await vm.navigateToTab(TAB.Dashboard); | ||
|
||
expect(vmInventoryNICs.getText()).toEqual('2 NICs'); | ||
expect(vmInventoryDisks.getText()).toEqual('3 Disks'); | ||
}); | ||
|
||
it('Status card', async () => { | ||
expect(vmStatus.getText()).toEqual(VM_STATUS.Off); | ||
|
||
await vm.action(VM_ACTION.Start, true, VM_BOOTUP_TIMEOUT_SECS); | ||
await vm.navigateToTab(TAB.Dashboard); | ||
|
||
expect(vmStatus.getText()).toEqual(VM_STATUS.Running); | ||
}); | ||
|
||
it('Details card', async () => { | ||
expect(vmDetailsName.getText()).toEqual(vm.name); | ||
expect(vmDetailsNamespace.getText()).toEqual(vm.namespace); | ||
expect(vmDetailsNode.getText()).not.toEqual(NOT_AVAILABLE); | ||
expect(vmDetailsIPAddress.getText()).not.toEqual(NOT_AVAILABLE); | ||
|
||
await vm.action(VM_ACTION.Stop, true, VM_STOP_TIMEOUT_SECS); | ||
await vm.navigateToTab(TAB.Dashboard); | ||
|
||
expect(vmDetailsNode.getText()).toEqual(NOT_AVAILABLE); | ||
expect(vmDetailsIPAddress.getText()).toEqual(NOT_AVAILABLE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
frontend/packages/kubevirt-plugin/integration-tests/views/dashboard.view.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { $, $$ } from 'protractor'; | ||
|
||
export const vmDetails = $$('.co-details-card__body dd'); | ||
export const vmDetailsName = vmDetails.get(0); | ||
export const vmDetailsNamespace = vmDetails.get(1).$('.co-resource-item__resource-name'); | ||
export const vmDetailsCreated = vmDetails.get(2); | ||
export const vmDetailsNode = vmDetails.get(3); | ||
export const vmDetailsIPAddress = vmDetails.get(4); | ||
|
||
export const vmStatus = $('.co-status-card__health-body > span'); | ||
|
||
export const vmInventoryItems = $$('.co-inventory-card__item'); | ||
export const vmInventoryNICs = vmInventoryItems.get(0); | ||
export const vmInventoryDisks = vmInventoryItems.get(1); |