mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-09 17:06:13 -06:00
test(web): read the V2V list pool and pair from the shared fixtures
This commit is contained in:
@@ -35,7 +35,7 @@ const EMPTY = {
|
||||
count: 0,
|
||||
isEmpty: true,
|
||||
readinessTags: [],
|
||||
listPair: createV2vListPair(),
|
||||
listPair: LIST_PAIR,
|
||||
}
|
||||
|
||||
function mountPanel(props: Partial<ComponentProps<typeof V2vSelectedVmsPanel>> = {}) {
|
||||
|
||||
@@ -6,9 +6,9 @@ import V2vVmsTable from '@/modules/v2v/components/vms/V2vVmsTable.vue'
|
||||
import { useV2vVmsStep } from '@/modules/v2v/composables/use-v2v-vms-step.composable.ts'
|
||||
import type { V2vMigrationList } from '@/modules/v2v/types/v2v-migration-list.type.ts'
|
||||
import { applyV2vPreset, V2V_VM_PRESETS } from '@/modules/v2v/utils/v2v-vm-presets.util.ts'
|
||||
import { createPool } from '@/test/create-pool.ts'
|
||||
import { createV2vConnection } from '@/test/create-v2v-connection.ts'
|
||||
import { createV2vMigrationList } from '@/test/create-v2v-migration-list.ts'
|
||||
import { createV2vListPair } from '@/test/create-v2v-selected-vms.ts'
|
||||
import { getV2vVmIds, getV2vVmNames } from '@/test/create-v2v-vm-row.ts'
|
||||
import { getV2vVmsQuery } from '@/test/create-v2v-wizard-router.ts'
|
||||
import { findButton, getButton, getUiButton } from '@/test/get-button.ts'
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
V2V_VMS_INVENTORY,
|
||||
V2V_WEB_VM,
|
||||
} from '@/test/v2v-vms-fixtures.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import VtsContentSidePanel from '@core/components/layout/VtsContentSidePanel.vue'
|
||||
import VtsQueryBuilder from '@core/components/query-builder/VtsQueryBuilder.vue'
|
||||
import { usePanelStore } from '@core/stores/panel.store.ts'
|
||||
@@ -62,8 +63,6 @@ const LIST = createV2vMigrationList({ vms: [{ id: V2V_LISTED_VM.id }] })
|
||||
|
||||
const EMPTY_LIST = createV2vMigrationList()
|
||||
|
||||
const POOL = createPool({ id: LIST.poolId })
|
||||
|
||||
const DATASTORE_B_AND_NAME_FILTER = `${V2V_DATASTORE_B_FILTER} name:${V2V_LISTED_VM.name}`
|
||||
|
||||
const SOURCE_HOST = createV2vConnection().host
|
||||
@@ -72,7 +71,7 @@ const SHOW_PANEL_LABEL = t('selected-vms-n', { n: LIST.vms.length })
|
||||
|
||||
// The children render what the step hands them, each covered by its own test: here only the wiring matters
|
||||
async function mountStep({ list = LIST, filter }: { list?: V2vMigrationList; filter?: string } = {}) {
|
||||
xoCollectionsMock.pools.value = [POOL]
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL]
|
||||
|
||||
const { mounted: wrapper, router } = await mountOnV2vWizard(
|
||||
(router, provide) =>
|
||||
@@ -257,7 +256,7 @@ describe('selected VMs', () => {
|
||||
isEmpty: false,
|
||||
isBusy: false,
|
||||
readinessTags: [{ label: t('n-ready', { n: 1 }), accent: 'success' }],
|
||||
listPair: { sourceHost: SOURCE_HOST, poolName: POOL.name_label },
|
||||
listPair: createV2vListPair(),
|
||||
})
|
||||
expect(findPanelItemIds(wrapper)).toEqual([V2V_LISTED_VM.id])
|
||||
})
|
||||
|
||||
@@ -5,11 +5,11 @@ import { useV2vVmsStep } from '@/modules/v2v/composables/use-v2v-vms-step.compos
|
||||
import type { V2vMigrationList } from '@/modules/v2v/types/v2v-migration-list.type.ts'
|
||||
import type { FrontXoVm } from '@/modules/vm/remote-resources/use-xo-vm-collection.ts'
|
||||
import { createNetwork } from '@/test/create-network.ts'
|
||||
import { createPool, DISKOR_POOL_NAME, OTHER_POOL_ID } from '@/test/create-pool.ts'
|
||||
import { createPool, OTHER_POOL_ID } from '@/test/create-pool.ts'
|
||||
import { createSr } from '@/test/create-sr.ts'
|
||||
import { createV2vConnection } from '@/test/create-v2v-connection.ts'
|
||||
import { createV2vImportVm } from '@/test/create-v2v-import-vm.ts'
|
||||
import { createV2vMigrationList } from '@/test/create-v2v-migration-list.ts'
|
||||
import { createV2vListPair } from '@/test/create-v2v-selected-vms.ts'
|
||||
import { getV2vVmIds } from '@/test/create-v2v-vm-row.ts'
|
||||
import { deleteModalMock } from '@/test/mock-delete-modal.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
@@ -17,6 +17,7 @@ import { v2vVmRowsCollectionsMock } from '@/test/mock-xo-v2v-vm-rows-collections
|
||||
import { mountV2vVmsStep } from '@/test/mount-v2v-vms-step.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_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import type { XoV2vVm } from '@vates/types'
|
||||
|
||||
vi.mock(
|
||||
@@ -51,8 +52,6 @@ const EMPTY_LIST = createV2vMigrationList()
|
||||
|
||||
const LIST_IDS = getV2vVmIds(LIST.vms)
|
||||
|
||||
const POOL = createPool({ id: LIST.poolId, name_label: DISKOR_POOL_NAME })
|
||||
|
||||
const OTHER_POOL = createPool({ id: OTHER_POOL_ID, name_label: 'pool other' })
|
||||
|
||||
const SR = createSr({ id: LIST.defaults.sr, name_label: 'sr-nvme-01' })
|
||||
@@ -68,15 +67,18 @@ const WEB_AND_DB_LIST = createV2vMigrationList({ vms: [{ id: V2V_WEB_VM.id }, {
|
||||
|
||||
// The DB VM is warm synced on the pool of the list, the listed one migrated
|
||||
const IMPORT_VMS = [
|
||||
createV2vImportVm({ isWarm: true, sourceVmId: V2V_DB_VM.id }, { id: 'xo-vm-db' as FrontXoVm['id'], $pool: POOL.id }),
|
||||
createV2vImportVm(
|
||||
{ isWarm: true, sourceVmId: V2V_DB_VM.id },
|
||||
{ id: 'xo-vm-db' as FrontXoVm['id'], $pool: V2V_LIST_POOL.id }
|
||||
),
|
||||
createV2vImportVm({ isWarm: false, sourceVmId: V2V_LISTED_VM.id }, { id: 'xo-vm-listed' as FrontXoVm['id'] }),
|
||||
]
|
||||
|
||||
async function mountSelectedVms({
|
||||
list = LIST,
|
||||
poolId = POOL.id,
|
||||
poolId = V2V_LIST_POOL.id,
|
||||
}: { list?: V2vMigrationList | null; poolId?: FrontXoPool['id'] | null } = {}) {
|
||||
xoCollectionsMock.pools.value = [POOL, OTHER_POOL]
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL, OTHER_POOL]
|
||||
xoCollectionsMock.srs.value = [SR]
|
||||
xoCollectionsMock.networks.value = [NETWORK]
|
||||
v2vVmRowsCollectionsMock.vms.value = IMPORT_VMS
|
||||
@@ -177,7 +179,7 @@ describe('items', () => {
|
||||
|
||||
expect(router.resolve(result.items[0].mappingRoute).query).toEqual({
|
||||
step: 'mapping',
|
||||
pool: POOL.id,
|
||||
pool: V2V_LIST_POOL.id,
|
||||
vm: V2V_WEB_VM.id,
|
||||
})
|
||||
})
|
||||
@@ -268,7 +270,7 @@ describe('listPair', () => {
|
||||
it('names the source and the pool of the list', async () => {
|
||||
const { result } = await mountSelectedVms()
|
||||
|
||||
expect(result.listPair).toEqual({ sourceHost: createV2vConnection().host, poolName: POOL.name_label })
|
||||
expect(result.listPair).toEqual(createV2vListPair())
|
||||
})
|
||||
|
||||
it('names no pool while the pools load', async () => {
|
||||
@@ -284,7 +286,7 @@ describe('listPair', () => {
|
||||
it('names no pool before one is chosen', async () => {
|
||||
const { result } = await mountSelectedVms({ poolId: null })
|
||||
|
||||
expect(result.listPair).toEqual({ sourceHost: createV2vConnection().host, poolName: undefined })
|
||||
expect(result.listPair).toEqual(createV2vListPair({ poolName: undefined }))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { createV2vConnection } from '@/test/create-v2v-connection.ts'
|
||||
import { xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { mountComposable } from '@/test/mount-composable.ts'
|
||||
import { createConnectedV2vContext, v2vConnectionProvide } from '@/test/v2v-connection-provide.ts'
|
||||
import { V2V_LIST_POOL } from '@/test/v2v-wizard-fixtures.ts'
|
||||
import { ref } from 'vue'
|
||||
|
||||
vi.mock(
|
||||
@@ -12,17 +13,15 @@ vi.mock(
|
||||
() => import('@/test/mock-xo-collections.ts')
|
||||
)
|
||||
|
||||
const POOL = createPool({ name_label: DISKOR_POOL_NAME })
|
||||
|
||||
const OTHER_POOL = createPool({ id: OTHER_POOL_ID, name_label: 'pool other' })
|
||||
|
||||
const CONNECTION = createV2vConnection()
|
||||
|
||||
function mountSourceAndDestination(
|
||||
poolId = ref<FrontXoPool['id'] | undefined>(POOL.id),
|
||||
poolId = ref<FrontXoPool['id'] | undefined>(V2V_LIST_POOL.id),
|
||||
{ isConnected = true }: { isConnected?: boolean } = {}
|
||||
) {
|
||||
xoCollectionsMock.pools.value = [POOL, OTHER_POOL]
|
||||
xoCollectionsMock.pools.value = [V2V_LIST_POOL, OTHER_POOL]
|
||||
|
||||
return mountComposable(() => useV2vSourceAndDestination(poolId), {
|
||||
provide: v2vConnectionProvide(isConnected ? createConnectedV2vContext({ connection: CONNECTION }) : undefined),
|
||||
@@ -49,7 +48,7 @@ describe('poolName', () => {
|
||||
})
|
||||
|
||||
it('follows the pool', () => {
|
||||
const poolId = ref<FrontXoPool['id'] | undefined>(POOL.id)
|
||||
const poolId = ref<FrontXoPool['id'] | undefined>(V2V_LIST_POOL.id)
|
||||
const result = mountSourceAndDestination(poolId)
|
||||
|
||||
poolId.value = OTHER_POOL.id
|
||||
|
||||
@@ -4,9 +4,10 @@ import { getV2vMappingSummary, getV2vSelectedVmState } from '@/modules/v2v/utils
|
||||
import { OTHER_POOL_ID } from '@/test/create-pool.ts'
|
||||
import { createV2vImportVm } from '@/test/create-v2v-import-vm.ts'
|
||||
import { createV2vDisk, createV2vNic, createV2vVm } from '@/test/create-v2v-inventory.ts'
|
||||
import { createV2vMigrationList } from '@/test/create-v2v-migration-list.ts'
|
||||
import { createV2vVmRow } from '@/test/create-v2v-vm-row.ts'
|
||||
|
||||
const LIST_POOL_ID = 'pool-list' as FrontXoPool['id']
|
||||
const LIST_POOL_ID = createV2vMigrationList().poolId
|
||||
|
||||
const TARGET_NAMES = { srName: 'sr-nvme-01', networkName: 'VLAN 10' }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user