*/
@Test
public void testRepositorySelector() throws Exception
{
// Setup the extension.
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
getRepositoryTestUtils().addExtension(extension);
// Check if the section links point to the right repository.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage().clickAddExtensionsSection();
Select repositorySelect = adminPage.getSearchBar().getRepositorySelect();
Assert.assertEquals("All Extensions", repositorySelect.getFirstSelectedOption().getText());
adminPage = adminPage.clickCoreExtensionsSection();
repositorySelect = adminPage.getSearchBar().getRepositorySelect();
Assert.assertEquals("Core extensions", repositorySelect.getFirstSelectedOption().getText());
adminPage = adminPage.clickInstalledExtensionsSection();
repositorySelect = adminPage.getSearchBar().getRepositorySelect();
Assert.assertEquals("Installed extensions", repositorySelect.getFirstSelectedOption().getText());
// Check that a remote extension appears only in the list of "All Extensions".
SearchResultsPane searchResults = adminPage.getSearchBar().search("alice");
Assert.assertNull(searchResults.getExtension(extensionId));
new SimpleSearchPane().getRepositorySelect().selectByVisibleText("All Extensions");
adminPage = new ExtensionAdministrationPage();
adminPage.waitUntilPageIsLoaded();
// The value of the search input must be preserved when we switch the repository.
Assert.assertEquals("alice", adminPage.getSearchBar().getSearchInput().getAttribute("value"));
Assert.assertNotNull(adminPage.getSearchResults().getExtension(extensionId));
Assert.assertNull(new SimpleSearchPane().selectRepository("local").getExtension(extensionId));
// Check that an installed extension appears also in "Installed Extensions" and "Local Extensions".
getExtensionTestUtils().install(extensionId);
adminPage = ExtensionAdministrationPage.gotoPage().clickInstalledExtensionsSection();
searchResults = adminPage.getSearchBar().search("alice");
Assert.assertNotNull(searchResults.getExtension(extensionId));
Assert.assertNotNull(new SimpleSearchPane().selectRepository("local").getExtension(extensionId));
Assert.assertNotNull(new SimpleSearchPane().selectRepository("").getExtension(extensionId));
// Check local extension.
getExtensionTestUtils().uninstall(extensionId.getId(), true);
adminPage = ExtensionAdministrationPage.gotoPage().clickInstalledExtensionsSection();
searchResults = adminPage.getSearchBar().search("alice");
Assert.assertNull(searchResults.getExtension(extensionId));
Assert.assertNotNull(new SimpleSearchPane().selectRepository("local").getExtension(extensionId));
Assert.assertNotNull(new SimpleSearchPane().selectRepository("").getExtension(extensionId));