Package org.xwiki.test.ui.framework.elements.editor

Examples of org.xwiki.test.ui.framework.elements.editor.WikiEditPage


        getUtil().deletePage(space, TEMPLATE_NAME + "Provider");

        String templateFullName = space + "." + TEMPLATE_NAME;

        // Create a template
        WikiEditPage editTemplatePage = new WikiEditPage();
        editTemplatePage.switchToEdit(space, TEMPLATE_NAME);
        editTemplatePage.setTitle(templateTitle);
        editTemplatePage.setContent(templateContent);
        editTemplatePage.clickSaveAndView();

        // Create the template provider
        TemplatesAdministrationSectionPage sectionPage = new TemplatesAdministrationSectionPage();
        sectionPage.gotoPage();
        TemplateProviderInlinePage templateProviderInline =
View Full Code Here


        // 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);
        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();
        // make sure we're in create mode
        Assert.assertTrue(getUtil().isInCreateMode());
        CreatePagePage createUnexistingPage = new CreatePagePage();
        // 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();
        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 = new CreatePagePage();
        createEmptyPage.gotoPage();
        Assert.assertTrue(createEmptyPage.getAvailableTemplateSize() > 0);
View Full Code Here

    public void testCreatePageWhenNoTemplateAvailable()
    {
        // prepare the test environment, create a test space and exclude all templates for this space
        String space = this.getClass().getSimpleName();
        // create the webhome of this space to make sure the space exists
        WikiEditPage editTemplatePage = new WikiEditPage();
        editTemplatePage.switchToEdit(space, "WebHome");
        editTemplatePage.setTitle("Welcome to the templates test space");
        editTemplatePage.setContent("You can have fun with templates here");
        editTemplatePage.clickSaveAndView();
        // we'll create all these pages during this test
        getUtil().deletePage(space, "NewUnexistingPage");
        getUtil().deletePage(space, "NewPage");
        getUtil().deletePage(space, "NewLinkedPage");
        // go through all the templates and make sure they are disabled on this space
        TemplatesAdministrationSectionPage sectionPage = new TemplatesAdministrationSectionPage();
        sectionPage.gotoPage();

        // get the links to existing templates, navigate to each of them and disable the current space
        List<String> spacesToExclude = new ArrayList<String>();
        spacesToExclude.add(space);
        List<WebElement> existingTemplatesLinks = sectionPage.getExistingTemplatesLinks();
        for (int i = 0; i < existingTemplatesLinks.size(); i++) {
            WebElement link = existingTemplatesLinks.get(i);
            link.click();
            ViewPage templateViewPage = new ViewPage();
            templateViewPage.editInline();
            TemplateProviderInlinePage providerEditPage = new TemplateProviderInlinePage();
            providerEditPage.excludeSpaces(spacesToExclude);
            providerEditPage.clickSaveAndView();

            // go back to the admin page, to leave this in a valid state
            sectionPage.gotoPage();
            existingTemplatesLinks = sectionPage.getExistingTemplatesLinks();
        }

        // TODO: should reset these template settings at the end of the test, to leave things in the same state as they
        // were at the beginning of the test

        // and now start testing!

        // 1/ create a page from the link in the page displayed when navigating to a non-existing page
        Assert.assertFalse(getUtil().gotoPage(space, "NewUnexistingPage").exists());
        DocumentDoesNotExistPage nonExistingPage = new DocumentDoesNotExistPage();
        nonExistingPage.clickEditThisPageToCreate();
        // make sure we're not in create mode anymore
        Assert.assertFalse(getUtil().isInCreateMode());
        // make sure we're directly in edit mode
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        // TODO: check that we're indeed in the edit mode of space.NewUnexitingPage
        WYSIWYGEditPage editNewUnexistingPage = new WYSIWYGEditPage();
        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();
        Assert.assertEquals(space, editNewPage.getMetaDataValue("space"));
        Assert.assertEquals("NewPage", editNewPage.getMetaDataValue("page"));

        // 3/ create a page from a link in another page
        // we're in edit mode of the newly created page from template
        WYSIWYGEditPage editNewPageWysiwyg = new WYSIWYGEditPage();
        // sometimes this fails to find the edit button, for a reason for which I don't understand...
        WikiEditPage editNewPageWiki = editNewPageWysiwyg.clickSaveAndView().editWiki();
        // put a link to the new page to create
        editNewPageWiki.setContent("[[NewLinkedPage]]");
        ViewPage newPage = editNewPageWiki.clickSaveAndView();
        // no templates are available, so we don't expect a panel with a list of templates, we just expect it goes
        // directly to edit mode of the new page
        // it would be nice to be able to test here that the create page panel is not displayed, ever. However, we can't
        // since we need to wait for that time, and we don't know how much is never.
        newPage.clickWantedLink(space, "NewLinkedPage", false);
View Full Code Here

     * Performs a click on the "edit wiki" entry of the content menu.
     */
    public WikiEditPage editWiki()
    {
        clickContentMenuEditSubMenuEntry("tmEditWiki");
        return new WikiEditPage();
    }
View Full Code Here

        // Create first version of the page
        ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);

        // Adds second version
        WikiEditPage wikiEditPage = vp.editWiki();
        wikiEditPage.setContent(CONTENT2);
        wikiEditPage.clickSaveAndView();

        // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
        // view mode) is fixed.
        vp.waitForDocExtraPaneActive("comments");
