Skip to content

Commit 8eea88d

Browse files
authored
Merge pull request #143 from Progi1984/fixImportPlayrwright
Endpoint `reports/{id}` : Fixed import Playwright
2 parents c3662ad + 20ccd7b commit 8eea88d

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

src/Service/ReportSuiteBuilder.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,13 @@ public function filterSuite(?int $suiteId = null): self
7171

7272
public function build(Execution $execution): self
7373
{
74+
// Fetch suites
7475
$this->suites = $execution->getSuitesCollection()->toArray();
75-
76-
// Find if there is main suite id
77-
$hasOnlyOneMainSuite = false;
78-
$mainSuiteId = null;
79-
foreach ($this->suites as $suite) {
80-
if ($suite->getParentId()) {
81-
continue;
82-
}
83-
84-
if ($hasOnlyOneMainSuite) {
85-
// There is another suite with null, so not only one is used
86-
// Used for legacy purpose
87-
$hasOnlyOneMainSuite = false;
88-
$mainSuiteId = null;
89-
break;
90-
}
91-
92-
$hasOnlyOneMainSuite = true;
93-
$mainSuiteId = $suite->getId();
94-
}
9576
// Extract tests
9677
$this->tests = $this->getTests();
9778

9879
// Build the recursive tree
99-
$this->suites = $this->buildTree($mainSuiteId, true);
80+
$this->suites = $this->buildTree(null, true);
10081
$this->suites = $this->filterTree($this->suites);
10182

10283
return $this;

tests/Command/ImportPlaywrightCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function testImportBlockwislist(): void
1616
$command = $application->find('nightly:import:playwright');
1717
$commandTester = new CommandTester($command);
1818
$commandTester->execute([
19-
'--platform' => 'cli',
19+
'--platform' => 'chromium',
2020
'--campaign' => 'blockwishlist',
2121
'filename' => 'blockwishlist_2024-01-25-develop.json',
2222
]);

tests/Controller/ReportControllerTest.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public static function dataProviderReportFilters(): array
116116
return [
117117
[[], 6],
118118
[['filter_campaign[0]' => 'functional'], 2],
119-
[['filter_platform' => 'chromium'], 3],
120-
[['filter_browser' => 'chromium'], 3],
119+
[['filter_platform' => 'chromium'], 4],
120+
[['filter_browser' => 'chromium'], 4],
121121
[['filter_version' => 'develop'], 6],
122122
];
123123
}
@@ -149,10 +149,15 @@ public function testCorsReportID(): void
149149
$this->assertEquals($response->headers->get('access-control-allow-origin'), '*');
150150
}
151151

152-
public function testReportID(): void
152+
/**
153+
* @dataProvider dataProviderReportID
154+
*
155+
* @param array<string> $campaigns
156+
*/
157+
public function testReportID(int $reportId, array $campaigns): void
153158
{
154159
$client = static::createClient();
155-
$client->request('GET', '/reports/2');
160+
$client->request('GET', '/reports/' . $reportId);
156161
$response = $client->getResponse();
157162

158163
$this->assertEquals(200, $response->getStatusCode());
@@ -167,7 +172,7 @@ public function testReportID(): void
167172
$this->assertArrayHasKey('date', $content);
168173
$this->assertArrayHasKey('version', $content);
169174
$this->assertArrayHasKey('campaign', $content);
170-
$this->assertContains($content['campaign'], ReportMochaImporter::FILTER_CAMPAIGNS);
175+
$this->assertContains($content['campaign'], $campaigns);
171176
$this->assertArrayHasKey('browser', $content);
172177
$this->assertContains($content['browser'], ReportMochaImporter::FILTER_PLATFORMS);
173178
$this->assertArrayHasKey('platform', $content);
@@ -195,11 +200,27 @@ public function testReportID(): void
195200

196201
$this->assertArrayHasKey('suites_data', $content);
197202
$this->assertIsArray($content['suites_data']);
203+
$this->assertNotEmpty($content['suites_data']);
198204
foreach ($content['suites_data'] as $suiteId => $suiteItem) {
199205
$this->partialTestSuite($content['id'], $suiteId, $suiteItem, null, true);
200206
}
201207
}
202208

209+
/**
210+
* @return array<array<int>>
211+
*/
212+
public static function dataProviderReportID(): array
213+
{
214+
return [
215+
// autoupgrade
216+
[1, ReportMochaImporter::FILTER_CAMPAIGNS],
217+
// functional
218+
[2, ReportMochaImporter::FILTER_CAMPAIGNS],
219+
// blockwishlist
220+
[3, ReportPlaywrightImporter::FILTER_CAMPAIGNS],
221+
];
222+
}
223+
203224
public function testReportIDSuiteID(): void
204225
{
205226
$client = static::createClient();

0 commit comments

Comments
 (0)