int availableTemplateSize = createPagePage.getAvailableTemplateSize();
String templateInstanceName = TEMPLATE_NAME + "Instance";
WYSIWYGEditPage templateInstanceEditWysiwyg =
createPagePage.createPageFromTemplate(getTestClassName(), templateInstanceName, templateProviderFullName);
templateInstanceEditWysiwyg.waitUntilPageIsLoaded();
WikiEditPage templateInstanceEdit = templateInstanceEditWysiwyg.clickSaveAndView().editWiki();
// Verify template instance content
Assert.assertEquals(templateInstanceName, templateInstanceEdit.getTitle());
Assert.assertEquals(templateContent, templateInstanceEdit.getContent());
// check the parent of the template instance
Assert.assertEquals(templateProviderFullName, templateInstanceEdit.getParent());
// Put a wanted link in the template instance
templateInstanceEdit.setContent("[[NewPage]]");
ViewPage vp = templateInstanceEdit.clickSaveAndView();
// Verify that clicking on the wanted link pops up a box to choose the template.
vp.clickWantedLink(getTestClassName(), "NewPage", true);
List<WebElement> templates = getDriver().findElements(By.name("templateprovider"));
// Note: We need to remove 1 to exclude the "Empty Page" template entry
Assert.assertEquals(availableTemplateSize, templates.size() - 1);
Assert.assertTrue(createPagePage.getAvailableTemplates().contains(templateProviderFullName));
// Create a new page from template by going to a non-existing page
// And make sure we're on a non-existing page
Assert.assertFalse(getUtil().gotoPage(getTestClassName(), TEMPLATE_NAME + "UnexistingInstance").exists());
DocumentDoesNotExistPage unexistingPage = new DocumentDoesNotExistPage();
unexistingPage.clickEditThisPageToCreate();
CreatePagePage createUnexistingPage = new CreatePagePage();
// Make sure we're in create mode.
Assert.assertTrue(getUtil().isInCreateMode());
// count the available templates, make sure they're as many as before and that our template is among them
templates = getDriver().findElements(By.name("templateprovider"));
// Note: We need to remove 1 to exclude the "Empty Page" template entry
Assert.assertEquals(availableTemplateSize, templates.size() - 1);
Assert.assertTrue(createPagePage.getAvailableTemplates().contains(templateProviderFullName));
// select it
createUnexistingPage.setTemplate(templateProviderFullName);
// and create
createUnexistingPage.clickCreate();
WYSIWYGEditPage unexistingPageEditWysiwyg = new WYSIWYGEditPage();
unexistingPageEditWysiwyg.waitUntilPageIsLoaded();
WikiEditPage unexistingPageEdit = unexistingPageEditWysiwyg.clickSaveAndView().editWiki();
// Verify template instance content
Assert.assertEquals(TEMPLATE_NAME + "UnexistingInstance", unexistingPageEdit.getTitle());
Assert.assertEquals(templateContent, unexistingPageEdit.getContent());
// test that this page has no parent
Assert.assertEquals("", unexistingPageEdit.getParent());
// create an empty page when there is a template available, make sure it's empty
CreatePagePage createEmptyPage = CreatePagePage.gotoPage();
Assert.assertTrue(createEmptyPage.getAvailableTemplateSize() > 0);
WYSIWYGEditPage editEmptyPage = createEmptyPage.createPage(getTestClassName(), "EmptyPage");