Skip to content

Conversation

@brbrr
Copy link
Contributor

@brbrr brbrr commented Nov 10, 2017

Will incrementally add UI tests to existing High priority issues

Covered:
#385
#675
#465
#771
#768

Fixed: #839

Copy link
Contributor

@rachelmcr rachelmcr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on these so far. I have some thoughts/questions about the line height tests, but I like the overall approach you're taking with these.

}

// Gihtub issue #393
func testLongTitle() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only passes on smaller screens — it fails on larger screens (I checked on an iPad Pro) because the text isn't long enough to wrap there. We should make sure the test accounts for different screen sizes and passes on any device.


titleTextView.typeText("very very very very very very long title in a galaxy not so far away")
let twoLineTitleHeight = Int(titleTextView.frame.height)
XCTAssert(twoLineTitleHeight - oneLineTitleHeight == titleLineHeight )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting titleLineHeight (fragile due to device settings or design changes) and using it in this calculation, what about using oneLineTitleHeight and asserting that twoLineTitleHeight is twice that? (Or just that twoLineTitleHeight is a multiple of oneLineTitleHeight if we want to confirm that the title area expands.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with you and I was thinking about that one. The thing is that oneLineTitleHeight is about 38px (due to underline and some padding), but every other line is 22px. So its quite complicated to confirm that in a nice way. We can confirm that it's just bigger, but I don't think its good approach either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I see what you mean. I agree that it'd be best to confirm a specific change in line height, so it might be best to stick with this approach. I'll keep thinking about it. (In the future, if we implement visual regression tests for Aztec we could confirm in the UI test that it's just bigger and use the visual regression test to make sure the entire title is visible. I wouldn't rely on that until we start implementing those visual tests, though.)

// Created by brbrr on 11/10/17.
// Copyright © 2017 Automattic Inc. All rights reserved.
//

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove these default header comments from the top of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
}

func testNewlinesInTitle() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is the current behavior, but should Aztec allow new lines in the title field? cc @diegoreymendez for your thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need this test, given that this isn't the intended behavior. See: #821

super.tearDown()
}

// Gihtub issue #393
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go ahead and add the full link to the issue here, to make it easier to find. (Also, just a small typo in "Gihtub")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// XCTAssert(twoLineTitleHeight < threeLineTitleHeight)
}

