Repository: GraphiteEditor/Graphite
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs (Rust)

Code before:
		let document = editor.active_document();
		let layer = document.metadata().all_layers().next().unwrap();

		editor.handle_message(TransformLayerMessage::BeginScale).await;

		// Move mouse exactly to the pivot point to achieve zero scale
		let center_x = 50.0;
		let center_y = 50.0;
		editor.move_mouse(center_x, center_y, ModifierKeys::empty(), MouseKeys::NONE).await;

		editor
			.handle_message(TransformLayerMessage::PointerMove {
				slow_key: Key::Shift,
				increments_key: Key::Control,
			})
			.await;

		editor.handle_message(TransformLayerMessage::ApplyTransformOperation { final_transform: true }).await;

		let final_transform = get_layer_transform(&mut editor, layer).await.unwrap();

		// Checking the transform matrix components are valid (not NaN or infinite)
		assert!(final_transform.matrix2.x_axis.x.is_finite(), "X-axis x component should be finite");
		assert!(final_transform.matrix2.x_axis.y.is_finite(), "X-axis y component should be finite");
		assert!(final_transform.matrix2.y_axis.x.is_finite(), "Y-axis x component should be finite");
		assert!(final_transform.matrix2.y_axis.y.is_finite(), "Y-axis y component should be finite");

		let scale_x = final_transform.matrix2.x_axis.length();
		let scale_y = final_transform.matrix2.y_axis.length();

		assert!(scale_x == 0.0, "Scale factor X should be effectively zero, got: {}", scale_x);
		assert!(scale_y == 0.0, "Scale factor Y should be effectively zero, got: {}", scale_y);

		// Checking that the determinant is very close to zero
		let determinant = final_transform.matrix2.determinant();
		assert!(determinant.abs() <= 1e-10, "Determinant should be effectively zero");
	}
}


Review comment (suggestion):
You can simply do:
```rs
assert!(final_transform.is_finite(), "Matrix should be finite");
```

Code after:
	#[tokio::test]
	async fn test_grab_rotate_scale_chained() {
		let mut editor = EditorTestUtils::create();
		editor.new_document().await;
		editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
		let document = editor.active_document();
		let layer = document.metadata().all_layers().next().unwrap();
		editor.handle_message(NodeGraphMessage::SelectedNodesSet { nodes: vec![layer.to_node()] }).await;
		let original_transform = get_layer_transform(&mut editor, layer).await.unwrap();

		editor.handle_message(TransformLayerMessage::BeginGrab).await;
		editor.move_mouse(150.0, 130.0, ModifierKeys::empty(), MouseKeys::NONE).await;
		editor
			.handle_message(TransformLayerMessage::PointerMove {
				slow_key: Key::Shift,
				increments_key: Key::Control,
			})
			.await;

		let after_grab_transform = get_layer_transform(&mut editor, layer).await.unwrap();
		let expected_translation = DVec2::new(50.0, 30.0);
		let actual_translation = after_grab_transform.translation - original_transform.translation;
		assert!(
			(actual_translation - expected_translation).length() < 1e-5,
			"Expected translation of {:?}, got {:?}",
			expected_translation,
			actual_translation
		);

		// 2. Chain to rotation - from current position to create ~45 degree rotation
		editor.handle_message(TransformLayerMessage::BeginRotate).await;
		editor.move_mouse(190.0, 90.0, ModifierKeys::empty(), MouseKeys::NONE).await;
		editor
			.handle_message(TransformLayerMessage::PointerMove {
				slow_key: Key::Shift,
				increments_key: Key::Control,
			})
			.await;
		let after_rotate_transform = get_layer_transform(&mut editor, layer).await.unwrap();
		// Checking for off-diagonal elements close to 0.707, which corresponds to cos(45°) and sin(45°)
		assert!(
			!after_rotate_transform.matrix2.abs_diff_eq(after_grab_transform.matrix2, 1e-5) &&
			(after_rotate_transform.matrix2.x_axis.y.abs() - 0.707).abs() < 0.1 &&  // Check for off-diagonal elements close to 0.707
			(after_rotate_transform.matrix2.y_axis.x.abs() - 0.707).abs() < 0.1, // that would indicate ~45° rotation
			"Rotation should change matrix components with approximately 45° rotation"
		);

		// 3. Chain to scaling - scale(area) up by 2x
		editor.handle_message(TransformLayerMessage::BeginScale).await;
		editor.move_mouse(250.0, 200.0, ModifierKeys::empty(), MouseKeys::NONE).await;
		editor