mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-09 17:06:13 -06:00
test(web): seed the pool of the V2V list through one helper
- `seedV2vListPool` seeds the pool of the list and its offers, in place of the same two lines in the VMs step, selected VMs and mapping step tests - the resumed VM is imported to the pool of the list: `V2V_RESUMED_VM_POOL` is gone - the network and template of the other pool get their own ids, apart from the list defaults
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -7,13 +7,14 @@ import { createGlobalTestConfig } from '@/test/global-test-config.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { vmDeviceCollectionsMock } from '@/test/mock-xo-vm-device-collections.ts'
|
||||
import { mountOnV2vWizard } from '@/test/mount-on-v2v-wizard.ts'
|
||||
import { seedV2vResumedVmCollections, V2V_RESUMED_VM_POOL } from '@/test/seed-v2v-resumed-vm.ts'
|
||||
import { seedV2vResumedVmCollections } from '@/test/seed-v2v-resumed-vm.ts'
|
||||
import {
|
||||
V2V_ACTIVE_DISK_ROWS,
|
||||
V2V_ACTIVE_NIC_ROWS,
|
||||
V2V_MAPPING_INVENTORY,
|
||||
V2V_RESUMED_IMPORT_VM,
|
||||
} from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import { mount } from '@vue/test-utils'
|
||||
|
||||
vi.mock(
|
||||
@@ -71,10 +72,7 @@ beforeEach(() => {
|
||||
it('shows the import VM on the pool it was synced to', async () => {
|
||||
const card = (await mountCards()).getComponent(V2vDestinationVmCard)
|
||||
|
||||
expect([card.props('vm').id, card.props('poolName')]).toEqual([
|
||||
V2V_RESUMED_IMPORT_VM.id,
|
||||
V2V_RESUMED_VM_POOL.name_label,
|
||||
])
|
||||
expect([card.props('vm').id, card.props('poolName')]).toEqual([V2V_RESUMED_IMPORT_VM.id, V2V_LIST_POOL.name_label])
|
||||
})
|
||||
|
||||
it('tells the next run, since the last sync', async () => {
|
||||
@@ -87,7 +85,7 @@ it('shows the mapping of the first sync, locked on the pool', async () => {
|
||||
const card = (await mountCards()).getComponent(V2vActiveMappingCard)
|
||||
|
||||
expect(card.props()).toEqual({
|
||||
poolName: V2V_RESUMED_VM_POOL.name_label,
|
||||
poolName: V2V_LIST_POOL.name_label,
|
||||
diskRows: V2V_ACTIVE_DISK_ROWS,
|
||||
nicRows: V2V_ACTIVE_NIC_ROWS,
|
||||
loading: false,
|
||||
|
||||
@@ -19,7 +19,7 @@ import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { v2vVmRowsCollectionsMock } from '@/test/mock-xo-v2v-vm-rows-collections.ts'
|
||||
import { mountOnV2vWizard } from '@/test/mount-on-v2v-wizard.ts'
|
||||
import { mountV2vVmsStep } from '@/test/mount-v2v-vms-step.ts'
|
||||
import { V2V_DEFAULT_OFFERS } from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { seedV2vListPool } from '@/test/seed-v2v-list-pool.ts'
|
||||
import { readV2vMigrationListStorage } from '@/test/v2v-migration-list-storage.ts'
|
||||
import {
|
||||
V2V_DATASTORE_B,
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
V2V_VMS_INVENTORY,
|
||||
V2V_WEB_VM,
|
||||
} from '@/test/v2v-vms-fixtures.ts'
|
||||
import { V2V_EMPTY_LIST, V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import { V2V_EMPTY_LIST } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import VtsContentSidePanel from '@core/components/layout/VtsContentSidePanel.vue'
|
||||
import VtsQueryBuilder from '@core/components/query-builder/VtsQueryBuilder.vue'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
@@ -73,8 +73,7 @@ async function mountStep({
|
||||
list = V2V_LIST_WITH_LISTED_VM,
|
||||
filter,
|
||||
}: { list?: V2vMigrationList; filter?: string } = {}) {
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL]
|
||||
xoCollectionsMock.seedChoices(V2V_DEFAULT_OFFERS)
|
||||
seedV2vListPool()
|
||||
|
||||
const { mounted: wrapper, router } = await mountOnV2vWizard(
|
||||
(router, provide) =>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { createV2vVm } from '@/test/create-v2v-inventory.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { vmDeviceCollectionsMock } from '@/test/mock-xo-vm-device-collections.ts'
|
||||
import { mountComposableWithI18n } from '@/test/mount-composable.ts'
|
||||
import { seedV2vResumedVmCollections, V2V_RESUMED_VM_POOL } from '@/test/seed-v2v-resumed-vm.ts'
|
||||
import { seedV2vResumedVmCollections } from '@/test/seed-v2v-resumed-vm.ts'
|
||||
import { createConnectedV2vContext, v2vConnectionProvide } from '@/test/v2v-connection-provide.ts'
|
||||
import {
|
||||
V2V_ACTIVE_DISK_ROWS,
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
V2V_SYNCED_VM,
|
||||
V2V_VLAN_NETWORK,
|
||||
} from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import { objectIcon } from '@core/icons'
|
||||
import type { XoV2vVm } from '@vates/types'
|
||||
|
||||
@@ -73,7 +74,7 @@ describe('destinationVm', () => {
|
||||
|
||||
describe('poolName', () => {
|
||||
it('names the pool of the import VM', () => {
|
||||
expect(mountResumedVm().poolName).toBe(V2V_RESUMED_VM_POOL.name_label)
|
||||
expect(mountResumedVm().poolName).toBe(V2V_LIST_POOL.name_label)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ import { deleteModalMock } from '@/test/mock-delete-modal.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { v2vVmRowsCollectionsMock } from '@/test/mock-xo-v2v-vm-rows-collections.ts'
|
||||
import { mountV2vVmsStep } from '@/test/mount-v2v-vms-step.ts'
|
||||
import { V2V_DEFAULT_OFFERS, V2V_DEFAULT_SR, V2V_SSD_SR } from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { seedV2vListPool } from '@/test/seed-v2v-list-pool.ts'
|
||||
import { V2V_DEFAULT_SR, V2V_SSD_SR } from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { readV2vMigrationListStorage } from '@/test/v2v-migration-list-storage.ts'
|
||||
import { V2V_DB_VM, V2V_LISTED_VM, V2V_RDM_VM, V2V_WEB_VM } from '@/test/v2v-vms-fixtures.ts'
|
||||
import { V2V_EMPTY_LIST, V2V_LIST_POOL, V2V_OTHER_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
@@ -75,8 +76,8 @@ async function mountSelectedVms({
|
||||
poolId = V2V_LIST_POOL.id,
|
||||
selectedVmId,
|
||||
}: { list?: V2vMigrationList | null; poolId?: FrontXoPool['id'] | null; selectedVmId?: XoV2vVm['id'] } = {}) {
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL, V2V_OTHER_POOL]
|
||||
xoCollectionsMock.seedChoices(V2V_DEFAULT_OFFERS)
|
||||
seedV2vListPool()
|
||||
xoCollectionsMock.pools.value.push(V2V_OTHER_POOL)
|
||||
v2vVmRowsCollectionsMock.vms.value = IMPORT_VMS
|
||||
|
||||
return mountV2vVmsStep(
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import type { FrontXoNetwork } from '@/modules/network/remote-resources/use-xo-network-collection.ts'
|
||||
import type { FrontXoSr } from '@/modules/storage-repository/remote-resources/use-xo-sr-collection.ts'
|
||||
import { useV2vMigrationList } from '@/modules/v2v/composables/use-v2v-migration-list.composable.ts'
|
||||
import type { V2vMigrationList, V2vMigrationListVm } from '@/modules/v2v/types/v2v-migration-list.type.ts'
|
||||
import type { FrontXoVmTemplate } from '@/modules/vm/remote-resources/use-xo-vm-template-collection.ts'
|
||||
import { createNetwork } from '@/test/create-network.ts'
|
||||
import { OTHER_POOL_ID } from '@/test/create-pool.ts'
|
||||
import { createSr } from '@/test/create-sr.ts'
|
||||
import { createV2vMigrationList, createV2vMigrationListVm } from '@/test/create-v2v-migration-list.ts'
|
||||
import { createVmTemplate } from '@/test/create-vm-template.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { mountComposableWithI18n } from '@/test/mount-composable.ts'
|
||||
import { mountOnV2vWizard } from '@/test/mount-on-v2v-wizard.ts'
|
||||
import { seedV2vListPool } from '@/test/seed-v2v-list-pool.ts'
|
||||
import { createConnectedV2vContext, v2vConnectionProvide } from '@/test/v2v-connection-provide.ts'
|
||||
import {
|
||||
V2V_DEBIAN_TEMPLATE,
|
||||
@@ -45,11 +47,16 @@ export const V2V_OTHER_LIST_VM = createV2vMigrationListVm({
|
||||
|
||||
// Stores the list holding `listVm`, on a pool offering the mapping fixtures (another pool offers one target of each kind)
|
||||
function seedV2vVmMappingList(listVm: V2vMigrationListVm) {
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL]
|
||||
xoCollectionsMock.seedChoices({
|
||||
seedV2vListPool({
|
||||
srs: [...V2V_POOL_OFFERS.srs, createSr({ id: 'sr-other' as FrontXoSr['id'], $pool: OTHER_POOL_ID })],
|
||||
networks: [...V2V_POOL_OFFERS.networks, createNetwork({ $pool: OTHER_POOL_ID })],
|
||||
templates: [...V2V_POOL_OFFERS.templates, createVmTemplate({ $pool: OTHER_POOL_ID })],
|
||||
networks: [
|
||||
...V2V_POOL_OFFERS.networks,
|
||||
createNetwork({ id: 'network-other' as FrontXoNetwork['id'], $pool: OTHER_POOL_ID }),
|
||||
],
|
||||
templates: [
|
||||
...V2V_POOL_OFFERS.templates,
|
||||
createVmTemplate({ id: 'template-other' as FrontXoVmTemplate['id'], $pool: OTHER_POOL_ID }),
|
||||
],
|
||||
})
|
||||
|
||||
const list = createV2vMigrationList({ poolId: V2V_LIST_POOL.id, vms: [listVm] })
|
||||
|
||||
10
@xen-orchestra/web/src/test/seed-v2v-list-pool.ts
Normal file
10
@xen-orchestra/web/src/test/seed-v2v-list-pool.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { V2vPoolDestinationChoices } from '@/modules/v2v/utils/v2v-destination.util.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { V2V_DEFAULT_OFFERS } from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
|
||||
// The pool of the list, offering its VMs `offers`, in the mocked destination collections
|
||||
export function seedV2vListPool(offers: V2vPoolDestinationChoices = V2V_DEFAULT_OFFERS) {
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL]
|
||||
xoCollectionsMock.seedChoices(offers)
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
import { createPool } from '@/test/create-pool.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { vmDeviceCollectionsMock } from '@/test/mock-xo-vm-device-collections.ts'
|
||||
import { seedV2vListPool } from '@/test/seed-v2v-list-pool.ts'
|
||||
import {
|
||||
V2V_DEFAULT_NETWORK,
|
||||
V2V_RESUMED_IMPORT_VM,
|
||||
V2V_SSD_SR,
|
||||
V2V_SYNCED_VBD,
|
||||
V2V_SYNCED_VDI,
|
||||
@@ -11,14 +9,10 @@ import {
|
||||
V2V_VLAN_NETWORK,
|
||||
} from '@/test/v2v-mapping-fixtures.ts'
|
||||
|
||||
export const V2V_RESUMED_VM_POOL = createPool({ id: V2V_RESUMED_IMPORT_VM.$pool })
|
||||
|
||||
// The pool, the targets and the devices the first sync of the resumed VM left in XO, read through the mocked
|
||||
// destination and VM device collections
|
||||
// The pool of the list, the targets and the devices the first sync of the resumed VM left in XO, read through the
|
||||
// mocked destination and VM device collections
|
||||
export function seedV2vResumedVmCollections() {
|
||||
xoCollectionsMock.pools.value = [V2V_RESUMED_VM_POOL]
|
||||
xoCollectionsMock.srs.value = [V2V_SSD_SR]
|
||||
xoCollectionsMock.networks.value = [V2V_DEFAULT_NETWORK, V2V_VLAN_NETWORK]
|
||||
seedV2vListPool({ srs: [V2V_SSD_SR], networks: [V2V_DEFAULT_NETWORK, V2V_VLAN_NETWORK], templates: [] })
|
||||
vmDeviceCollectionsMock.vbds.value = [V2V_SYNCED_VBD]
|
||||
vmDeviceCollectionsMock.vdis.value = [V2V_SYNCED_VDI]
|
||||
vmDeviceCollectionsMock.vifs.value = V2V_SYNCED_VIFS
|
||||
|
||||
@@ -30,6 +30,7 @@ import { createVdi } from '@/test/create-vdi.ts'
|
||||
import { createVif } from '@/test/create-vif.ts'
|
||||
import { createVmTemplate } from '@/test/create-vm-template.ts'
|
||||
import { t } from '@/test/i18n.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import { V2V_VDI_OTHER_CONFIG, V2V_VM_OTHER_CONFIG, VM_POWER_STATE, type XoV2vDisk, type XoV2vNic } from '@vates/types'
|
||||
|
||||
const DEFAULTS = createV2vDestinationDefaults()
|
||||
@@ -186,6 +187,7 @@ export const V2V_RESUMED_IMPORT_VM = createV2vImportVm(
|
||||
{
|
||||
name_label: 'app-03',
|
||||
power_state: VM_POWER_STATE.HALTED,
|
||||
$pool: V2V_LIST_POOL.id,
|
||||
$VBDs: [V2V_SYNCED_VBD.id],
|
||||
VIFs: V2V_SYNCED_VIFS.map(vif => vif.id),
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createV2vImportVm, createV2vPartialImportSnapshot } from '@/test/create-v2v-import-vm.ts'
|
||||
import { createV2vDatacenter, createV2vHost } from '@/test/create-v2v-inventory.ts'
|
||||
import { createV2vMigrationList } from '@/test/create-v2v-migration-list.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { v2vVmRowsCollectionsMock } from '@/test/mock-xo-v2v-vm-rows-collections.ts'
|
||||
import { V2V_DEFAULT_OFFERS } from '@/test/v2v-mapping-fixtures.ts'
|
||||
import { seedV2vListPool } from '@/test/seed-v2v-list-pool.ts'
|
||||
import { V2V_DB_VM, V2V_VMS_INVENTORY, V2V_WEB_VM } from '@/test/v2v-vms-fixtures.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import type { XoV2vVm } from '@vates/types'
|
||||
@@ -34,8 +33,7 @@ export const V2V_DB_SYNC_SNAPSHOT = createV2vPartialImportSnapshot()
|
||||
|
||||
// The pool of the list offers its defaults; the DB VM was synced once to it
|
||||
export function seedV2vMappingStepCollections() {
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL]
|
||||
xoCollectionsMock.seedChoices(V2V_DEFAULT_OFFERS)
|
||||
seedV2vListPool()
|
||||
v2vVmRowsCollectionsMock.vms.value = [V2V_DB_IMPORT_VM]
|
||||
v2vVmRowsCollectionsMock.snapshots.value = [V2V_DB_SYNC_SNAPSHOT]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user