func testInfinitLoopOnAssetDownload() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What issue does this test? I think it's worth adding comments with links to all the issues we're testing, for reference later on. (Also, just a small note that there's a typo - "Infinit" should be "Infinite")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added GH issue ✅

switchContentView()
gotoRootPage()

let editorDemoButton = app.tables/*@START_MENU_TOKEN@*/.staticTexts["Empty Editor Demo"]/*[[".cells.staticTexts[\"Empty Editor Demo\"]",".staticTexts[\"Empty Editor Demo\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use staticTexts[elementStringIDs.emptyDemo] here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow! That is some fancy XCode recording stuff holding few locator values. I'll replace it with the single value you suggest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I should clarify that I was thinking of replacing staticTexts["Empty Editor Demo"] with staticTexts[elementStringIDs.emptyDemo]. We can remove the comments here and just use let editorDemoButton = app.tables.staticTexts[elementStringIDs.emptyDemo].

gotoRootPage()

let editorDemoButton = app.tables/*@START_MENU_TOKEN@*/.staticTexts["Empty Editor Demo"]/*[[".cells.staticTexts[\"Empty Editor Demo\"]",".staticTexts[\"Empty Editor Demo\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
XCTAssert(editorDemoButton.exists, "Editor button not hittable. Arew you on right page?")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor suggested edit:

"Editor button not hittable. Are you on the right page?"

extension XCTest {
/**
Common method to type in different text fields
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I like these updates you've made to the helper functions.

@diegoreymendez
Copy link
Contributor

diegoreymendez commented Nov 12, 2017

@brbrr, @catehstn, @rachelmcr - While reviewing these tests I can't really help it but notice we're devoting a lot of effort into UI testing the library's example App.

While this is good for Aztec as a library, most of the UI code is not directly affecting WPiOS (since Aztec as a library only provides the editor view).

I feel like it may be a good idea to start pushing at least part of these into WPiOS, instead or in addition to Aztec's example App.

Thoughts?

@brbrr
Copy link
Contributor Author

brbrr commented Nov 14, 2017

@diegoreymendez Generally I agree with you. Our (mine w/ @rachelmcr) plan was to cover all High priority issues (which are worth to cover w/ UI tests) here since test flows are mostly short. So we don't need to bother with login flow etc.

After that is done (and maybe some other simple formatting tests) we will switch to WP apps. Is it sounds reasonable to you?

And maybe we should move this discussion elsewhere (call or P2)

@diegoreymendez
Copy link
Contributor

Just to clarify though. I believe that the work you're doing here is great for several different reasons.

Ideally we'd have both the library and the app covered by a similar set of tests.

Thanks for taking care, everyone!

@brbrr
Copy link
Contributor Author

brbrr commented Nov 24, 2017

@rachelmcr may I ask your attention to this one?

Copy link
Contributor

@rachelmcr rachelmcr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the page object improvements!

The tests are working great for me on smaller devices, so my comments at this point are mainly focused on getting the tests working on larger devices.

// tablesQuery.staticTexts[elementStringIDs.emptyDemo].tap()
//
// let richTextField = app.textViews[elementStringIDs.richTextField]
// richTextField.tap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go ahead and remove this commented-out section.

expandOptionsSctrip()
}

func expandOptionsSctrip() -> Void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On larger devices (e.g. iPad Pro) this function is toggling the extended toolbar open/closed rather than always expanding it. We should check the status of the toolbar before tapping — otherwise the expanded toolbar is toggled off in every other test.

If it isn't currently possible to check the status, we should open an issue to address that as it's also an accessibility issue. (VoiceOver users need to be aware of the toolbar status so they can expand it if needed, too.)

Copy link
Contributor Author

@brbrr brbrr Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created the ticket for that: #837

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, how about checking to see if the HTML button exists before toggling the extended toolbar? I'm thinking of something like this:

        let expandButton = app.children(matching: .window).element(boundBy: 1).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .button).element
        let htmlButton = app.scrollViews.otherElements.buttons[elementStringIDs.sourcecodeButton]
        
        if expandButton.exists && expandButton.isHittable && !htmlButton.exists {
            expandButton.tap()
        }

That way we don't break the existing tests on iPads, and we can improve the check later once that issue is resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice solution, thanks!

}

// Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/385
func testLongTitle() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is still failing on larger devices (e.g. iPad Pro). If there isn't a way to get it to work for both large and small devices, could we restrict it to only run when testing smaller devices?

Copy link
Contributor Author

@brbrr brbrr Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its possible to tag which tests to run with current test runner (as it's done in wp-e2e-tests). The only solution I see is to move such tests to separate files and run them only for small screens. And in general, I think it would be better to address this issue once we'll have them running on multiple devices. I've created the ticket for that: #839

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked around and found these hints and tips that include conditional code for testing on iPhone v. iPad. I updated the example shown there and got it to work in this test like this:

if (app.windows.element(boundBy: 0).horizontalSizeClass == .compact || app.windows.element(boundBy: 0).verticalSizeClass == .compact) {
            titleTextView.typeText("very very very very very very long title in a galaxy not so far away")
        } else {
            titleTextView.typeText("very very very very very very long title in a galaxy not so far away very very very very very very long title in a galaxy not so far away")
        }

// XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
}

func testNewlinesInTitle() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need this test, given that this isn't the intended behavior. See: #821

// let app = XCUIApplication()
// let richTextField = app.textViews[elementStringIDs.richTextField]
//
// richTextField.typeText(text)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go ahead and remove this commented-out section.

@brbrr brbrr changed the title [WIP] Add UI tests for high priority issues Add UI tests for high priority issues Nov 30, 2017
@rachelmcr
Copy link
Contributor

The changes look good to me. It looks like testCopyPasteCrash failed on Travis CI — I'm not sure what's going on there; I haven't had any trouble with it on local runs.

@brbrr brbrr merged commit aec651b into develop Dec 1, 2017
@brbrr brbrr deleted the add/ui-tests-for-high-priority-issues branch December 14, 2017 03:49
@diegoreymendez diegoreymendez added this to the 1.0.0-beta.16 milestone Dec 15, 2017
@diegoreymendez
Copy link
Contributor

Just a reminder to set the appropriate milestone when closing a PR or issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants