Files
suixinkan_uikit/suixinkanTests/HomeCollectionModelsTests.swift
汉秋 715393e78c Refactor home to single collection view and add all-functions customization.
Replace scroll/stack layout with one UICollectionView, fix grid column math and Diffable item IDs so location report and quick actions render, and add the customizable all-functions page with persistence and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 09:57:41 +08:00

54 lines
1.9 KiB
Swift

//
// HomeCollectionModelsTests.swift
// suixinkanTests
//
import XCTest
@testable import suixinkan
/// Collection snapshot
final class HomeCollectionModelsTests: XCTestCase {
func testMakeSnapshotIncludesDistinctWorkBlockItems() {
let snapshot = HomeCollectionLayoutBuilder.makeSnapshot(
showWorkBlock: true,
showStore: false,
storeItem: nil,
commonMenus: []
)
XCTAssertEqual(snapshot.numberOfSections, 4)
XCTAssertEqual(snapshot.numberOfItems(inSection: .workStatus), 1)
XCTAssertEqual(snapshot.numberOfItems(inSection: .locationReport), 1)
XCTAssertEqual(snapshot.numberOfItems(inSection: .quickActions), 1)
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .workStatus), [.workStatus])
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .locationReport), [.locationReport])
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .quickActions), [.quickActions])
}
func testMakeSnapshotOmitsWorkBlockForMinimalTopRole() {
let snapshot = HomeCollectionLayoutBuilder.makeSnapshot(
showWorkBlock: false,
showStore: false,
storeItem: nil,
commonMenus: []
)
XCTAssertEqual(snapshot.sectionIdentifiers, [.commonApps])
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .commonApps).count, 1)
}
func testMakeSnapshotIncludesStoreSectionWhenAvailable() {
let store = StoreItem(id: 1, name: "测试门店", address: "测试地址")
let snapshot = HomeCollectionLayoutBuilder.makeSnapshot(
showWorkBlock: true,
showStore: true,
storeItem: store,
commonMenus: []
)
XCTAssertTrue(snapshot.sectionIdentifiers.contains(.store))
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .store), [.store])
}
}