diff --git a/src/Service/ReportSuiteBuilder.php b/src/Service/ReportSuiteBuilder.php index f9102fa..1bcc9f5 100644 --- a/src/Service/ReportSuiteBuilder.php +++ b/src/Service/ReportSuiteBuilder.php @@ -71,32 +71,13 @@ public function filterSuite(?int $suiteId = null): self public function build(Execution $execution): self { + // Fetch suites $this->suites = $execution->getSuitesCollection()->toArray(); - - // Find if there is main suite id - $hasOnlyOneMainSuite = false; - $mainSuiteId = null; - foreach ($this->suites as $suite) { - if ($suite->getParentId()) { - continue; - } - - if ($hasOnlyOneMainSuite) { - // There is another suite with null, so not only one is used - // Used for legacy purpose - $hasOnlyOneMainSuite = false; - $mainSuiteId = null; - break; - } - - $hasOnlyOneMainSuite = true; - $mainSuiteId = $suite->getId(); - } // Extract tests $this->tests = $this->getTests(); // Build the recursive tree - $this->suites = $this->buildTree($mainSuiteId, true); + $this->suites = $this->buildTree(null, true); $this->suites = $this->filterTree($this->suites); return $this; diff --git a/tests/Command/ImportPlaywrightCommandTest.php b/tests/Command/ImportPlaywrightCommandTest.php index ece7698..0aa03dc 100644 --- a/tests/Command/ImportPlaywrightCommandTest.php +++ b/tests/Command/ImportPlaywrightCommandTest.php @@ -16,7 +16,7 @@ public function testImportBlockwislist(): void $command = $application->find('nightly:import:playwright'); $commandTester = new CommandTester($command); $commandTester->execute([ - '--platform' => 'cli', + '--platform' => 'chromium', '--campaign' => 'blockwishlist', 'filename' => 'blockwishlist_2024-01-25-develop.json', ]); diff --git a/tests/Controller/ReportControllerTest.php b/tests/Controller/ReportControllerTest.php index e6ca981..70a0805 100644 --- a/tests/Controller/ReportControllerTest.php +++ b/tests/Controller/ReportControllerTest.php @@ -116,8 +116,8 @@ public static function dataProviderReportFilters(): array return [ [[], 6], [['filter_campaign[0]' => 'functional'], 2], - [['filter_platform' => 'chromium'], 3], - [['filter_browser' => 'chromium'], 3], + [['filter_platform' => 'chromium'], 4], + [['filter_browser' => 'chromium'], 4], [['filter_version' => 'develop'], 6], ]; } @@ -149,10 +149,15 @@ public function testCorsReportID(): void $this->assertEquals($response->headers->get('access-control-allow-origin'), '*'); } - public function testReportID(): void + /** + * @dataProvider dataProviderReportID + * + * @param array $campaigns + */ + public function testReportID(int $reportId, array $campaigns): void { $client = static::createClient(); - $client->request('GET', '/reports/2'); + $client->request('GET', '/reports/' . $reportId); $response = $client->getResponse(); $this->assertEquals(200, $response->getStatusCode()); @@ -167,7 +172,7 @@ public function testReportID(): void $this->assertArrayHasKey('date', $content); $this->assertArrayHasKey('version', $content); $this->assertArrayHasKey('campaign', $content); - $this->assertContains($content['campaign'], ReportMochaImporter::FILTER_CAMPAIGNS); + $this->assertContains($content['campaign'], $campaigns); $this->assertArrayHasKey('browser', $content); $this->assertContains($content['browser'], ReportMochaImporter::FILTER_PLATFORMS); $this->assertArrayHasKey('platform', $content); @@ -195,11 +200,27 @@ public function testReportID(): void $this->assertArrayHasKey('suites_data', $content); $this->assertIsArray($content['suites_data']); + $this->assertNotEmpty($content['suites_data']); foreach ($content['suites_data'] as $suiteId => $suiteItem) { $this->partialTestSuite($content['id'], $suiteId, $suiteItem, null, true); } } + /** + * @return array> + */ + public static function dataProviderReportID(): array + { + return [ + // autoupgrade + [1, ReportMochaImporter::FILTER_CAMPAIGNS], + // functional + [2, ReportMochaImporter::FILTER_CAMPAIGNS], + // blockwishlist + [3, ReportPlaywrightImporter::FILTER_CAMPAIGNS], + ]; + } + public function testReportIDSuiteID(): void { $client = static::createClient();