Skip to content

Commit

Permalink
Unit tests: Restore site-data.spec.ts
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
adamziel committed Apr 11, 2024
1 parent 83b6f85 commit c6f26b5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/php-wasm/node/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export default defineConfig(() => {
},
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
onConsoleLog(): false | void {
return false;
},
},

define: {
Expand Down
37 changes: 37 additions & 0 deletions packages/playground/blueprints/src/lib/steps/site-data.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { NodePHP } from '@php-wasm/node';
import {
RecommendedPHPVersion,
getWordPressModule,
} from '@wp-playground/wordpress';
import { setSiteOptions } from './site-data';
import { unzip } from './unzip';

describe('Blueprint step setSiteOptions()', () => {
let php: NodePHP;
beforeEach(async () => {
php = await NodePHP.load(RecommendedPHPVersion, {
requestHandler: {
documentRoot: '/wordpress',
},
});
await unzip(php, {
zipFile: await getWordPressModule(),
extractToPath: '/wordpress',
});
});

it('should set the site option', async () => {
await setSiteOptions(php, {
options: {
blogname: 'My test site!',
},
});
const response = await php.run({
code: `<?php
require '/wordpress/wp-load.php';
echo get_option('blogname');
`,
});
expect(response.text).toBe('My test site!');
});
});
3 changes: 3 additions & 0 deletions packages/playground/blueprints/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ export default defineConfig({
},
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
onConsoleLog(): false | void {
return false;
},
},
});

0 comments on commit c6f26b5

Please sign in to comment.