Commit 03d1f202 authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

🚸 Improve initial opening state of event items in profiler

The item is initially open if :
- it is a failed or orphaned event
- it is the first successful event and there is no other failed or orphaned event in the same list
parent abf4eb02
......@@ -159,7 +159,11 @@
{% for event in collector.events %}
{{ helper.render_event_table(
event,
collector.nbFailedEvents == 0 and loop.index0 == 0,
event.failed
or event.projections | length == 0
or collector.nbFailedEvents == 0
and collector.nbOrphanedEvents == 0
and loop.index0 == 0,
collector
) }}
{% endfor %}
......@@ -217,7 +221,7 @@
{% if event.failed %}
{{ helper.render_event_table(
event,
false,
true,
collector
) }}
{% endif %}
......@@ -249,7 +253,7 @@
{% if event.projections | length == 0 %}
{{ helper.render_event_table(
event,
not first_seen,
true,
collector
) }}
{% set first_seen = true %}
......@@ -282,7 +286,7 @@
<tr>
<th colspan="2" class="sf-toggle"
data-toggle-selector="#dispatched-event-item-{{ discr }}-details"
data-toggle-initial="{{ open or event.failed ? 'display' }}"
data-toggle-initial="{{ open ? 'display' }}"
>
<span class="dump-inline">
{{ profiler_dump(collector.classStub(event.type)) }}
......
......@@ -279,6 +279,90 @@ class DataCollectorTest extends KernelTestCase
]);
}
public function test_event_item_initial_opening_state()
{
$successful = new DispatchedEvent(
$event = new EventStub(),
$caller = new Caller('/path/to/file.php', 42)
);
$successful->projectionStarted(new ProjectionStub());
usleep(1);
$successful->projectionSucceeded();
$successful->dispatched();
$failed = new DispatchedEvent(
$event = new EventStub(),
$caller = new Caller('/path/to/file.php', 42)
);
$failed->projectionStarted(new ProjectionStub());
usleep(1);
$failed->projectionFailed(new Exception());
$failed->dispatched();
$orphaned = new DispatchedEvent(
new EventStub(),
new Caller('/path/to/file2.php', 43)
);
usleep(1);
$orphaned->dispatched();
[, , $panel] = $this->getCrawlers(
new WebfProjectionsDataCollectorStub([
'nb_events' => 6,
'nb_successful_events' => 2,
'nb_failed_events' => 2,
'nb_orphaned_events' => 2,
'nb_event_types' => 1,
'nb_total_event_types' => 3,
'nb_projections' => 1,
'nb_total_projections' => 2,
'execution_time' => 123.456,
'events' => [$successful, $failed, $orphaned, $successful, $failed, $orphaned],
])
);
// There are failed/orphaned events so the first event (which is successful) is closed in the "All" tab
$ths = $panel->filter('.tab.all .dispatched-event-item thead .sf-toggle');
$this->assertEmpty($ths->eq(0)->attr('data-toggle-initial'));
$this->assertEquals('display', $ths->eq(1)->attr('data-toggle-initial'));
$this->assertEquals('display', $ths->eq(2)->attr('data-toggle-initial'));
$this->assertEmpty($ths->eq(3)->attr('data-toggle-initial'));
$this->assertEquals('display', $ths->eq(4)->attr('data-toggle-initial'));
$this->assertEquals('display', $ths->eq(5)->attr('data-toggle-initial'));
$ths = $panel->filter('.tab.successful .dispatched-event-item thead .sf-toggle');
$this->assertEquals('display', $ths->eq(0)->attr('data-toggle-initial'));
$this->assertEmpty($ths->eq(1)->attr('data-toggle-initial'));
$ths = $panel->filter('.tab.failed .dispatched-event-item thead .sf-toggle');
$this->assertEquals('display', $ths->eq(0)->attr('data-toggle-initial'));
$this->assertEquals('display', $ths->eq(1)->attr('data-toggle-initial'));
$ths = $panel->filter('.tab.orphaned .dispatched-event-item thead .sf-toggle');
$this->assertEquals('display', $ths->eq(0)->attr('data-toggle-initial'));
$this->assertEquals('display', $ths->eq(1)->attr('data-toggle-initial'));
[, , $panel] = $this->getCrawlers(
new WebfProjectionsDataCollectorStub([
'nb_events' => 2,
'nb_successful_events' => 2,
'nb_failed_events' => 0,
'nb_orphaned_events' => 0,
'nb_event_types' => 1,
'nb_total_event_types' => 3,
'nb_projections' => 1,
'nb_total_projections' => 2,
'execution_time' => 123.456,
'events' => [$successful, $successful],
])
);
// There is only successful events so the first one is open in the "All" tab
$ths = $panel->filter('.tab.all .dispatched-event-item thead .sf-toggle');
$this->assertEquals('display', $ths->eq(0)->attr('data-toggle-initial'));
$this->assertEmpty($ths->eq(1)->attr('data-toggle-initial'));
}
/**
* @return Crawler[]
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment