<commit_before>/*
 * 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.test.selenium;

import junit.framework.Test;

import org.xwiki.test.selenium.framework.AbstractXWikiTestCase;
import org.xwiki.test.selenium.framework.ColibriSkinExecutor;
import org.xwiki.test.selenium.framework.XWikiTestSuite;

/**
 * Verify the overall Administration application features.
 * 
 * @version $Id$
 */
public class AdministrationTest extends AbstractXWikiTestCase
{
    public static Test suite()
    {
        XWikiTestSuite suite = new XWikiTestSuite("Verify the Administration application features.");
        suite.addTestSuite(AdministrationTest.class, ColibriSkinExecutor.class);
        return suite;
    }

    public void setUp() throws Exception
    {
        super.setUp();
        loginAsAdmin();
    }

    /**
     * This method makes the following tests :
     * 
     * <ul>
     * <li>Login as global admin.</li>
     * <li>Validate presence of default sections for global and space sections.</li>
     * <li>Validate presence of application administration sections at global level only.</li>
     * </ul>
     */
    public void testGlobalAndSpaceSections()
    {
        clickLinkWithText("Administer Wiki");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=General')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Presentation')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Registration')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Programming')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Rights')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Users')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Groups')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Import')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Export')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Panels.PanelWizard')]");

        // select space administration
        getSelenium().select("goto-select", "label=Main");
        waitPage();
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Presentation')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Rights')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Panels.PanelWizard')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=General')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Registration')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Programming')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Users')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Groups')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Import')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Export')]");
    }

    /*
     * Test to see an application page is included only if that application exists
     */
    public void testApplicationSection()
    {
        // Delete the Blog.Categories page and test it's not present in the admin global menu anymore
        deletePage("XWiki", "SearchAdmin");
        clickLinkWithText("Administer Wiki");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Search')]");
        restorePage("XWiki", "SearchAdmin");
    }

    /*
     * Test modifying XWiki.XWikiPreferences multi-language field and save it.
     */
    public void testSettingXWikiPreferences()
    {
        clickLinkWithText("Administer Wiki");
        getSelenium().select("goto-select", "label=Wiki administration");
        clickLinkWithXPath("//a[text()='General']", true);
        getSelenium().select("//select[@name='XWiki.XWikiPreferences_0_multilingual']", "label=Yes");<commit_msg>[misc] Fixed failing tests<commit_after>/*
 * 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.test.selenium;

import junit.framework.Test;

import org.xwiki.test.selenium.framework.AbstractXWikiTestCase;
import org.xwiki.test.selenium.framework.ColibriSkinExecutor;
import org.xwiki.test.selenium.framework.XWikiTestSuite;

/**
 * Verify the overall Administration application features.
 * 
 * @version $Id$
 */
public class AdministrationTest extends AbstractXWikiTestCase
{
    public static Test suite()
    {
        XWikiTestSuite suite = new XWikiTestSuite("Verify the Administration application features.");
        suite.addTestSuite(AdministrationTest.class, ColibriSkinExecutor.class);
        return suite;
    }

    @Override
    public void setUp() throws Exception
    {
        super.setUp();
        loginAsAdmin();
    }

    /**
     * This method makes the following tests :
     * 
     * <ul>
     * <li>Login as global admin.</li>
     * <li>Validate presence of default sections for global and space sections.</li>
     * <li>Validate presence of application administration sections at global level only.</li>
     * </ul>
     */
    public void testGlobalAndSpaceSections()
    {
        clickLinkWithText("Administer Wiki");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Editing')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Localization')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Programming')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Email')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Presentation')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Elements')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Registration')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Users')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Groups')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Rights')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Registration')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Import')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Export')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Templates')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=MessageStream')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Panels.PanelWizard')]");

        // select space administration
        getSelenium().select("goto-select", "label=Main");
        waitPage();
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Editing')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Localization')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Programming')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Email')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Presentation')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Elements')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Registration')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Users')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Groups')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Rights')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Registration')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Import')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Export')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Templates')]");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=MessageStream')]");
        assertElementPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Panels.PanelWizard')]");
    }

    /*
     * Test to see an application page is included only if that application exists
     */
    public void testApplicationSection()
    {
        // Delete the Blog.Categories page and test it's not present in the admin global menu anymore
        deletePage("XWiki", "SearchAdmin");
        clickLinkWithText("Administer Wiki");
        assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Search')]");
        restorePage("XWiki", "SearchAdmin");
    }

    /*
     * Test modifying XWiki.XWikiPreferences multi-language field and save it.
     */
    public void testSettingXWikiPreferences()
    {
        clickLinkWithText("Administer Wiki");
        getSelenium().select("goto-select", "label=Wiki administration");
        clickLinkWithXPath("//a[text()='Localization']", true);
        getSelenium().select("//select[@name='XWiki.XWikiPreferences_0_multilingual']", "label=Yes");
{'fraction_non_alphanumeric': 0.17272200612430688, 'fraction_numerical': 0.00231730530497393, 'mean_word_length': 4.293035479632063, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '538787', 'n_tokens_mistral': 3484, 'n_tokens_neox': 3430, 'n_words': 729}