metis-desk/apps/server/src/work-profile-hosts.fixture.ts
David b45925f3e2 feat(assets): implement asset picker dialog and selection components
- Added `useAssetPickerController` for managing asset selection logic.
- Created `AssetSelectProps` type for defining asset selection properties.
- Implemented `AssetPickerDialog` for displaying the asset selection interface.
- Developed `AssetPickerList` for rendering the list of selectable assets.
- Introduced `AssetSelect` component for integrating the asset picker into forms.
- Created `AssetList` component for shared asset listing functionality.
- Added tests for workstation creation logic to ensure proper validation.
- Implemented workstation asset fields and association fields for managing workstation assets.
- Developed workstation lifecycle dialog for managing work profile states.
- Added form progress component for visualizing multi-step forms.
2026-10-14 19:42:59 +02:00

46 lines
1.4 KiB
TypeScript

import assert from "node:assert/strict";
import { InventoryResponseSchema, WorkstationResponseSchema } from "@metis/assets/common";
type Request = (path: string, body?: unknown, origin?: string, token?: string) => Promise<Response>;
/** Prepara puestos independientes para los ordenadores de los escenarios HTTP. */
export async function prepareProfileHosts(
request: Request,
companyId: string,
assetIds: readonly string[]
) {
const current = InventoryResponseSchema.parse(
await (await request(`/assets/${companyId}`)).json()
);
for (const station of current.workstations) {
if (station.values.active && assetIds.some((id) => station.values.assetIds.includes(id))) {
const closed = await request(`/assets/${companyId}/workstations/${station.id}/update`, {
values: { ...station.values, active: false },
});
assert.equal(closed.status, 200, await closed.clone().text());
}
}
const hosts = [];
for (const assetId of assetIds) {
const response = await request(`/assets/${companyId}/workstations`, {
values: {
name: `Puesto perfiles ${assetId}`,
active: true,
siteId: null,
personId: null,
computerAssetId: assetId,
assetIds: [assetId],
},
});
assert.equal(response.status, 201, await response.clone().text());
hosts.push(WorkstationResponseSchema.parse(await response.json()).workstation);
}
return hosts;
}