V2Wizard: Fix FSC units on Edit

This updates the logic of parsing bytesize into size/unit pair.

Currently 'GiB' is set as a default which causes problem with smaller partitions on Edit.

A validation for the min_size is in place and the rule is that the size cannot be smaller than 0 of a given unit. If there was a partition with smaller size in KiB it will break the rule when converted to GiB.
This commit is contained in:
regexowl 2024-04-30 15:38:50 +02:00 committed by Lucas Garfield
parent 13d35a834e
commit df9ec1499d
7 changed files with 61 additions and 40 deletions

View file

@ -1,7 +1,12 @@
import { screen, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { CREATE_BLUEPRINT, UNIT_GIB } from '../../../../../constants';
import {
CREATE_BLUEPRINT,
UNIT_GIB,
UNIT_KIB,
UNIT_MIB,
} from '../../../../../constants';
import { clickNext } from '../../../../testUtils';
import {
blueprintRequest,
@ -161,7 +166,7 @@ describe('file system configuration request generated correctly', () => {
customizations: {
filesystem: [
{
min_size: 10 * UNIT_GIB,
min_size: 10 * UNIT_MIB,
mountpoint: '/',
},
],
@ -184,7 +189,7 @@ describe('file system configuration request generated correctly', () => {
customizations: {
filesystem: [
{
min_size: 10 * UNIT_GIB,
min_size: 10 * UNIT_KIB,
mountpoint: '/',
},
],