Repository: directus/directus
File: api/src/utils/transformations.test.ts (TypeScript)

Code before:
		};

		const output = resolvePreset(
			{ transformationParams },
			{ ...inputFile, focal_point_x: inputFile.width / 2, focal_point_y: inputFile.height / 2 },
		);

		// Dimensions should be clamped to original (1920x1080)
		// Since we're requesting 1920x1080 with a centered focal point on a 1920x1080 image,
		// the intermediate dimensions will be 1920x1080, and the extract will be the full image
		expect(output).toStrictEqual([
			[
				'resize',
				{
					width: 1920,
					height: 1080,
					fit: 'cover',
					withoutEnlargement: true,
				},
			],
			['extract', { left: 0, top: 0, width: 1920, height: 1080 }],
		]);
	});

	test('Add resize transformation: withoutEnlargement clamps only width when height is smaller #22391', () => {
		// Width is larger, height is smaller - only width should be clamped
		const transformationParams: TransformationParams = {
			key: 'test-width-larger',
			width: 2000, // larger than original width (1920)
			height: 500, // smaller than original height (1080)
			fit: 'cover',
			withoutEnlargement: true,
		};

		const output = resolvePreset(
			{ transformationParams },
			{ ...inputFile, focal_point_x: inputFile.width / 2, focal_point_y: inputFile.height / 2 },
		);

		// Width should be clamped to 1920, height stays at 500
		// With 1920x500 target and centered focal point on 1920x1080 image:
		// hRatio = 1080/500 = 2.16, wRatio = 1920/1920 = 1
		// wRatio < hRatio, so factor = 1, width = 1920, height = 1080/1 = 1080
		// Extract region: left = 0, top = (1080/2 - 500/2) = 290
		expect(output).toStrictEqual([
			[
				'resize',
				{
					width: 1920,
					height: 1080,
					fit: 'cover',

Review comment (suggestion):
```suggestion
	test('Resize transformation with withoutEnlargement clamps only width when height is smaller', () => {
```

Code after:
		);

		// Dimensions should be clamped to original (1920x1080)
		expect(output).toStrictEqual([
			[
				'resize',
				{
					width: 1920,
					height: 1080,
					fit: 'cover',
					withoutEnlargement: true,
				},
			],
			['extract', { left: 0, top: 0, width: 1920, height: 1080 }],
		]);
	});

	test('Resize transformation with withoutEnlargement clamps only width when height is smaller', () => {
		const transformationParams: TransformationParams = {
			key: 'test-width-larger',
			width: 2000, // larger than original width (1920)
			height: 500, // smaller than original height (1080)
			fit: 'cover',
			withoutEnlargement: true,
		};

		const output = resolvePreset(
			{ transformationParams },
			{ ...inputFile, focal_point_x: inputFile.width / 2, focal_point_y: inputFile.height / 2 },
		);

		// Width should be clamped to 1920, height stays at 500
		// With 1920x500 target and centered focal point on 1920x1080 image
		expect(output).toStrictEqual([
			[
				'resize',
				{
					width: 1920,
					height: 1080,
					fit: 'cover',
					withoutEnlargement: true,
				},
			],
			['extract', { left: 0, top: 290, width: 1920, height: 500 }],
		]);
	});

	test('Resize transformation with withoutEnlargement with smaller dimensions is unchanged', () => {
		const transformationParams: TransformationParams = {
			key: 'test-smaller',
			width: 800,