Package org.xwiki.test.ui.po

Examples of org.xwiki.test.ui.po.CreatePagePage


        String templateProviderFullName = getTestClassName() + "." + templateProviderName;

        ViewPage templateProviderView = createTemplate(templateProviderName, templateContent, templateTitle, false);

        // Create the new document from template
        CreatePagePage createPagePage = templateProviderView.createPage();
        // Save the number of available templates so that we can make some checks later on.
        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");
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        // wait to load editor to make sure that what we're saving is the content that is supposed to be in this
        // document
        editEmptyPage.waitUntilPageIsLoaded();
        ViewPage emptyPage = editEmptyPage.clickSaveAndView();
View Full Code Here


        String existingSpace = this.getClass().getSimpleName() + ((int) (Math.random() * 1000));
        getUtil().createPage(existingSpace, "WebHome", "{{spaceindex /}}", "New random space");

        // 1/ create an empty page that already exists
        HomePage homePage = HomePage.gotoPage();
        CreatePagePage createPage = homePage.createPage();
        createPage.setSpace(space);
        createPage.setPage(existingPageName);
        String currentURL = getDriver().getCurrentUrl();
        createPage.clickCreate();
        // make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
        // error
        Assert.assertEquals(currentURL, getDriver().getCurrentUrl());
        createPage.waitForErrorMessage();

        // 2/ create a page from template that already exists
        // restart everything to make sure it's not the error before
        homePage = HomePage.gotoPage();
        createPage = homePage.createPage();
        createPage.setSpace(space);
        createPage.setPage(existingPageName);
        createPage.setTemplate(space + "." + templateProviderName);
        currentURL = getDriver().getCurrentUrl();
        createPage.clickCreate();
        // make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
        // error
        Assert.assertEquals(currentURL, getDriver().getCurrentUrl());
        createPage.waitForErrorMessage();

        // 3/ create a space that already exists
        homePage = HomePage.gotoPage();
        CreateSpacePage createSpace = homePage.createSpace();
        currentURL = getDriver().getCurrentUrl();
View Full Code Here

        Assert.assertEquals(space, editNewUnexistingPage.getMetaDataValue("space"));
        Assert.assertEquals("NewUnexistingPage", editNewUnexistingPage.getMetaDataValue("page"));

        // 2/ create a page from the create menu on an existing page, by filling in space and name
        ViewPage spaceHomePage = getUtil().gotoPage(space, "WebHome");
        CreatePagePage createNewPage = spaceHomePage.createPage();
        // we expect no templates available
        Assert.assertEquals(0, createNewPage.getAvailableTemplateSize());
        // fill in data and create the page
        createNewPage.setSpace(space);
        createNewPage.setPage("NewPage");
        createNewPage.clickCreate();
        // we expect to go to the edit mode of the new page
        Assert.assertFalse(getUtil().isInCreateMode());
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        WYSIWYGEditPage editNewPage = new WYSIWYGEditPage();
        editNewPage.waitUntilPageIsLoaded();
View Full Code Here

        String templateTitle = "Funny templates";
        String templateProviderFullName = space + "." + templateProviderName;
        ViewPage templatePage = createTemplate(templateProviderName, templateContent, templateTitle, true);

        // create the page
        CreatePagePage createPage = templatePage.createPage();
        WYSIWYGEditPage editCreatedPage =
            createPage.createPageFromTemplate(space, newPageName, templateProviderFullName);
        // ensure that we're indeed in edit mode
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        // wait for editor to load (so that content is loaded)
        editCreatedPage.waitUntilPageIsLoaded();
        // and now cancel it
View Full Code Here

     */
    @Test
    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146")
    public void testCreateNonAsciiPage()
    {
        CreatePagePage createPagePage = this.homePage.createPage();
        WYSIWYGEditPage editPage = createPagePage.createPage("Main", "\u0219");

        // Verify the title field
        Assert.assertEquals("\u0219", editPage.getDocumentTitle());

        // Verify the document name in the metadata
View Full Code Here

TOP

Related Classes of org.xwiki.test.ui.po.CreatePagePage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.