From 4d0650a02f5088853492cffb87b0f6763242bce7 Mon Sep 17 00:00:00 2001 From: YvesCesar Date: Sat, 14 Nov 2026 10:28:18 -0400 Subject: [PATCH] fix: prorate subscription upgrades in the local and e2e stores Signed-off-by: YvesCesar --- docker-compose.override.yml | 1 + tests/E2E/PlanChange.spec.ts | 6 ++++-- tests/E2E/support/seed.php | 1 - tests/E2E/support/wordpress.ts | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 7cdb2c3..990d1b9 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -66,6 +66,7 @@ services: source: https://github.com/pronamic/woocommerce-subscriptions.git post_install_commands: - git -C "$$PLUGIN_DIR" fetch -q origin 2459d9c8662884d62b9a92221eb21c7c6c051a62 && git -C "$$PLUGIN_DIR" checkout -q 2459d9c8662884d62b9a92221eb21c7c6c051a62 + - wp option update woocommerce_subscriptions_apportion_recurring_price yes-upgrade wordpress_custom_themes: - slug: libresign source: https://github.com/LibreSign/wordpress-theme.git diff --git a/tests/E2E/PlanChange.spec.ts b/tests/E2E/PlanChange.spec.ts index 8e40bb8..2cae28a 100644 --- a/tests/E2E/PlanChange.spec.ts +++ b/tests/E2E/PlanChange.spec.ts @@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test'; import { nextcloud } from './support/nextcloud'; import { agreeToTheTerms, aSubscriber, logInToTheStore, placeTheOrder, plansInTheStore, STORE_URL } from './support/store'; -import { subscriptionStatus } from './support/wordpress'; +import { orderTotal, subscriptionStatus } from './support/wordpress'; const GIGABYTE = 1024 ** 3; @@ -23,7 +23,7 @@ test.describe( 'Changing plan', () => { await expect( page.getByRole( 'link', { name: 'Professional', exact: true } ) ).toHaveCount( 0 ); } ); - test( 'upgrading from Basic to Enterprise raises the workspace storage to 800 GB', async ( { browser, page } ) => { + test( 'upgrading from Basic to Enterprise charges the prorated difference and raises the workspace storage to 800 GB', async ( { browser, page } ) => { const { customer, subscriptionId } = await aSubscriber( page, 'Nilo' ); await logInToTheStore( page, customer.email, customer.password ); @@ -37,6 +37,8 @@ test.describe( 'Changing plan', () => { await page.getByRole( 'button', { name: 'Switch subscription' } ).click(); await expect( page ).toHaveURL( /\/checkout\/order-received\/\d+\//, { timeout: 90_000 } ); + const switchOrderId = Number( page.url().match( /order-received\/(\d+)\// )![ 1 ] ); + expect( orderTotal( switchOrderId ) ).toBeGreaterThan( 0 ); expect( subscriptionStatus( subscriptionId ) ).toBe( 'active' ); expect( await nextcloud.account( customer.email ) ).toMatchObject( { enabled: true, quota: { quota: 800 * GIGABYTE } } ); await nextcloud.expectToLogIn( browser, customer.email, customer.password ); diff --git a/tests/E2E/support/seed.php b/tests/E2E/support/seed.php index 9098382..304fa94 100644 --- a/tests/E2E/support/seed.php +++ b/tests/E2E/support/seed.php @@ -28,7 +28,6 @@ 'woocommerce_email_from_name' => 'LibreSign', 'woocommerce_email_from_address' => 'noreply@example.com', 'woocommerce_subscriptions_allow_switching' => 'grouped', - 'woocommerce_subscriptions_apportion_recurring_price' => 'no', 'woocommerce_subscriptions_enable_early_renewal' => 'yes', 'woocommerce_subscriptions_enable_retry' => 'no', 'woocommerce_subscriptions_multiple_purchase' => 'yes', diff --git a/tests/E2E/support/wordpress.ts b/tests/E2E/support/wordpress.ts index aeb54fa..6528081 100644 --- a/tests/E2E/support/wordpress.ts +++ b/tests/E2E/support/wordpress.ts @@ -27,6 +27,10 @@ export function orderStatus( orderId: number ): string { return wpEval( `echo wc_get_order( ${ orderId } )->get_status();` ); } +export function orderTotal( orderId: number ): number { + return Number( wpEval( `echo wc_get_order( ${ orderId } )->get_total();` ) ); +} + export function runTheScheduledNextcloudSyncRetry( orderId: number ): void { wpEval( ` if ( ! as_next_scheduled_action( 'agm_retry_nextcloud_sync', array( 'order_id' => ${ orderId } ), 'nextcloud-admin-group-manager' ) ) {