Skip to content

Commit

Permalink
Unit tests: Restore site-data.spec.ts (#1194)
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
```

![CleanShot 2024-04-04 at 13 09
25@2x](https://github.com/WordPress/wordpress-playground/assets/205419/fe68c5ff-80a7-4966-82a8-fbfcc7e9a101)

They seem related to #1189, but:

* I can't reproduce it locally
* The test actually passed in #1189 and only started failing in #1192
* All the other tests pass and the Playground website works so I wonder
what's going on there.
* The stack trace mentions network activity, but that call shouldn't
involve any. It's almost as if the trace was coming from
`php-networking.spec.ts`, but those tests actually pass.

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!

CC @brandonpayton for insights
  • Loading branch information
adamziel authored Apr 11, 2024
1 parent 7d51a7c commit 581da69
Showing 1 changed file with 37 additions and 0 deletions.
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!');
});
});

0 comments on commit 581da69

Please sign in to comment.