Permalink
Browse files

[Snackbar] Fix Earl Grey test (#4349)

With the new Catalog structure for a "Start Demo" button (instead of a cell),
the accessibilityIdentifier was missing and Earl Grey couldn't find the
correct demo.

Closes #4343
  • Loading branch information...
romoore committed Jun 1, 2018
1 parent acd639c commit d9d4b5ca616f847c33649037e04ff63f34c31dbb
@@ -109,6 +109,7 @@ class NodeViewTableViewPrimaryDemoCell: UITableViewCell {
func setupContainedButton() {
containedButton.setTitle("Start Demo", for: .normal)
containedButton.translatesAutoresizingMaskIntoConstraints = false
containedButton.accessibilityIdentifier = "start.demo";
contentView.addSubview(containedButton)
// constraints
@@ -85,14 +85,17 @@ + (void)scrollToElementWithIdentifier:(nonnull NSString *)identifier
@note Only the first two elements are currently handled.
*/
+ (void)jumpToExampleWithBreadcrumbs:(NSArray<NSString *> *)breadcrumbs {
NSAssert(breadcrumbs.count >= 2, @"Breadcrumb paths must be at least 2 elements.");
NSAssert(breadcrumbs.count >= 1, @"Breadcrumb paths must be at least 1 element.");
[SnackbarEarlGreyTests scrollToElementWithIdentifier:breadcrumbs[0]
inElementWithIdentifier:@"collectionView"
direction:kGREYDirectionDown
withStep:-1
tap:YES];
NSString *demoName =
breadcrumbs.count >= 2 ? [NSString stringWithFormat:@"Cell%@", breadcrumbs[1]]
: @"start.demo";
[SnackbarEarlGreyTests
scrollToElementWithIdentifier:[NSString stringWithFormat:@"Cell%@", breadcrumbs[1]]
scrollToElementWithIdentifier:demoName
inElementWithIdentifier:[NSString stringWithFormat:@"Table%@", breadcrumbs[0]]
direction:kGREYDirectionDown
withStep:-1
@@ -112,7 +115,7 @@ + (void)returnToMainScreen {
}
- (void)testSliding {
[SnackbarEarlGreyTests jumpToExampleWithBreadcrumbs:@[ @"Snackbar", @"Demo" ]];
[SnackbarEarlGreyTests jumpToExampleWithBreadcrumbs:@[ @"Snackbar"]];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Simple Snackbar")]
performAction:grey_tap()];
[SnackbarEarlGreyTests returnToMainScreen];

0 comments on commit d9d4b5c

Please sign in to comment.