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

53_show_cards_from_suite_contain_failed_cases #54

Open
wants to merge 11 commits 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
25 changes: 14 additions & 11 deletions src/DebbieRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ public function render_reports_html($path)
$failed_Summ = "";
$succ_Summ = "";
$cards_summary_suites = "";
$fatal_error = '';
$type_fail = '';
$is_failed = false;

foreach ($this->reports as $i => $test_suite_reports)
{
Expand Down Expand Up @@ -382,6 +385,7 @@ public function render_reports_html($path)
{
$total_failed++;
$failed++; //count the assert fail of each test per suite
$tests_type_fail[] = $test_case;
}
else if ($assert_report['type'] == 'OK')
{
Expand All @@ -390,15 +394,13 @@ public function render_reports_html($path)
}
else if ($assert_report['type'] == 'ERROR') // fatal error
{
$tests_fatal_error[] = [
'case' => $test_case
];
$tests_fatal_error[] = $test_case;
$failed++;
}
else if ($assert_report['type'] == 'FAIL')
else if ($assert_report['type'] == 'EXCEPTION')
{
$tests_type_fail[] = [
'case' => $test_case
];
$tests_fatal_error[] = $test_case;
$failed++;
}
}
$total_asserts++;
Expand Down Expand Up @@ -467,14 +469,15 @@ public function render_reports_html($path)
$badge = self::get_badge($item, $total_cases_failed, $total_cases_successful);
$fatal_error = self::get_cases_with_fatal_err($item, $tests_fatal_error);
$type_fail = self::get_type_fail($item, $tests_type_fail);

