<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.wysiwyg.test.ui;

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

import org.junit.*;
import org.openqa.selenium.By;
import org.xwiki.test.ui.AbstractTest;
import org.xwiki.test.ui.SuperAdminAuthenticationRule;
import org.xwiki.test.ui.po.FormElement;
import org.xwiki.test.ui.po.editor.ObjectEditPage;
import org.xwiki.wysiwyg.test.po.WYSIWYGEditPage;

/**
 * Base class for WYSIWYG Editor tests.
 * 
 * @version $Id$
 * @since 5.1RC1
 */
public abstract class AbstractWYSIWYGEditorTest extends AbstractTest
{
    @Rule
    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil(), getDriver());

    /**
     * The edited page.
     */
    protected WYSIWYGEditPage editPage;

    @BeforeClass
    public static void configure()
    {
        enableAllEditingFeatures();
    }

    @Before
    public void setUp() throws Exception
    {
        editPage = WYSIWYGEditPage.gotoPage(getTestClassName(), getTestMethodName()).waitUntilPageIsLoaded();
    }

    /**
     * Enables all editing features so they are accessible for testing.
     */
    private static void enableAllEditingFeatures()
    {
        Map<String, String> config = new HashMap<String, String>();<commit_msg>[Misc] Use superadmin for the tests instead of requiring XWiki.Admin which we want to remove from administration-ui * Fix WYSIWYG test which required authenticate before configure() executes<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.wysiwyg.test.ui;

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

import org.junit.*;
import org.openqa.selenium.By;
import org.xwiki.test.ui.AbstractTest;
import org.xwiki.test.ui.SuperAdminAuthenticationRule;
import org.xwiki.test.ui.po.FormElement;
import org.xwiki.test.ui.po.editor.ObjectEditPage;
import org.xwiki.wysiwyg.test.po.WYSIWYGEditPage;

/**
 * Base class for WYSIWYG Editor tests.
 * 
 * @version $Id$
 * @since 5.1RC1
 */
public abstract class AbstractWYSIWYGEditorTest extends AbstractTest
{
    // Note: We do not use the @Rule annotation since we need this rule to be executed before the configure() method
    // below which runs **before** any @Rule (since it's tagged with @BeforeClass). Thus we trigger the authentication
    // manually.
    public static SuperAdminAuthenticationRule authenticationRule =
        new SuperAdminAuthenticationRule(getUtil(), getDriver());

    /**
     * The edited page.
     */
    protected WYSIWYGEditPage editPage;

    @BeforeClass
    public static void configure()
    {
        authenticationRule.authenticate();
        enableAllEditingFeatures();
    }

    @Before
    public void setUp() throws Exception
    {
        editPage = WYSIWYGEditPage.gotoPage(getTestClassName(), getTestMethodName()).waitUntilPageIsLoaded();
    }

    /**
     * Enables all editing features so they are accessible for testing.
     */
    private static void enableAllEditingFeatures()
    {
        Map<String, String> config = new HashMap<String, String>();
{'fraction_non_alphanumeric': 0.08263598326359832, 'fraction_numerical': 0.0066945606694560665, 'mean_word_length': 3.7010816125860373, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7666849', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1300, 'n_words': 502}