Skip to content

Commit

Permalink
Fix typo with theme as SUT, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc45 committed Dec 17, 2024
1 parent cc7903c commit 2a2cbf5
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 18 deletions.
21 changes: 6 additions & 15 deletions src/src/LocalTests/ConfigurationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'] );
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/tests/Environment/RunActivationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
14 changes: 14 additions & 0 deletions src/tests/Environment/RunE2ECommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
}
Original file line number Diff line number Diff line change
@@ -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": []
}
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
themes:
storefront:
source: "./storefront-theme"
test_tags:
- "default"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Theme Name: Storefront
Author: Automattic
Description: The perfect theme for your next WooCommerce project.
Version: 2.5.0
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test, expect } from '@playwright/test';

test('Storefront theme activation test', async ({ page }) => {
// Placeholder test
expect(1).toBe(1);
});

0 comments on commit 2a2cbf5

Please sign in to comment.