diff --git a/apps/cli/commands/tests/import.e2e.test.ts b/apps/cli/commands/tests/import.e2e.test.ts index c808546820..cc7b8c2ed3 100644 --- a/apps/cli/commands/tests/import.e2e.test.ts +++ b/apps/cli/commands/tests/import.e2e.test.ts @@ -17,6 +17,7 @@ */ import fs from 'fs'; import path from 'path'; +import * as tar from 'tar'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { cleanupCliEnv, @@ -187,4 +188,45 @@ describe.skipIf( ! cliE2ePrerequisitesMet() )( 'CLI e2e: studio import', () => { expect( await getBlogname( env, sitePath ) ).toBe( FIXTURE_BLOGNAME ); } ); + + // Regression test for https://github.com/Automattic/studio/issues/3518 + // where db.php overwrites SQLite drop-in during restore causing database import error + // "Could not determine the version of the SQLite integration plugin". + it( + 'imports a backup containing db.php drop-in', + { tags: [ 'e2e' ], timeout: 300_000 }, + async () => { + if ( ! env ) { + throw new Error( 'CLI e2e env was not initialised' ); + } + + const workDir = path.join( env.root, 'db-php' ); + const cwd = path.join( workDir, 'contents' ); + fs.mkdirSync( cwd, { recursive: true } ); + await tar.x( { file: path.join( FIXTURES_DIR, 'jetpack-backup.tar.gz' ), cwd } ); + + fs.writeFileSync( + path.join( cwd, 'wp-content', 'db.php' ), + '