-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-132335 / 25.04 / Adding disks to containers (#11022)
- Loading branch information
Showing
119 changed files
with
1,429 additions
and
876 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
21 changes: 21 additions & 0 deletions
21
.../virtualization/components/all-instances/instance-details/instance-details.component.html
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 |
---|---|---|
@@ -1,9 +1,30 @@ | ||
<div class="header"> | ||
<h3 class="title"> | ||
<div class="mobile-prefix"> | ||
<ix-mobile-back-button | ||
(onClose)="onCloseMobileDetails()" | ||
></ix-mobile-back-button> | ||
{{ 'Details for' | translate }} | ||
</div> | ||
|
||
<span class="prefix"> | ||
{{ 'Details for' | translate }} | ||
</span> | ||
|
||
<span class="name"> | ||
{{ instance().name }} | ||
</span> | ||
</h3> | ||
</div> | ||
|
||
<div class="cards"> | ||
<div class="scroll-window"> | ||
<ix-instance-general-info [instance]="instance()"></ix-instance-general-info> | ||
|
||
<ix-instance-devices></ix-instance-devices> | ||
|
||
<ix-instance-disks></ix-instance-disks> | ||
|
||
<ix-instance-proxies></ix-instance-proxies> | ||
</div> | ||
</div> |
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
59 changes: 59 additions & 0 deletions
59
...rtualization/components/all-instances/instance-details/instance-details.component.spec.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,59 @@ | ||
import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; | ||
import { MockComponents } from 'ng-mocks'; | ||
import { VirtualizationInstance } from 'app/interfaces/virtualization.interface'; | ||
import { | ||
InstanceDetailsComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-details.component'; | ||
import { | ||
InstanceDevicesComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-devices/instance-devices.component'; | ||
import { | ||
InstanceDisksComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-disks/instance-disks.component'; | ||
import { | ||
InstanceGeneralInfoComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-general-info/instance-general-info.component'; | ||
import { | ||
InstanceProxiesComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-proxies/instance-proxies.component'; | ||
import { VirtualizationInstancesStore } from 'app/pages/virtualization/stores/virtualization-instances.store'; | ||
|
||
describe('InstanceDetailsComponent', () => { | ||
let spectator: Spectator<InstanceDetailsComponent>; | ||
const createComponent = createComponentFactory({ | ||
component: InstanceDetailsComponent, | ||
imports: [ | ||
MockComponents( | ||
InstanceGeneralInfoComponent, | ||
InstanceDevicesComponent, | ||
InstanceDisksComponent, | ||
InstanceProxiesComponent, | ||
), | ||
], | ||
providers: [ | ||
mockProvider(VirtualizationInstancesStore), | ||
], | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent({ | ||
props: { | ||
instance: { | ||
name: 'my-instance', | ||
} as VirtualizationInstance, | ||
}, | ||
}); | ||
}); | ||
|
||
it('shows name of the selected instance', () => { | ||
expect(spectator.query('.title')).toHaveText('Details for'); | ||
expect(spectator.query('.title')).toHaveText('my-instance'); | ||
}); | ||
|
||
it('shows details sub-components related to selected instance', () => { | ||
expect(spectator.query(InstanceGeneralInfoComponent)).toExist(); | ||
expect(spectator.query(InstanceDevicesComponent)).toExist(); | ||
expect(spectator.query(InstanceDisksComponent)).toExist(); | ||
expect(spectator.query(InstanceProxiesComponent)).toExist(); | ||
}); | ||
}); |
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
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
71 changes: 30 additions & 41 deletions
71
...onents/all-instances/instance-details/instance-devices/instance-devices.component.spec.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 |
---|---|---|
@@ -1,72 +1,61 @@ | ||
import { HarnessLoader } from '@angular/cdk/testing'; | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; | ||
import { of } from 'rxjs'; | ||
import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils'; | ||
import { MockComponent } from 'ng-mocks'; | ||
import { VirtualizationDeviceType } from 'app/enums/virtualization.enum'; | ||
import { VirtualizationProxy, VirtualizationUsb } from 'app/interfaces/virtualization.interface'; | ||
import { DialogService } from 'app/modules/dialog/dialog.service'; | ||
import { IxIconHarness } from 'app/modules/ix-icon/ix-icon.harness'; | ||
import { SnackbarService } from 'app/modules/snackbar/services/snackbar.service'; | ||
import { | ||
InstanceDevicesComponent, | ||
} from 'app/pages/virtualization/components/all-instances/instance-details/instance-devices/instance-devices.component'; | ||
import { | ||
DeleteDeviceButtonComponent, | ||
} from 'app/pages/virtualization/components/common/delete-device-button/delete-device-button.component'; | ||
import { VirtualizationInstancesStore } from 'app/pages/virtualization/stores/virtualization-instances.store'; | ||
import { ApiService } from 'app/services/api.service'; | ||
|
||
describe('InstanceDevicesComponent', () => { | ||
let spectator: Spectator<InstanceDevicesComponent>; | ||
let loader: HarnessLoader; | ||
const devices = [ | ||
{ | ||
dev_type: VirtualizationDeviceType.Usb, | ||
name: 'usb1', | ||
} as VirtualizationUsb, | ||
{ | ||
dev_type: VirtualizationDeviceType.Gpu, | ||
name: 'gpu1', | ||
}, | ||
{ | ||
name: 'proxy2', | ||
} as VirtualizationProxy, | ||
]; | ||
|
||
const createComponent = createComponentFactory({ | ||
component: InstanceDevicesComponent, | ||
imports: [ | ||
MockComponent(DeleteDeviceButtonComponent), | ||
], | ||
providers: [ | ||
mockProvider(DialogService, { | ||
confirm: jest.fn(() => of(true)), | ||
}), | ||
mockApi([ | ||
mockCall('virt.instance.device_delete'), | ||
]), | ||
mockProvider(SnackbarService), | ||
mockProvider(VirtualizationInstancesStore, { | ||
isLoadingDevices: () => false, | ||
selectedInstance: () => ({ id: 'my-instance' }), | ||
selectedInstanceDevices: () => [ | ||
{ | ||
dev_type: VirtualizationDeviceType.Usb, | ||
name: 'usb1', | ||
} as VirtualizationUsb, | ||
{ | ||
dev_type: VirtualizationDeviceType.Gpu, | ||
name: 'gpu1', | ||
}, | ||
{ | ||
name: 'proxy2', | ||
} as VirtualizationProxy, | ||
], | ||
selectedInstanceDevices: () => devices, | ||
loadDevices: jest.fn(), | ||
}), | ||
], | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent(); | ||
loader = TestbedHarnessEnvironment.loader(spectator.fixture); | ||
}); | ||
|
||
it('shows a list of USB or GPU devices', () => { | ||
const devices = spectator.queryAll('.device'); | ||
const deviceRows = spectator.queryAll('.device'); | ||
|
||
expect(devices).toHaveLength(2); | ||
expect(devices[0]).toHaveText('usb1'); | ||
expect(devices[1]).toHaveText('gpu1'); | ||
expect(deviceRows).toHaveLength(2); | ||
expect(deviceRows[0]).toHaveText('usb1'); | ||
expect(deviceRows[1]).toHaveText('gpu1'); | ||
}); | ||
|
||
it('deletes a device with confirmation and reloads the list when delete icon is pressed', async () => { | ||
const deleteIcon = await loader.getHarness(IxIconHarness.with({ name: 'mdi-close' })); | ||
await deleteIcon.click(); | ||
|
||
expect(spectator.inject(DialogService).confirm).toHaveBeenCalled(); | ||
expect(spectator.inject(ApiService).call).toHaveBeenCalledWith('virt.instance.device_delete', ['my-instance', 'usb1']); | ||
expect(spectator.inject(VirtualizationInstancesStore).loadDevices).toHaveBeenCalled(); | ||
it('renders a button to delete the device', () => { | ||
const deleteButtons = spectator.queryAll(DeleteDeviceButtonComponent); | ||
expect(deleteButtons).toHaveLength(2); | ||
expect(deleteButtons[0].device).toBe(devices[0]); | ||
}); | ||
}); |
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
Oops, something went wrong.