From 30a4a82bbb4456a2514f7b9cc141036d2c6b0297 Mon Sep 17 00:00:00 2001 From: Huzaifa Al Mesbah Date: Fri, 13 Nov 2026 15:23:27 +0600 Subject: [PATCH] Build/Test Tools: Cover replacing an installed theme with an uploaded version. Add an E2E test that uploads a newer version of the fixture theme, checks the version comparison on the "already installed" screen, replaces the installed theme, and verifies the new version through REST. Add a 2.0 theme fixture and move the shared upload steps into a helper. Follow-up to r64624. See #54334. --- tests/e2e/assets/e2e-test-theme-2.0.zip | Bin 0 -> 2524 bytes tests/e2e/assets/e2e-test-theme.md | 33 +++++++----- tests/e2e/specs/themes.test.js | 64 ++++++++++++++++++++---- 3 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 tests/e2e/assets/e2e-test-theme-2.0.zip diff --git a/tests/e2e/assets/e2e-test-theme-2.0.zip b/tests/e2e/assets/e2e-test-theme-2.0.zip new file mode 100644 index 0000000000000000000000000000000000000000..87389816848616691f8c25d16777381a1001b68e GIT binary patch literal 2524 zcmbtW2~<`wKl|;5H*?NN>JX(9sJFhcmX8t?(pYQ*_f9}lv zeZA0H1n{<4`u-y4>U@PfXqqX~m=vZhm&xJUa#_q6CYi%c*v7Pr;Bd$`xB$(J#rp6V zrjx}Q${LFRM9pGm5=UpoaiU_kJ6TZd{(%eJu_c_#v!a3ox_Ud+C}f!s=lx82Xj5wdaMNy1c7x(1!^%!Tf>Wr1i;%H*dPcx00S8TG$KJr z1&|rQ%*X(ELgurwKVm5`0-?}a7;UVME=~_osGSQ? z5E_lrLSrymNFbnO3p*#OP5)HZsV|GC3TgfliR=6taV@K;kh9okiIb}I3!{VGjb~{Dw@NM-?f{UuqPvP zUsm@1oCAlC96fft;D;YioGL3nT~Yb-nO}Z8FQ~1nzi{zVb4%;hw)Sh+Z*<-1zI(6d zes7;xGVo;Z>Co`A=d#yh;}erp@SAB3F9@J#L-t8tNDv^DmKItItKkKqc58?mYGEwD z)HYh}hYjC3&x*2FhwycNX^lvCk-fjvcynAQ&SbHJc!^9yZHC$ZMlAjRVm3?cJ+D5X zkA{%VLmL7bP^qjz2`bGd=<)sMyRIizJnD-!iF4^}-yOj*cqlj=>a(P_d9lDa%$5V+XuvruP_;X6q@J}D8^u=nB zp2lVvy3S2XMnqmx*u4qIrX@*e*~(g3nfPFR&N;inRw`poL#iY)TO!OJ%u+V>o#&ZL zCd->F?-q?G*M+%Bp442=54Xrg%UQFo4kb=z7OFloPyYzO7qr~4Uv;#A5U<=G?*Mqp`6 zjz36ZG|I583nX(osx(4{8^iQJI8v@JJFJ4wKVaLSqHHRPoQkuac>f zl>J5eYLFTG&4q546$w#n@nci?P@=iu@|{ysOi@`~s2BSh6DT*SL57boRt;eGEqLjp z0_n0gr=H2Yt7>qc?|&!7;Cao%Zxi~Cmq|GrY8$#!wAo#sM-28p>od-}C~dyE!aS3t zKXCDS?BZrl6ix*ufd{4GL=pY~9|P z3XK@Cn-;>M(hVXKfvcBlnB>?UKZ@6T5IQ<9c*JBnJ6FLhXB7}b+A|~JmFc=avo#Py;y&&|FKDuh0Hxm5iV7+NqEoc1()di zs(7ALzPIa!i6%zF^&#<9SCXw>wZ%}L>aqF3-{qp6Co|z}IZa^?yA6aTPL|51nr~&3 z&=a;+Bh8zfW!Sb@B9AR%;I|8^i6V0LQ|YUVRq%PguJO$-9t#yG9L%=WZ%(F%)qzyUnBiite8)|JQWdqToqTv{(Iefa2EeML*)ufncc z)6xr30wuj!?%jAuZ^ZcrD===RIScRZsSgLdy4TkWLJ`n^o$$Q9@Bv6e{_%gE{(Ow` taRT!mW!IlkX49FEQ9e#u-lJUmGYaQ}6vo#JqpeX#Bee$^M|Ct$e*n#q-68-0 literal 0 HcmV?d00001 diff --git a/tests/e2e/assets/e2e-test-theme.md b/tests/e2e/assets/e2e-test-theme.md index 3c8dcc235b57d..204a29d79c1b0 100644 --- a/tests/e2e/assets/e2e-test-theme.md +++ b/tests/e2e/assets/e2e-test-theme.md @@ -1,23 +1,30 @@ -# Theme fixture +# Theme fixtures `e2e-test-theme.zip` contains a minimal classic theme with three files. Its template executes no code. The screenshot reuses the existing PHPUnit image fixture. The update URI prevents WordPress.org update matching. -To reproduce the archive from the repository root with Python 3: +`e2e-test-theme-2.0.zip` contains the same theme with version `2.0`, for replacing an installed theme with an uploaded version. + +To reproduce both archives from the repository root with Python 3: ```python from pathlib import Path from zipfile import ZipFile, ZipInfo -files = { - 'style.css': '/*\nTheme Name: E2E Test Theme\nVersion: 1.0\nUpdate URI: false\n*/\n', - 'index.php': ' theme.stylesheet === themeSlug ) ) { @@ -47,16 +60,7 @@ test.describe( 'Theme management', () => { previousTheme = themes.find( ( theme ) => theme.status === 'active' ).stylesheet; - await admin.visitAdminPage( 'theme-install.php' ); - await page - .getByRole( 'button', { name: 'Upload Theme', exact: true } ) - .click(); - await page - .locator( '#themezip' ) - .setInputFiles( 'tests/e2e/assets/e2e-test-theme.zip' ); - await page - .getByRole( 'button', { name: 'Install Now', exact: true } ) - .click(); + await uploadTheme( admin, page, 'e2e-test-theme.zip' ); await expect( page.getByText( 'Theme installed successfully.', { exact: true } ) ).toBeVisible(); @@ -152,6 +156,46 @@ test.describe( 'Theme management', () => { ).toBe( previousTheme ); } ); + test( 'replaces an installed theme with an uploaded version', async ( { + admin, + page, + requestUtils, + } ) => { + expect( + ( + await requestUtils.rest( { + path: `/wp/v2/themes/${ themeSlug }`, + } ) + ).version + ).toBe( '1.0' ); + await uploadTheme( admin, page, 'e2e-test-theme-2.0.zip' ); + await expect( + page.getByRole( 'heading', { + name: 'This theme is already installed.', + exact: true, + } ) + ).toBeVisible(); + await expect( + page.getByRole( 'row', { name: 'Version 1.0 2.0', exact: true } ) + ).toBeVisible(); + await page + .getByRole( 'link', { + name: 'Replace installed with uploaded', + exact: true, + } ) + .click(); + await expect( + page.getByText( 'Theme updated successfully.', { exact: true } ) + ).toBeVisible(); + expect( + ( + await requestUtils.rest( { + path: `/wp/v2/themes/${ themeSlug }`, + } ) + ).version + ).toBe( '2.0' ); + } ); + test( 'searches for an installed theme', async ( { admin, page } ) => { await admin.visitAdminPage( 'themes.php' ); const search = page.getByRole( 'searchbox', {