Slide 73
Slide 73 text
class PHTestComments : PHTestUITestCase {
func testCommentingFlow() {
// setup
let post = fake.post()
tester.loginAsLoggedUser()
// comment versions
let comment = fake.comment(["user": tester.loggedUserId])
let updatedComment = comment.ph_merge(["body": "updated body"])
// stub requests
endpoint.stubPost(post)
endpoint.stubMethod(.Post, "/comments", comment)
endpoint.stubMethod(.Patch, "/comments/\(comment["id"])", updatedComment)
// start
tester.openPost(post)
tester.waitForViewWithAccessibilityLabel("No Comments")
// test submit button appearing
tester.clearTextFromAndThenEnterText(comment["body"],
intoViewWithAccessibilityLabel: "Comment")
// test creating a comment
tester.tapViewWithAccessibilityLabel("Submit")
tester.waitForViewWithAccessibilityLabel(comment["Body"])
// test updating a comment
tester.tapViewWithAccessibilityLabel("Edit comment")
tester.clearTextFromAndThenEnterText(updatedComment["body"],