Commit 91a1e461 authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

🐛 Fix orphaned events showing up in the successful tab of profiler

parent 03d1f202
......@@ -186,7 +186,7 @@
{% if collector.nbSuccessfulEvents > 0 %}
{% set first_seen = false %}
{% for event in collector.events %}
{% if not event.failed %}
{% if not event.failed and event.projections | length > 0 %}
{{ helper.render_event_table(
event,
not first_seen,
......
......@@ -227,28 +227,37 @@ class DataCollectorTest extends KernelTestCase
]);
}
public function test_colors_when_there_are_failed_and_orphaned_events()
public function test_all_events()
{
$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($projection = new ProjectionStub());
$failed->projectionStarted(new ProjectionStub());
usleep(1);
$failed->projectionFailed(new Exception());
$failed->dispatched();
$orphaned = new DispatchedEvent(
new EventStub(),
new Caller('/path/to/file2.php', 43)
$event = new EventStub(),
$caller = new Caller('/path/to/file.php', 42)
);
usleep(1);
$orphaned->dispatched();
[$toolbar, $menu] = $this->getCrawlers(
[$toolbar, $menu, $panel] = $this->getCrawlers(
new WebfProjectionsDataCollectorStub([
'nb_events' => 2,
'nb_successful_events' => 0,
'nb_events' => 3,
'nb_successful_events' => 1,
'nb_failed_events' => 1,
'nb_orphaned_events' => 1,
'nb_event_types' => 1,
......@@ -256,27 +265,42 @@ class DataCollectorTest extends KernelTestCase
'nb_projections' => 1,
'nb_total_projections' => 2,
'execution_time' => 123.456,
'events' => [$failed, $orphaned],
'events' => [$successful, $failed, $orphaned],
])
);
$this->assertToolbarData($toolbar, [
'status' => 'red',
'icon' => '2 in 123.46 ms',
'icon' => '3 in 123.46 ms',
'info_pieces' => [
'successful' => ['value' => '0', 'status' => 'normal'],
'successful' => ['value' => '1', 'status' => 'green'],
'failed' => ['value' => '1', 'status' => 'red'],
'orphaned' => ['value' => '1', 'status' => 'yellow'],
'total' => ['value' => '2', 'status' => 'normal'],
'total' => ['value' => '3', 'status' => 'normal'],
'execution-time' => ['value' => '123.46 ms', 'status' => false],
],
]);
$this->assertMenuData($menu, [
'count' => '2',
'count' => '3',
'disabled' => false,
'status' => 'error',
]);
$this->assertPanelData($panel, [
'projection_metrics' => [
'nb-events' => '3',
'nb-event-types' => '1/3',
'nb-projections' => '1/2',
'execution-time' => '123.46 ms',
],
'dispatched_events' => [
'all' => [$successful, $failed, $orphaned],
'successful' => [$successful],
'failed' => [$failed],
'orphaned' => [$orphaned],
],
]);
}
public function test_event_item_initial_opening_state()
......@@ -431,7 +455,12 @@ class DataCollectorTest extends KernelTestCase
$selector = ".sf-toolbar-info .sf-toolbar-info-piece.{$class} span";
$status = $toolbar->filter($selector);
$this->assertEquals($expected['value'], $status->text());
$this->assertEquals(
$expected['value'],
$status->text(),
"Toolbar info piece '{$class}' has not the right value."
);
if ($expected['status']) {
$this->assertStringContainsString(
'sf-toolbar-status',
......@@ -496,14 +525,14 @@ class DataCollectorTest extends KernelTestCase
".tab.{$tab} badge doesn't match expected number of events"
);
if ($nbEvents > 0) {
$selector = ".dispatched-events .tab.{$tab} .tab-content .dispatched-event-item";
$this->assertCount(
$nbEvents,
$panel->filter($selector),
"Number of items in .tab.{$tab} doesn't match expected number of events"
);
$selector = ".dispatched-events .tab.{$tab} .tab-content .dispatched-event-item";
$this->assertCount(
$nbEvents,
$panel->filter($selector),
"Number of items in .tab.{$tab} doesn't match expected number of events"
);
if ($nbEvents > 0) {
$selector = ".dispatched-events .tab.{$tab} .tab-content .dispatched-event-item";
$tables = $panel->filter($selector);
......
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