View Full Code Here

    @Before
    @Override
    public void setUp()
    {
        super.setUp();
        this.editPage = new WikiEditPage();
        getUtil().deletePage("Test", "EditWikiTest");
    }
View Full Code Here

    }

    @Test
    public void testChangeLanguageInMonolingualModeUsingTheAdministrationPreference()
    {
        WikiEditPage edit = new WikiEditPage();
        edit.switchToEdit("Test", "LanguageTest");
        edit.setContent("{{velocity}}context = ($context.language), doc = ($doc.language), "
            + "default = ($doc.defaultLanguage), tdoc = ($tdoc.language), "
            + "tdocdefault = ($tdoc.defaultLanguage){{/velocity}}");
        ViewPage vp = edit.clickSaveAndView();

        // Current language must be "en"
        Assert.assertEquals("Invalid content", vp.getContent(),
            "context = (en), doc = (), default = (en), tdoc = (), tdocdefault = (en)");
View Full Code Here

        final String space = "Main";
        final String page = "POSTTest";
        LoginPage loginPage = this.vp.login();
        loginPage.loginAsAdmin();
        // start editing a page
        WikiEditPage editPage = new WikiEditPage();
        editPage.switchToEdit(space, page);
        editPage.setTitle(test);
        editPage.setContent(test);
        // emulate expired session: delete the cookies
        getDriver().manage().deleteAllCookies();
        // try to save
        editPage.clickSaveAndView();
        // we should have been redirected to login
        String wantUrl = getUtil().getURL("XWiki", "XWikiLogin", "login");
        if (wantUrl.indexOf('?') > 0) {
            // strip parameters
            wantUrl = wantUrl.substring(0, wantUrl.indexOf('?'));
        }
        Assert.assertTrue(getDriver().getCurrentUrl().startsWith(wantUrl));
        loginPage.loginAsAdmin();
        // we should have been redirected back to view, and the page should have been saved
        Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL(space, page)));
        editPage.switchToEdit(space, page);
        Assert.assertEquals(test, editPage.getTitle());
        Assert.assertEquals(test, editPage.getContent());
    }
View Full Code Here

    {
        String initialContent = null;
        try {
            ProfileUserProfilePage pupp = new ProfileUserProfilePage("Admin");
            pupp.gotoPage();
            WikiEditPage wep = pupp.editWiki();
            initialContent = wep.getContent();
            wep.setContent("{{velocity}}$xcontext.setDisplayMode('edit'){{/velocity}}\n" + initialContent);
            wep.clickSaveAndView();
            Assert.assertTrue(getDriver().getPageSource().contains("XWiki.XWikiUsers_0_last_name"));
        } finally {
            if (initialContent != null) {
                getUtil().gotoPage("XWiki", "Admin", "save", "content=" + initialContent);
            }
View Full Code Here

        String spaceName = getTestClassName() + "&";
        // Make sure the space WebHome page doesn't exist.
        getUtil().deletePage(spaceName, "WebHome");

        // Create Space with a URL-reserved character in the Space name.
        WikiEditPage editPage = new WikiEditPage();
        editPage.switchToEdit(spaceName, "WebHome");
        editPage.setContent("Content");
        editPage.clickSaveAndView();

        // Navigate to the Home Page and click on the SpaceIndex.
        HomePage homePage = new HomePage();
        homePage.gotoPage();
        homePage.getSpacesPane().clickSpaceIndex(spaceName);
View Full Code Here

TOP

Related Classes of org.xwiki.test.ui.framework.elements.editor.WikiEditPage

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.