diff --git a/FunctionalTableData/TableView/FunctionalTableData.swift b/FunctionalTableData/TableView/FunctionalTableData.swift index 80f2e6c..20f055f 100644 --- a/FunctionalTableData/TableView/FunctionalTableData.swift +++ b/FunctionalTableData/TableView/FunctionalTableData.swift @@ -541,6 +541,7 @@ extension FunctionalTableData: UITableViewDataSource { let row = indexPath.row let cellConfig = sectionData[row] let cell = cellConfig.dequeueCell(from: tableView, at: indexPath) + cell.accessibilityIdentifier = sectionData.sectionKeyPathForRow(row) cellConfig.update(cell: cell, in: tableView) sectionData.mergedStyle(for: row)?.configure(cell: cell, in: tableView) diff --git a/FunctionalTableDataTests/FunctionalDataTests.swift b/FunctionalTableDataTests/FunctionalDataTests.swift index 5b31d95..35c6bd6 100644 --- a/FunctionalTableDataTests/FunctionalDataTests.swift +++ b/FunctionalTableDataTests/FunctionalDataTests.swift @@ -73,6 +73,24 @@ class FunctionalDataTests: XCTestCase { XCTAssertNotNil(indexPath) } + func testCellAccessibilityIdentifiers() { + let tableData = FunctionalTableData() + let tableView = UITableView() + + tableData.tableView = tableView + let expectation1 = expectation(description: "rendered") + let cellConfig = TestCaseCell(key: "cellKey", state: TestCaseState(data: "red"), cellUpdater: TestCaseState.updateView) + let section = TableSection(key: "sectionKey", rows: [cellConfig]) + + tableData.renderAndDiff([section]) { + expectation1.fulfill() + } + waitForExpectations(timeout: 1, handler: nil) + + let cell = tableData.tableView?.visibleCells.first + XCTAssertEqual(cell?.accessibilityIdentifier, "sectionKeycellKey") + } + func testPerformance() { let functionalData = FunctionalTableData()