diff --git a/src/src/LocalTests/ConfigurationProcessor.php b/src/src/LocalTests/ConfigurationProcessor.php index 45d2a83d..068b941d 100644 --- a/src/src/LocalTests/ConfigurationProcessor.php +++ b/src/src/LocalTests/ConfigurationProcessor.php @@ -93,11 +93,8 @@ public function process_configuration( $this->normalize_plugins( $env_config ); $this->normalize_themes( $env_config ); - if ( $sut_type === 'theme' ) { - $env_up_options['--theme'] = array_values( $env_config['themes'] ); - } else { - $env_up_options['--plugin'] = array_values( $env_config['plugins'] ); - } + $env_up_options['--plugin'] = array_values( $env_config['plugins'] ); + $env_up_options['--theme'] = array_values( $env_config['themes'] ); } if ( App::getVar( 'QIT_ACTIVATION_TEST' ) ) { @@ -160,11 +157,8 @@ protected function finalize_sut_definition( $this->add_cli_plugins( $env_config, $input ); $this->normalize_plugins( $env_config ); $this->normalize_themes( $env_config ); - if ( $sut_type === 'theme' ) { - $env_up_options['--theme'] = array_values( $env_config['themes'] ); - } else { - $env_up_options['--plugin'] = array_values( $env_config['plugins'] ); - } + $env_up_options['--plugin'] = array_values( $env_config['plugins'] ); + $env_up_options['--theme'] = array_values( $env_config['themes'] ); return; } @@ -213,11 +207,8 @@ protected function finalize_sut_definition( $this->normalize_plugins( $env_config ); $this->normalize_themes( $env_config ); - if ( $sut_type === 'theme' ) { - $env_up_options['--theme'] = array_values( $env_config['themes'] ); - } else { - $env_up_options['--plugin'] = array_values( $env_config['plugins'] ); - } + $env_up_options['--theme'] = array_values( $env_config['themes'] ); + $env_up_options['--plugin'] = array_values( $env_config['plugins'] ); } /** diff --git a/src/tests/Environment/RunActivationCommandTest.php b/src/tests/Environment/RunActivationCommandTest.php index 307dd641..2d4c022d 100644 --- a/src/tests/Environment/RunActivationCommandTest.php +++ b/src/tests/Environment/RunActivationCommandTest.php @@ -314,6 +314,22 @@ public function test_activation_with_additional_plugins() { $this->assertMatchesJsonSnapshot( $this->application_tester->getDisplay() ); } + public function test_theme_sut_activation() { + putenv( 'QIT_TESTING_ENV_CONFIG=1' ); + + $fixture_dir = $this->scenarios_dir . 'scenario-theme-activation'; + $this->assertDirectoryExists( $fixture_dir ); + chdir( $fixture_dir ); + + $this->application_tester->run( [ + 'command' => 'run:activation', + 'woo_extension' => 'storefront', // This is a known theme slug from your mock. + ], [ 'capture_stderr_separately' => true ] ); + + $this->assertCommandIsSuccessful( $this->application_tester ); + $this->assertMatchesJsonSnapshot( $this->application_tester->getDisplay() ); + } + public function tearDown(): void { parent::tearDown(); putenv( 'QIT_TESTING_ENV_CONFIG' ); diff --git a/src/tests/Environment/RunE2ECommandTest.php b/src/tests/Environment/RunE2ECommandTest.php index cb6e7d76..6fd4f52a 100644 --- a/src/tests/Environment/RunE2ECommandTest.php +++ b/src/tests/Environment/RunE2ECommandTest.php @@ -820,6 +820,20 @@ public function test_numeric_plugin_id_with_qit_config() { $this->assertMatchesJsonSnapshot($output); } + public function test_theme_sut_with_additional_plugins() { + putenv( 'QIT_TESTING_ENV_CONFIG=1' ); + $fixture_dir = $this->scenarios_dir . 'scenario-theme-sut'; + $this->assertDirectoryExists( $fixture_dir ); + chdir( $fixture_dir ); + + $this->application_tester->run( [ + 'command' => 'run:e2e', + 'woo_extension' => 'storefront', // a theme SUT + '--plugin' => [ 'woocommerce:test:activation' ], // triggers previous issue + ], [ 'capture_stderr_separately' => true ] ); + $this->assertCommandIsSuccessful( $this->application_tester ); + $this->assertMatchesJsonSnapshot( $this->application_tester->getDisplay() ); + } } diff --git a/src/tests/Environment/__snapshots__/RunActivationCommandTest__test_theme_sut_activation__1.json b/src/tests/Environment/__snapshots__/RunActivationCommandTest__test_theme_sut_activation__1.json new file mode 100644 index 00000000..183ebe4f --- /dev/null +++ b/src/tests/Environment/__snapshots__/RunActivationCommandTest__test_theme_sut_activation__1.json @@ -0,0 +1,33 @@ +{ + "--php_version": "7.4", + "--wp": "stable", + "--plugin": [ + { + "slug": "woocommerce", + "source": "woocommerce", + "test_tags": [ + "activation" + ], + "action": "test" + } + ], + "--theme": [ + { + "source": ".\/storefront-theme", + "test_tags": [ + "pre-activation" + ], + "action": "bootstrap", + "slug": "storefront" + } + ], + "--volume": [], + "--php_extension": [], + "--require": [], + "--object_cache": false, + "--skip_activating_plugins": true, + "--tunnel": "no_tunnel", + "--json": true, + "--env": [], + "--env_file": [] +} diff --git a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_plugin_and_theme_sut_theme__1.json b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_plugin_and_theme_sut_theme__1.json index adbbc996..504b5b59 100644 --- a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_plugin_and_theme_sut_theme__1.json +++ b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_plugin_and_theme_sut_theme__1.json @@ -1,7 +1,16 @@ { "--php_version": "7.4", "--wp": "stable", - "--plugin": [], + "--plugin": [ + { + "source": ".\/woocommerce-sample-plugin", + "test_tags": [ + "default" + ], + "action": "bootstrap", + "slug": "woocommerce-sample-plugin" + } + ], "--theme": [ { "source": ".\/deli-theme", diff --git a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_and_plugin_both_config__1.json b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_and_plugin_both_config__1.json index 21854d28..dc43b33f 100644 --- a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_and_plugin_both_config__1.json +++ b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_and_plugin_both_config__1.json @@ -1,7 +1,16 @@ { "--php_version": "7.4", "--wp": "stable", - "--plugin": [], + "--plugin": [ + { + "source": ".\/woocommerce-sample-plugin", + "test_tags": [ + "default" + ], + "action": "bootstrap", + "slug": "woocommerce-sample-plugin" + } + ], "--theme": [ { "source": ".\/twentytwentyone-theme", diff --git a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_sut_with_additional_plugins__1.json b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_sut_with_additional_plugins__1.json new file mode 100644 index 00000000..6cc23a88 --- /dev/null +++ b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_sut_with_additional_plugins__1.json @@ -0,0 +1,33 @@ +{ + "--php_version": "7.4", + "--wp": "stable", + "--plugin": [ + { + "slug": "woocommerce", + "source": "woocommerce", + "test_tags": [ + "activation" + ], + "action": "test" + } + ], + "--theme": [ + { + "source": ".\/storefront-theme", + "test_tags": [ + "default" + ], + "action": "test", + "slug": "storefront" + } + ], + "--volume": [], + "--php_extension": [], + "--require": [], + "--object_cache": false, + "--skip_activating_plugins": false, + "--tunnel": "no_tunnel", + "--json": true, + "--env": [], + "--env_file": [] +} diff --git a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_with_additional_plugin__1.json b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_with_additional_plugin__1.json index 8e813a8c..5946da0d 100644 --- a/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_with_additional_plugin__1.json +++ b/src/tests/Environment/__snapshots__/RunE2ECommandTest__test_theme_with_additional_plugin__1.json @@ -2,7 +2,14 @@ "--php_version": "7.4", "--wp": "stable", "--plugin": [ - "woocommerce-extra-plugin:bootstrap" + { + "slug": "woocommerce-extra-plugin", + "source": "woocommerce-extra-plugin", + "test_tags": [ + "default" + ], + "action": "bootstrap" + } ], "--theme": [ { diff --git a/src/tests/data/rune2e-scenarios/scenario-theme-activation/qit.yml b/src/tests/data/rune2e-scenarios/scenario-theme-activation/qit.yml new file mode 100644 index 00000000..2777ac62 --- /dev/null +++ b/src/tests/data/rune2e-scenarios/scenario-theme-activation/qit.yml @@ -0,0 +1,5 @@ +themes: + storefront: + source: "./storefront-theme" + test_tags: + - "default" \ No newline at end of file diff --git a/src/tests/data/rune2e-scenarios/scenario-theme-activation/storefront-theme/style.css b/src/tests/data/rune2e-scenarios/scenario-theme-activation/storefront-theme/style.css new file mode 100644 index 00000000..361ea929 --- /dev/null +++ b/src/tests/data/rune2e-scenarios/scenario-theme-activation/storefront-theme/style.css @@ -0,0 +1,6 @@ +/* +Theme Name: Storefront +Author: Automattic +Description: The perfect theme for your next WooCommerce project. +Version: 2.5.0 +*/ \ No newline at end of file diff --git a/src/tests/data/rune2e-scenarios/scenario-theme-activation/tests/example.spec.js b/src/tests/data/rune2e-scenarios/scenario-theme-activation/tests/example.spec.js new file mode 100644 index 00000000..13f888bc --- /dev/null +++ b/src/tests/data/rune2e-scenarios/scenario-theme-activation/tests/example.spec.js @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test('Storefront theme activation test', async ({ page }) => { + // Placeholder test + expect(1).toBe(1); +}); \ No newline at end of file