重构首页为单一集合视图并添加全部功能自定义

This commit is contained in:
2026-07-07 09:57:41 +08:00
parent 16e86c8899
commit af450fb4cc
14 changed files with 1222 additions and 209 deletions

View File

@ -0,0 +1,53 @@
//
// 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])
}
}