Assert.assertEquals("INSTALL LOG".toLowerCase(), jobLogLabel.getText().toLowerCase());
// The job log is collapsed when the job is waiting for user input so we need to expand it before asserting its
// content (otherwise #getText() returns the empty string because the text is not visible).
jobLogLabel.click();
List<LogItemPane> upgradeLog = progressPane.getJobLog();
LogItemPane lastLogItem = upgradeLog.get(upgradeLog.size() - 1);
Assert.assertEquals("loading", lastLogItem.getLevel());
Assert.assertEquals(progressBar.getMessage(), lastLogItem.getMessage());
MergeConflictPane mergeConflictPane = progressPane.getMergeConflict();
ChangesPane changesPane = mergeConflictPane.getChanges();
Assert.assertFalse(changesPane.getContentChanges().isEmpty());
Assert.assertEquals("@@ -1,1 +1,1 @@\n-<del>Test</del> macro.\n+<ins>A</ins> <ins>cool </ins>macro.",
changesPane.getObjectChanges("XWiki.WikiMacroClass", 0, "Macro description"));
mergeConflictPane.getFromVersionSelect().selectByVisibleText("Previous version");
mergeConflictPane.getToVersionSelect().selectByVisibleText("Current version");
mergeConflictPane = mergeConflictPane.clickShowChanges();
changesPane = mergeConflictPane.getChanges();
StringBuilder expectedDiff = new StringBuilder();
expectedDiff.append("@@ -1,9 +1,9 @@\n");
expectedDiff.append("-= Usage =\n");
expectedDiff.append("+=<ins>=</ins> Usage =<ins>=</ins>\n");
expectedDiff.append(" \n");
expectedDiff.append("-{{code}}\n");
expectedDiff.append("+{{code<ins> language=\"none\"</ins>}}\n");
expectedDiff.append(" {{alice/}}\n");
expectedDiff.append(" {{/code}}\n");
expectedDiff.append(" \n");
expectedDiff.append("-= <del>Res</del>u<del>l</del>t =\n");
expectedDiff.append("+=<ins>=</ins> <ins>O</ins>ut<ins>put</ins> =<ins>=</ins>\n");
expectedDiff.append(" \n");
expectedDiff.append(" {{alice/}}");
Assert.assertEquals(expectedDiff.toString(), changesPane.getContentChanges());
Assert.assertEquals(1, changesPane.getObjectChangeSummaries().size());
Assert.assertEquals(
"@@ -1,1 +1,1 @@\n-Alice says hello!\n+<ins>{{info}}</ins>Alice says hello!<ins>{{/info}}</ins>",
changesPane.getObjectChanges("XWiki.WikiMacroClass", 0, "Macro code"));
// Finish the merge.
mergeConflictPane.getVersionToKeepSelect().selectByValue("NEXT");
// FIXME: We get the extension pane from the search results because it is reloaded when we compare the versions.
extensionPane = searchResults.getExtension(0).confirm();
Assert.assertEquals("installed", extensionPane.getStatus());
Assert.assertNull(extensionPane.getProgressBar());
upgradeLog = extensionPane.openProgressSection().getJobLog();
lastLogItem = upgradeLog.get(upgradeLog.size() - 1);
Assert.assertEquals("info", lastLogItem.getLevel());
Assert.assertEquals("Finished job of type [install] with identifier "
+ "[extension/action/alice-xar-extension/wiki:xwiki]", lastLogItem.getMessage());
// Check the merge result.
ViewPage mergedPage = getUtil().gotoPage("ExtensionTest", "Alice");
Assert.assertEquals("Alice Wiki Macro (upgraded)", mergedPage.getDocumentTitle());
}