Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-22409: Add automated test for "Show Page Information Tab (No)" #3629

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import org.junit.jupiter.api.Test;
import org.xwiki.administration.test.po.AdministrablePage;
import org.xwiki.administration.test.po.AdministrationPage;
import org.xwiki.administration.test.po.PresentationAdministrationPage;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.po.InformationPane;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -91,4 +93,27 @@ void verifyAdministrationSections(TestUtils setup, TestReference testReference)
.stream().forEach(sectionId -> assertTrue(pageAdministrationPage.hasNotSection(sectionId),
String.format("Menu section [%s] shouldn't be present.", sectionId)));
}

/**
* Validate that the show information setting of the Presentation section of the administration has an effect.
*
* @since 15.10.14
* @since 16.4.6
* @since 16.10.0RC1
*/
@Test
void showPageInformationTabSettings(TestUtils setup, TestReference testReference)
{
setup.loginAsSuperAdmin();
setup.createPage(testReference, "");
// Check that the information tab is displayed by default.
assertTrue(new InformationPane().exists());
PresentationAdministrationPage adminPage = PresentationAdministrationPage.goToAdminSection();
adminPage.setShowInformation("No");
adminPage.save();
assertEquals("No", adminPage.getShowInformation());

setup.gotoPage(testReference);
assertTrue(new InformationPane().doesNotExist());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.administration.test.po;

import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.By;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.test.ui.po.Select;
import org.xwiki.test.ui.po.ViewPage;

/**
* Page object for the Presentation section of the administration.
*
* @version $Id$
* @since 15.10.14
* @since 16.4.6
* @since 16.10.0RC1
*/
public class PresentationAdministrationPage extends ViewPage
{
/**
* Go to the Presentation section of the administration.
*
* @return a {@link PresentationAdministrationPage} instance
*/
public static PresentationAdministrationPage goToAdminSection()
{
Map<String, Object> queryParameters = new HashMap<>();
queryParameters.put("editor", "globaladmin");
queryParameters.put("section", "Presentation");
DocumentReference reference = new DocumentReference("xwiki", "XWiki", "XWikiPreferences");
getUtil().gotoPage(reference, "admin", queryParameters);
return new PresentationAdministrationPage();
}

/**
* Set the value of the show information field.
*
* @param value {@code No}, {@code Yes} or {@code ---}
*/
public void setShowInformation(String value)
{
getShowInformationSelect().selectByVisibleText(value);
}

/**
* Save the administration page.
*/
public void save()
{
getDriver().findElement(By.cssSelector("#presentation input[value='Save']")).click();
}

/**
* @return the text of the currently selected show information option
*/
public String getShowInformation()
{
return getShowInformationSelect().getFirstSelectedOption().getText();
}

private Select getShowInformationSelect()
{
return new Select(getDriver().findElement(By.id("XWiki.XWikiPreferences_0_showinformation")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class InformationPane extends BaseElement
{
private static final By ORIGINAL_LOCALE_SELECTOR = By.cssSelector("dd[data-key='originalLocale']");

private static final String INFORMATION_TAB_ID = "Informationtab";

@FindBy(id = "informationcontent")
private WebElement pane;

Expand Down Expand Up @@ -131,4 +133,26 @@ public DocumentSyntaxPropertyPane editSyntax()
{
return new DocumentSyntaxPropertyPane().clickEdit();
}

/**
* @return {@code true} if the information tab is found, {@code false} otherwise
* @since 15.10.14
* @since 16.4.6
* @since 16.10.0RC1
*/
public boolean exists()
{
return getDriver().findElements(By.id(INFORMATION_TAB_ID)).size() == 1;
}

/**
* @return {@code true} if the information tab is not found, {@code false} otherwise
* @since 15.10.14
* @since 16.4.6
* @since 16.10.0RC1
*/
public boolean doesNotExist()
{
return getDriver().findElements(By.id(INFORMATION_TAB_ID)).isEmpty();
}
}