<commit_before># --
# 000-JSUnitTest.t - frontend tests that collect the JavaScript unit test results
# Copyright (C) 2001-2010 OTRS AG, http://otrs.org/
# --
# $Id: 000-JSUnitTest.t,v 1.2 2010-12-21 14:18:51 mg Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

use strict;
use warnings;

use vars qw($Self);

use Kernel::Config;
use Kernel::System::User;

use Kernel::System::UnitTest::Selenium;
use Time::HiRes qw(sleep);

if ( !$Self->{ConfigObject}->Get('SeleniumTestsActive') ) {
    $Self->True( 1, 'Selenium testing is not active' );
    return 1;
}

my $sel = Kernel::System::UnitTest::Selenium->new(
    Verbose        => 1,
    UnitTestObject => $Self,
);

my $WebPath = $Self->{ConfigObject}->Get('Frontend::WebPath');

$sel->open_ok("${WebPath}js/test/JSUnitTest.html");
$sel->wait_for_page_to_load_ok("30000");

# wait for the javascript tests (including AJAX) to complete
$sel->set_timeout_ok("3000");

$sel->is_element_present_ok("css=p.result span.failed");
$sel->is_element_present_ok("css=p.result span.passed");
$sel->is_element_present_ok("css=p.result span.total");

if (
    !eval {
        my ( $Passed, $Failed, $Total );
        $Passed = $sel->get_eval(
            "this.browserbot.getCurrentWindow().\$('p.result span.passed').text()"
        );
        $Failed = $sel->get_eval(
            "this.browserbot.getCurrentWindow().\$('p.result span.failed').text()"
        );
        $Total
            = $sel->get_eval("this.browserbot.getCurrentWindow().\$('p.result span.total').text()");

        $Self->True( $Passed, 'Found passed tests' );
        $Self->Is( $Passed, $Total, 'Total number of tests' );
        $Self->False( $Failed, 'Failed tests' );

        for my $Test ( 1 .. $Passed ) {
            $Self->True( 1, 'Successful JavaScript unit test found' );
        }

        for my $Test ( 1 .. $Failed ) {
            $Self->True( 0, 'Failed JavaScript unit test found' );
        }
<commit_msg>Added error message.<commit_after># --
# 000-JSUnitTest.t - frontend tests that collect the JavaScript unit test results
# Copyright (C) 2001-2010 OTRS AG, http://otrs.org/
# --
# $Id: 000-JSUnitTest.t,v 1.3 2010-12-21 14:23:15 mg Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

use strict;
use warnings;

use vars qw($Self);

use Kernel::Config;
use Kernel::System::User;

use Kernel::System::UnitTest::Selenium;
use Time::HiRes qw(sleep);

if ( !$Self->{ConfigObject}->Get('SeleniumTestsActive') ) {
    $Self->True( 1, 'Selenium testing is not active' );
    return 1;
}

my $sel = Kernel::System::UnitTest::Selenium->new(
    Verbose        => 1,
    UnitTestObject => $Self,
);

my $WebPath = $Self->{ConfigObject}->Get('Frontend::WebPath');

$sel->open_ok("${WebPath}js/test/JSUnitTest.html");
$sel->wait_for_page_to_load_ok("30000");

# wait for the javascript tests (including AJAX) to complete
$sel->set_timeout_ok("3000");

$sel->is_element_present_ok("css=p.result span.failed");
$sel->is_element_present_ok("css=p.result span.passed");
$sel->is_element_present_ok("css=p.result span.total");

if (
    !eval {
        my ( $Passed, $Failed, $Total );
        $Passed = $sel->get_eval(
            "this.browserbot.getCurrentWindow().\$('p.result span.passed').text()"
        );
        $Failed = $sel->get_eval(
            "this.browserbot.getCurrentWindow().\$('p.result span.failed').text()"
        );
        $Total
            = $sel->get_eval("this.browserbot.getCurrentWindow().\$('p.result span.total').text()");

        $Self->True( $Passed, 'Found passed tests' );
        $Self->Is( $Passed, $Total, 'Total number of tests' );
        $Self->False( $Failed, 'Failed tests' );

        for my $Test ( 1 .. $Passed ) {
            $Self->True( 1, 'Successful JavaScript unit test found' );
        }

        for my $Test ( 1 .. $Failed ) {
            $Self->True(
                0,
                'Failed JavaScript unit test found (open js/test/JSUnitTest.html in your browser for details)'
            );
        }

{'fraction_non_alphanumeric': 0.17136258660508083, 'fraction_numerical': 0.021247113163972285, 'mean_word_length': 3.0704887218045114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 47, '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': '510848', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1444, 'n_words': 335}