Skip to content

Commit 091ccf4

Browse files
committed
fix(tests): Align mocks and behavior in component tests
Ensure both single task training and task chain training tests use the same mocks and behavior, fixing inconsistencies that previously caused test failures.
1 parent 8c17244 commit 091ccf4

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

web_ui/tests/features/project-models/mocks.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,6 +2866,26 @@ export const trainingConfiguration: TrainingConfigurationDTO = {
28662866
],
28672867
},
28682868
augmentation: {
2869+
center_crop: [
2870+
{
2871+
default_value: false,
2872+
description: 'Whether to apply center cropping to the image',
2873+
key: 'enable',
2874+
name: 'Enable center crop',
2875+
type: 'bool',
2876+
value: true,
2877+
},
2878+
{
2879+
default_value: 1,
2880+
description: 'Ratio of original dimensions to keep when cropping',
2881+
key: 'ratio',
2882+
max_value: null,
2883+
min_value: 0,
2884+
name: 'Crop ratio',
2885+
type: 'float',
2886+
value: 0.6,
2887+
},
2888+
],
28692889
iou_random_crop: [
28702890
{
28712891
key: 'enable',
@@ -3129,15 +3149,15 @@ export const trainingConfiguration: TrainingConfigurationDTO = {
31293149
name: 'Enable tiling',
31303150
type: 'bool',
31313151
description: 'Whether to apply tiling to the image',
3132-
value: false,
3152+
value: true,
31333153
default_value: false,
31343154
},
31353155
{
31363156
key: 'adaptive_tiling',
31373157
name: 'Adaptive tiling',
31383158
type: 'bool',
31393159
description: 'Whether to use adaptive tiling based on image content',
3140-
value: true,
3160+
value: false,
31413161
default_value: true,
31423162
},
31433163
{
@@ -3283,6 +3303,16 @@ export const expectedTrainingConfiguration: TrainingConfigurationUpdatePayloadDT
32833303
],
32843304
},
32853305
augmentation: {
3306+
center_crop: [
3307+
{
3308+
key: 'enable',
3309+
value: false,
3310+
},
3311+
{
3312+
key: 'ratio',
3313+
value: 0.6,
3314+
},
3315+
],
32863316
color_jitter: [
32873317
{
32883318
key: 'enable',

web_ui/tests/features/project-models/train-model.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ test.describe('Train model', () => {
205205
throw new Error('Could not get bounding box for endRange handle');
206206
}
207207

208+
await expect(trainModelPage.getBooleanParameter('Enable center crop')).toBeChecked();
209+
await expect(trainModelPage.getNumberParameter('Crop ratio')).toBeEnabled();
210+
211+
await trainModelPage.toggleEnableParameter('Enable center crop');
212+
await expect(trainModelPage.getBooleanParameter('Enable center crop')).not.toBeChecked();
213+
await expect(trainModelPage.getNumberParameter('Crop ratio')).toBeDisabled();
214+
208215
await expect(trainModelPage.getToggleFilter('Minimum annotation pixels')).toBeChecked();
209216
await expect(trainModelPage.getNumberParameter('Minimum annotation pixels')).toBeDisabled();
210217

@@ -429,6 +436,33 @@ test.describe('Train model', () => {
429436
await trainModelPage.changeNumberParameter('Tile size', 128);
430437
await expect(trainModelPage.getNumberParameter('Tile size')).toHaveValue('128');
431438

439+
await trainModelPage.toggleEnableParameter('Enable color jitter');
440+
441+
await expect(page.getByRole('slider', { name: 'Minimum Change Brightness' })).toHaveValue('0.875');
442+
await expect(page.getByRole('slider', { name: 'Maximum Change Brightness' })).toHaveValue('1.125');
443+
444+
const brightnessStart = page.getByRole('button', {
445+
name: 'Increase Change Brightness range start range value',
446+
});
447+
await brightnessStart.click();
448+
449+
const brightnessSlider = page.getByLabel('Change Brightness range value');
450+
brightnessSlider.click();
451+
452+
const endRange = brightnessSlider.getByRole('presentation').nth(2);
453+
454+
await endRange.click();
455+
const box = await endRange.boundingBox();
456+
457+
if (box) {
458+
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
459+
await page.mouse.down();
460+
await page.mouse.move(box.x + box.width / 2 - 30, box.y + box.height / 2);
461+
await page.mouse.up();
462+
} else {
463+
throw new Error('Could not get bounding box for endRange handle');
464+
}
465+
432466
await expect(trainModelPage.getBooleanParameter('Enable center crop')).toBeChecked();
433467
await expect(trainModelPage.getNumberParameter('Crop ratio')).toBeEnabled();
434468

0 commit comments

Comments
 (0)