theextremeprogrammer / Succinct

UI tests at the speed of unit tests. Proper encapsulation. Architecture agnostic. Freedom to refactor.
MIT License
42 stars 7 forks source link

Support finding labels in table view section headers #73

Closed rgravina closed 3 years ago

rgravina commented 3 years ago

Given a table view subject has a section with a header Section Title, this returns false.

// in table view
    public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return "Section Title"
    }

// in test
expect(subject.hasLabel(withExactText: "Section Title")).toEventually(beTrue())

Although the code does appear to look in the table section header https://github.com/derekleerock/Succinct/blob/master/Succinct/UITableView/UITableView+Evaluations.swift

Not sure I'm looking in the right place but couldn't find a check for looking the the table view section headers for a label though https://github.com/derekleerock/Succinct/blob/master/SuccinctTests/UITableViewController/UITableViewController+UILabelSpec.swift

Just adding but if it's already supported feel free to close.

theextremeprogrammer commented 3 years ago

Thanks @rgravina! Looks like header views are supported, but not section headers as you suggested. It also looks like Footer Views are not supported yet, either.

As you already noted, it would be the titleForHeaderInSection delegate method that would need to be added. 👍🏻

Let me know if this is a high priority for you!

rgravina commented 3 years ago

Great, glad I finally found one! It's not urgent, it's not common for section headers to have logic but in this case they come from a backing array. It's ok for us to not test that one thing for now.

theextremeprogrammer commented 3 years ago

@rgravina I was in Succinct to make some other changes and thought that I'd go ahead and knock this one out while I was in here.

It was pretty straight forward but did require a few changes that I didn't anticipate - but the implementation is interesting I think! Take a look at the referenced commits if you're interested, and feel free to back-fill those tests that you passes earlier if time permits. 👍🏻

The same could be done for section footers (following the same pattern), but since that is likely not urgent I'll create a separate issue for that to be tackled later (#75).

theextremeprogrammer commented 3 years ago

Included in tag 0.4.33: https://github.com/derekleerock/Succinct/releases/tag/v0.4.33