Skip to content

Commit e5c5890

Browse files
committed
Verify staged additions and hidden-history resizing in the app
gitx/gitx#370 gitx/gitx#400
1 parent 8e3a634 commit e5c5890

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎GitXUITests/GitXScreenshotTests.m‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,51 @@ - (void)testStagingTabScreenshot
254254
[self saveWindowScreenshotNamed:@"staging-view"];
255255
}
256256

257+
- (void)testPartiallyStagedAdditionShowsOnlyTheIndexedContent
258+
{
259+
[self.app terminate];
260+
NSString *fixture = [self makeDirtyRepositoryFixture];
261+
XCTAssertTrue(([self runGit:@[ @"reset", @"--hard", @"--quiet", @"HEAD" ] inDirectory:fixture]));
262+
XCTAssertTrue(([self runGit:@[ @"clean", @"-fd", @"--quiet" ] inDirectory:fixture]));
263+
NSString *newPath = [fixture stringByAppendingPathComponent:@"partial.txt"];
264+
XCTAssertTrue([@"staged line\n" writeToFile:newPath atomically:YES encoding:NSUTF8StringEncoding error:nil]);
265+
XCTAssertTrue(([self runGit:@[ @"add", @"partial.txt" ] inDirectory:fixture]));
266+
XCTAssertTrue([@"staged line\nunstaged line\n" writeToFile:newPath atomically:YES encoding:NSUTF8StringEncoding error:nil]);
267+
self.app.launchEnvironment = @{@"GITX_UITEST_REPO" : fixture};
268+
[self.app launch];
269+
[self openStagingView];
270+
271+
XCUIElement *stagedTable = self.app.tables[@"StagedFiles"];
272+
XCUIElement *unstagedTable = self.app.tables[@"UnstagedFiles"];
273+
XCUIElement *stagedFile = stagedTable.staticTexts[@"partial.txt"];
274+
XCTAssertTrue([stagedFile waitForExistenceWithTimeout:10]);
275+
XCTAssertTrue([unstagedTable.staticTexts[@"partial.txt"] waitForExistenceWithTimeout:10]);
276+
[stagedFile click];
277+
XCUIElement *diff = self.app.textViews.firstMatch;
278+
NSPredicate *indexedContent = [NSPredicate predicateWithFormat:@"value CONTAINS 'staged line' AND NOT value CONTAINS 'unstaged line'"];
279+
XCTNSPredicateExpectation *diffExpectation = [[XCTNSPredicateExpectation alloc] initWithPredicate:indexedContent object:diff];
280+
[self waitForExpectations:@[ diffExpectation ] timeout:15];
281+
[self saveWindowScreenshotNamed:@"partially-staged-addition-index-diff"];
282+
}
283+
284+
- (void)testHistoryRemainsUsableAfterResizingWhileHidden
285+
{
286+
XCTAssertTrue([self waitForWindow]);
287+
[self openStagingView];
288+
XCUIElement *window = self.app.windows.firstMatch;
289+
CGRect originalFrame = window.frame;
290+
[self.app.menuBars.menuBarItems[@"Window"] click];
291+
XCUIElement *zoom = self.app.menuItems[@"Zoom"];
292+
XCTAssertTrue([zoom waitForExistenceWithTimeout:5]);
293+
[zoom click];
294+
XCTAssertNotEqual(window.frame.size.width, originalFrame.size.width);
295+
296+
XCUIElement *history = [self selectHistoryForCurrentBranch];
297+
XCTAssertTrue([history.tableRows.firstMatch waitForExistenceWithTimeout:15]);
298+
XCTAssertTrue(self.app.textViews.firstMatch.exists, @"The restored history view should retain its native diff renderer");
299+
[self saveWindowScreenshotNamed:@"history-after-hidden-resize"];
300+
}
301+
257302
- (void)testSpaceStagesFilesAndSuccessfulCommitPushesWithoutASecondConfirmation
258303
{
259304
[self.app terminate];

0 commit comments

Comments
 (0)