fix: 优化图片预览索引胶囊

This commit is contained in:
2026-08-13 15:36:06 +08:00
parent 202b0f5e41
commit 48b6b9be22
2 changed files with 38 additions and 6 deletions
@@ -67,6 +67,29 @@ final class TravelAlbumDetailViewControllerTests: XCTestCase {
XCTAssertEqual(failure, .failure("服务暂不可用"))
}
func testPreviewCounterUsesHorizontalPaddingAndContentDrivenWidth() throws {
let controller = TravelAlbumPhotoPreviewViewController(
projects: [makePreviewProject(id: 1, fileName: "原图.jpg")],
totalCount: 10_000,
startProjectIndex: 0
)
controller.loadViewIfNeeded()
controller.view.frame = CGRect(x: 0, y: 0, width: 390, height: 844)
controller.view.layoutIfNeeded()
let counterLabel = try XCTUnwrap(
controller.view.findSubview {
$0.accessibilityIdentifier == "travelAlbum.previewCounterLabel"
} as? UILabel
)
let counterContainer = try XCTUnwrap(counterLabel.superview)
let expectedWidth = max(48, counterLabel.intrinsicContentSize.width + 24)
XCTAssertEqual(counterContainer.bounds.width, expectedWidth, accuracy: 0.5)
XCTAssertEqual(counterLabel.frame.minX, 12, accuracy: 0.5)
XCTAssertEqual(counterContainer.bounds.width - counterLabel.frame.maxX, 12, accuracy: 0.5)
}
func testPreviewSuccessfulDeletionShowsNextProjectAndPreventsDuplicateRequests() async throws {
let api = TravelAlbumMockAPI()
api.deleteMaterialDelayNanoseconds = 1_000_000