diff --git a/src/src/Commands/TestTagsCommand.php b/src/src/Commands/TestTagsCommand.php new file mode 100644 index 00000000..47a8ab06 --- /dev/null +++ b/src/src/Commands/TestTagsCommand.php @@ -0,0 +1,54 @@ +setDescription( 'List the Test Tags you have access to test.' ); + } + + protected function execute( InputInterface $input, OutputInterface $output ): int { + try { + $json = ( new RequestBuilder( get_manager_url() . "/wp-json/cd/v1/get_extensions" ) ) + ->with_method( 'POST' ) + ->with_post_body( [ + 'list_tests' => true, + ] ) + ->request(); + } catch ( \Exception $e ) { + $output->writeln( "{$e->getMessage()}" ); + + return Command::FAILURE; + } + + $test_tags = json_decode( $json, true ); + + if ( empty( $test_tags ) ) { + $output->writeln( 'No test tags found.' ); + + return Command::FAILURE; + } + + $table = new Table( $output ); + $table->setHeaders(['Slug', 'E2E Tests', 'Type']); + + foreach ($test_tags as $tag => $data) { + $e2eTests = implode(', ', $data['tests']['e2e'] ?? []); + $table->addRow([$data['slug'], $e2eTests, $data['type']]); + } + + $table->render(); + + return Command::SUCCESS; + } +} diff --git a/src/src/bootstrap.php b/src/src/bootstrap.php index aee6ab92..193da2ef 100644 --- a/src/src/bootstrap.php +++ b/src/src/bootstrap.php @@ -28,6 +28,7 @@ use QIT_CLI\Commands\Partner\SwitchPartner; use QIT_CLI\Commands\SetProxyCommand; use QIT_CLI\Commands\SyncCommand; +use QIT_CLI\Commands\TestTagsCommand; use QIT_CLI\Commands\WooExtensionsCommand; use QIT_CLI\Config; use QIT_CLI\Diagnosis; @@ -233,6 +234,7 @@ public function filter( $in, $out, &$consumed, $closing ): int { // List the Woo Extensions the user can run tests against. $application->add( $container->make( WooExtensionsCommand::class ) ); + $application->add( $container->make( TestTagsCommand::class ) ); $application->add( $container->make( UploadCustomTestCommand::class ) ); $application->add( $container->make( ShowReportCommand::class ) );