@@ -516,22 +516,56 @@ - (void)testAppearancePreferenceOffersAutomaticLightAndDark
516516
517517- (void )testCommitContextMenuScreenshot
518518{
519+ [self .app terminate ];
520+ NSString *fixture = [self makeDirtyRepositoryFixture ];
521+ XCTAssertTrue (([self runGit: @[ @" reset" , @" --hard" , @" --quiet" , @" HEAD" ] inDirectory: fixture]));
522+ XCTAssertTrue (([self runGit: @[ @" clean" , @" -fd" , @" --quiet" ] inDirectory: fixture]));
523+ self.app .launchEnvironment = @{@" GITX_UITEST_REPO" : fixture};
524+ [self .app launch ];
519525 XCTAssertTrue ([self waitForWindow ], @" The context menu requires a repository window" );
520526 XCUIElement *table = [self selectHistoryForCurrentBranch ];
521527 XCUIElement *window = self.app .windows .firstMatch ;
522- XCUIElement *firstRow = [table.tableRows elementBoundByIndex: 0 ];
523- XCTAssertTrue ([firstRow waitForExistenceWithTimeout: 15 ], @" The commit list should contain a row" );
528+ XCUIElement *selectedRow = [table.tableRows containingType: XCUIElementTypeStaticText identifier: @" Third" ].firstMatch ;
529+ XCUIElement *clickedRow = [table.tableRows containingType: XCUIElementTypeStaticText identifier: @" Initial" ].firstMatch ;
530+ XCTAssertTrue ([selectedRow waitForExistenceWithTimeout: 15 ]);
531+ XCTAssertTrue ([clickedRow waitForExistenceWithTimeout: 15 ]);
532+ [selectedRow click ];
533+ XCTAssertTrue (selectedRow.isSelected );
524534
525- // Right-click to open the context menu
526- [firstRow rightClick ];
535+ [clickedRow rightClick ];
527536
528537 XCUIElement *menu = self.app .menus .firstMatch ;
529538 XCTAssertTrue ([menu waitForExistenceWithTimeout: 5 ], @" Right-clicking a commit should open its context menu" );
530539 XCTAssertTrue ([menu.menuItems.firstMatch waitForExistenceWithTimeout: 5 ], @" The commit context menu should finish populating" );
540+ XCTAssertTrue (clickedRow.isSelected , @" The context menu and table selection should target the same commit" );
541+ XCTAssertFalse (selectedRow.isSelected );
531542 [self saveWindowScreenshotNamed: @" commit-context-menu" ];
532543
533544 // Dismiss the menu
534545 [window typeKey: XCUIKeyboardKeyEscape modifierFlags: 0 ];
535546}
536547
548+ - (void )testManualRefreshUpdatesCheckedOutBranchAndSidebar
549+ {
550+ [self .app terminate ];
551+ NSString *fixture = [self makeDirtyRepositoryFixture ];
552+ XCTAssertTrue (([self runGit: @[ @" reset" , @" --hard" , @" --quiet" , @" HEAD" ] inDirectory: fixture]));
553+ XCTAssertTrue (([self runGit: @[ @" clean" , @" -fd" , @" --quiet" ] inDirectory: fixture]));
554+ self.app .launchEnvironment = @{@" GITX_UITEST_REPO" : fixture};
555+ [self .app launch ];
556+ XCTAssertTrue ([self waitForWindow ]);
557+ XCUIElement *currentBranch = [self .app.staticTexts matchingPredicate: [NSPredicate predicateWithFormat: @" value == 'main'" ]].firstMatch ;
558+ XCTAssertTrue ([currentBranch waitForExistenceWithTimeout: 10 ]);
559+ XCTAssertTrue (([self runGit: @[ @" checkout" , @" --quiet" , @" -b" , @" feature/manual-ui-refresh" ] inDirectory: fixture]));
560+
561+ XCUIElement *window = self.app .windows .firstMatch ;
562+ [window typeKey: @" r" modifierFlags: XCUIKeyModifierCommand];
563+ XCUIElement *newBranch = [self .app.staticTexts matchingPredicate: [NSPredicate predicateWithFormat: @" value == 'manual-ui-refresh'" ]].firstMatch ;
564+ XCTAssertTrue ([newBranch waitForExistenceWithTimeout: 15 ], @" Manual refresh should reveal externally created branches" );
565+ NSPredicate *updatedTitle = [NSPredicate predicateWithFormat: @" title CONTAINS 'feature/manual-ui-refresh'" ];
566+ XCTNSPredicateExpectation *titleExpectation = [[XCTNSPredicateExpectation alloc ] initWithPredicate: updatedTitle object: window];
567+ [self waitForExpectations: @[ titleExpectation ] timeout: 15 ];
568+ [self saveWindowScreenshotNamed: @" manual-refresh-updated-branch" ];
569+ }
570+
537571@end
0 commit comments