Skip to content

Commit

Permalink
Add e2e for plugin routes
Browse files Browse the repository at this point in the history
  • Loading branch information
frandiox committed Aug 2, 2022
1 parent 4d7f64a commit 6cd988a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
@@ -0,0 +1,5 @@
{
"name": "my-test-plugin",
"private": "true",
"type": "module"
}
@@ -0,0 +1,6 @@
import {definePlugin} from '@shopify/hydrogen/config';

export default definePlugin(() => ({
name: 'my-test-plugin',
url: import.meta.url,
}));
@@ -0,0 +1,7 @@
export default function MyPlugin() {
return <h1>Hello My Plugin</h1>;
}

export function api() {
return new Response('Plugin OK');
}
12 changes: 12 additions & 0 deletions packages/playground/server-components/tests/e2e-test-cases.ts
Expand Up @@ -894,4 +894,16 @@ export default async function testCases({
expect(await page.textContent('h2')).toContain('itBroke is not defined');
});
});

describe('Hydrogen Plugins', () => {
it('imports plugin routes', async () => {
const pluginRoute = getServerUrl() + '/my-plugin';
await page.goto(pluginRoute);
expect(await page.textContent('h1')).toContain('Hello My Plugin');

expect(await (await fetch(pluginRoute, {method: 'POST'})).text()).toEqual(
'Plugin OK'
);
});
});
}

0 comments on commit 6cd988a

Please sign in to comment.