Skip to content

Commit 9baa796

Browse files
committed
Unit tests: Restore site-data.spec.ts
The test was removed in #1192 due to intermittent failures like these: ``` FAIL src/lib/steps/site-data.spec.ts > Blueprint step setSiteOptions() > should set the site option ``` They seem related to #1189, but all the other tests pass and the Playground website works so I wonder what's going on there. Is the CI runner just running out of memory? But then it shouldn't be able to allocate the memory segment in the first place. Weird!
1 parent fad3ccf commit 9baa796

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

packages/php-wasm/node/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export default defineConfig(() => {
6262
},
6363
environment: 'jsdom',
6464
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
65+
onConsoleLog(): false | void {
66+
return false;
67+
},
6568
},
6669

6770
define: {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { NodePHP } from '@php-wasm/node';
2+
import {
3+
RecommendedPHPVersion,
4+
getWordPressModule,
5+
} from '@wp-playground/wordpress';
6+
import { setSiteOptions } from './site-data';
7+
import { unzip } from './unzip';
8+
9+
describe('Blueprint step setSiteOptions()', () => {
10+
let php: NodePHP;
11+
beforeEach(async () => {
12+
php = await NodePHP.load(RecommendedPHPVersion, {
13+
requestHandler: {
14+
documentRoot: '/wordpress',
15+
},
16+
});
17+
await unzip(php, {
18+
zipFile: await getWordPressModule(),
19+
extractToPath: '/wordpress',
20+
});
21+
});
22+
23+
it('should set the site option', async () => {
24+
await setSiteOptions(php, {
25+
options: {
26+
blogname: 'My test site!',
27+
},
28+
});
29+
const response = await php.run({
30+
code: `<?php
31+
require '/wordpress/wp-load.php';
32+
echo get_option('blogname');
33+
`,
34+
});
35+
expect(response.text).toBe('My test site!');
36+
});
37+
});

packages/playground/blueprints/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ export default defineConfig({
5656
},
5757
environment: 'jsdom',
5858
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
59+
onConsoleLog(): false | void {
60+
return false;
61+
},
5962
},
6063
});

0 commit comments

Comments
 (0)