From 280059431cfae2240f0c41fb483924515ca8177d Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 1 Apr 2024 10:15:07 +0200 Subject: [PATCH] Add test for tab --- src/DebugBar/Resources/debugbar.js | 2 ++ tests/DebugBar/Tests/Browser/DebugbarTest.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/DebugBar/Resources/debugbar.js b/src/DebugBar/Resources/debugbar.js index 74f5db5..5984e3d 100644 --- a/src/DebugBar/Resources/debugbar.js +++ b/src/DebugBar/Resources/debugbar.js @@ -1065,6 +1065,8 @@ if (typeof(PhpDebugBar) == 'undefined') { 'debugbar': this })}); this.datasetTab.$tab.addClass(csscls('tab-history')); + this.datasetTab.$tab.attr('data-collector', '__datasets'); + this.datasetTab.$el.attr('data-collector', '__datasets'); this.datasetTab.$tab.insertAfter(this.$openbtn).hide(); this.datasetTab.$tab.click(() => { if (!this.isMinimized() && self.activePanelName == '__datasets') { diff --git a/tests/DebugBar/Tests/Browser/DebugbarTest.php b/tests/DebugBar/Tests/Browser/DebugbarTest.php index bf6a122..38c120d 100644 --- a/tests/DebugBar/Tests/Browser/DebugbarTest.php +++ b/tests/DebugBar/Tests/Browser/DebugbarTest.php @@ -66,6 +66,21 @@ class DebugbarTest extends AbstractBrowserTest $client->waitForElementToContain('.phpdebugbar-datasets-switcher', 'ajax_exception.php'); $client->waitForElementToContain('.phpdebugbar-panel[data-collector=exceptions] .phpdebugbar-widgets-message', 'Something failed!'); + + // Open network tab + $client->click($this->getTabLink($crawler, '__datasets')); + $client->waitForVisibility('.phpdebugbar-panel[data-collector=__datasets] .phpdebugbar-widgets-table-row'); + + $requests = $crawler->filter('.phpdebugbar-panel[data-collector=__datasets] .phpdebugbar-widgets-table-row') + ->each(function(WebDriverElement $node){ + return $node->getText(); + }); + $this->assertStringContainsString('GET /demo/', $requests[0]); + $this->assertStringContainsString('GET /demo/ajax.php (ajax)', $requests[1]); + $this->assertStringContainsString('GET /demo/ajax_exception.php (ajax)', $requests[2]); + + + } } \ No newline at end of file