Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint reports/{id} : Fixed import Playwright #143

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions src/Service/ReportSuiteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/ImportPlaywrightCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
Expand Down
31 changes: 26 additions & 5 deletions tests/Controller/ReportControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
];
}
Expand Down Expand Up @@ -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<string> $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());
Expand All @@ -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);
Expand Down Expand Up @@ -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<array<int>>
*/
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();
Expand Down
Loading