$menu_items .= self::template_report_html()->render('menu_items', [
'item' => $item,
'is_failed' => $is_failed,
'namesSuitessubmenu' => $namesSuitessubmenu,
'badge' => $badge,
'fatal_error' => $fatal_error,
'type_fail' => $type_fail
'type_fail' => $type_fail,
'tests_fatal_error' => $tests_fatal_error,
'tests_type_fail' => $tests_type_fail
]);
}
}
Expand Down Expand Up @@ -875,7 +878,7 @@ public function get_cases_with_fatal_err($item, $tests_fatal_error)
$fatal_error_php = '';
foreach ($tests_fatal_error as $fatal)
{
$suite_error = explode("\\", $fatal["case"]);
$suite_error = explode("\\", $fatal);
if (array_search($item, $suite_error))
{
$fatal_error_php = $suite_error[2];
Expand All @@ -889,7 +892,7 @@ public function get_type_fail($item, $tests_type_fail)
$type_fail = '';
foreach ($tests_type_fail as $fail)
{
$suite_error = explode("\\", $fail["case"]);
$suite_error = explode("\\", $fail);
if (array_search($item, $suite_error))
{
$type_fail = $suite_error[2];
Expand Down
24 changes: 24 additions & 0 deletions tests/suite5/TestCase51.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace tests\suite5;

use \CaboLabs\Debbie\DebbieTestCase;

class TestCase51 extends DebbieTestCase {

public function test_this_is_a_test_5()
{
$a = 1;

$this->assert($a == 1, "This is happening");
}

public function test_this_is_another_test_5()
{
$a = 5;

$this->assert($a == 5, "This is happening");
}
}

?>
20 changes: 20 additions & 0 deletions tests/suite5/TestCase52.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace tests\suite5;

use \CaboLabs\Debbie\DebbieTestCase;

class TestCase52 extends DebbieTestCase {

public function test_this_is_a_test_52()
{
$this->assert(true, "This is happening");
}

public function test_this_is_another_test_52()
{
$this->assert(true, "This is happening");
}
}

?>
20 changes: 20 additions & 0 deletions tests/suite5/TestCase53.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace tests\suite5;

use \CaboLabs\Debbie\DebbieTestCase;

class TestCase53 extends DebbieTestCase {

public function test_this_is_a_test_53()
{
$this->assert(true, "This is happening");
}

public function test_this_is_another_test_53()
{
$this->assert(false, "This is happening");
}
}

?>
2 changes: 1 addition & 1 deletion views/templates/body_report.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="card_tests<?=$names[1] . $i?>" class="card_<?=$names[1]?> suites_test" style="display:none;">
<div class="row row_testcases" id="card_<?=$names[2]?>">
<div class="row row_testcases card_<?=$names[2]?>" id="card_<?=$names[2]?>">
<div class="col-xl-12 col-lg-12">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
Expand Down
2 changes: 1 addition & 1 deletion views/templates/content_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</div>
<!-- Cases failed Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-danger shadow h-100 py-2">
<div class="card border-left-danger shadow h-100 py-2 card_fail_dashboard">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
Expand Down
95 changes: 77 additions & 18 deletions views/templates/layout_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,61 @@
crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script>
$(document).ready(function() {
// TODO: add a minimized version of the JS
$("li.nav-item").on("click", function (e)
$('.nav-item a[style*="color:red"]').each(function(){
let txt_test_fail = $(this).text();
$('.card_' + txt_test_fail).addClass("fail_card");
});

$(".card_fail_dashboard").on("click", function ()
{
$(this).toggleClass('border-danger active_card_fail');
get_all_card_fail(".card_fail_dashboard");
});

$(".card_fail_suite").on("click", function ()
{
$(this).toggleClass('border-danger active_card_fail_suite');
get_suite_card_fail(".card_fail_suite");
});

function get_all_card_fail(class_card_fail)
{
if ($(class_card_fail).hasClass('active_card_fail'))
{
$("#cardSummaryTables").hide();
$(".suites_test:has(.fail_card)").show();
$("#Card_suites").show();
}
else
{
$(".suites_test:has(.fail_card)").hide();
$("#cardSummaryTables").show();
}
}

function get_suite_card_fail(class_card_fail_suite)
{
if ($(class_card_fail_suite).hasClass('active_card_fail_suite'))
{
$(".card_succes").hide();
}
else
{
$(".card_succes").show();
}
}

$("li.nav-item").on("click", function ()
{
var id_li = $("a", this).attr("id");
var class_card = 'card_' + id_li;

if (id_li === 'dashboard')
{
$('.card_fail_dashboard').removeClass('active_card_fail');
$('.card_fail_dashboard').removeClass('border-danger');
$('#cardSummaryTables').show();
$('#headCardSummary').show();
$(this).addClass("active");
Expand All @@ -79,14 +126,15 @@
if ($('li > div').hasClass('show'))
{
$('li > div').collapse('hide');
console.log($('li > div'));
}
}
else if (id_li === class_card.substring(5))
{
clean_class(class_card);
$('#Card_suites').show();
$('#title_suite').show();
$('#title_suite').html(id_li);
set_class_successful(class_card);
$('#Card_suites').find('.' + class_card).show();
$(this).addClass("active");

Expand Down Expand Up @@ -144,37 +192,48 @@

function AllSuite(id_li , class_card)
{
if (id_li === 'dashboard')
{
$('#cardSummaryTables').show();
$('#headCardSummary').show();

$(this).addClass("active");
$('#title_suite').hide();
$('#Card_suites').hide();

if ($('li > div').hasClass('show'))
{
$('li > div').collapse('hide');
}
}
else if (id_li === class_card.substring(5))
clean_class(class_card);
if (id_li === class_card.substring(5))
{
$(this).addClass("active");
$('#Card_suites').show();
$('#title_suite').show();
$('#title_suite').html(id_li);
$('#card_summary_' + id_li).show();
$('.suites_test').show();
set_class_successful(class_card);
$('#Card_suites').find('.' + class_card).show();


$('.suites_test').not('.' + class_card).hide();
$('.card_summary_suites').not('#card_summary_' + id_li).hide();
$('#headCardSummary').hide();
$('#cardSummaryTables').hide();
}
}

function set_class_successful(class_card) {
var card_suite = $('#Card_suites').find('.row_testcases');

if ($('.card_suite:not(.fail_card)'))
{
card_suite.addClass('card_succes');
}

$('.fail_card').each(function() {
if ($(this).hasClass('card_succes')) {
$(this).removeClass('card_succes');
}
});
}

function clean_class(class_card) {
var card_suite = $('.suites_test');
if (card_suite.hasClass('card_succes'))
{
card_suite.removeClass('card_succes');
}
}
});
</script>
</body>
</html>
5 changes: 3 additions & 2 deletions views/templates/menu_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<a id="<?=$item?>" class="nav-link collapsed" href="#" data-toggle="collapse"
data-target="#collapseUtilities_<?=$item?>" aria-expanded="true" aria-controls="collapseUtilities">
<?php $style_item = "fa-fw fa fa-check text-success"; ?>
<?php $color = "green"; ?>
<?php if ($is_failed || $fatal_error || $type_fail) : ?>
<?php $style_item = "fa-fw fas fa-times text-warning"; ?>
<?php endif; ?>
Expand All @@ -19,8 +18,10 @@
<?php foreach ($namesSuitessubmenu as $submenu): ?>
<?php $suites = explode("\\", $submenu); ?>
<?php if (in_array($item, $suites)): ?>
<?php if ($fatal_error == $suites[2] || $type_fail == $suites[2] || $is_failed) : ?>
<?php if (in_array($submenu, $tests_fatal_error) || in_array($submenu, $tests_type_fail)) : ?>
<?php $color = "red"; ?>
<?php else: ?>
<?php $color = "green"; ?>
<?php endif; ?>
<a id="<?=$suites[2]?>" class="text-truncate collapse-item" style="max-width: 175px; color:<?=$color?>" href="#" title="<?=$suites[2]?>"><?=$suites[2]?></a>
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion views/templates/summary_suite.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<!-- test failed Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-danger shadow h-100 py-2">
<div class="card border-left-danger shadow h-100 py-2 card_fail_suite">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
Expand Down