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>
54 lines
1.9 KiB
Swift
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])
|
|
}
|
|
}
|