Skip to content

Commit e680b93

Browse files
committed
test: add coverage for merged Remix context
1 parent ddfcd8c commit e680b93

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useLoaderData } from "@remix-run/react";
2+
import { type LoaderArgs } from "@netlify/remix-edge-adapter";
3+
4+
export async function loader({ context }: LoaderArgs) {
5+
return {
6+
siteName: context.site?.name,
7+
};
8+
}
9+
export default function About() {
10+
const { siteName } = useLoaderData<typeof loader>();
11+
return <div>This site name is {siteName}</div>;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useLoaderData } from "@remix-run/react";
2+
import { type LoaderArgs } from "@netlify/remix-adapter";
3+
4+
export async function loader({ context }: LoaderArgs) {
5+
return {
6+
siteName: context.site?.name,
7+
};
8+
}
9+
export default function About() {
10+
const { siteName } = useLoaderData<typeof loader>();
11+
return <div>This site name is {siteName}</div>;
12+
}

tests/e2e/user-journeys.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ test.describe('User journeys', () => {
100100
await expect(page.getByRole('img')).toHaveJSProperty('height', 300)
101101
})
102102

103+
test('can access Netlify Functions context in loader context', async ({ page, serverlessSite }) => {
104+
const response = await page.goto(`${serverlessSite.url}/context`)
105+
expect(response?.status()).toBe(200)
106+
await expect(page.getByText('This site name is remix-compute-e2e-tests')).toBeVisible()
107+
})
108+
109+
test('can access Netlify Edge Functions context in loader context', async ({ page, edgeSite }) => {
110+
const response = await page.goto(`${edgeSite.url}/context`)
111+
expect(response?.status()).toBe(200)
112+
await expect(page.getByText('This site name is remix-compute-e2e-tests')).toBeVisible()
113+
})
114+
103115
test.describe('classic Remix compiler', () => {
104116
test('serves a response from the origin when using @netlify/remix-adapter', async ({
105117
page,

0 commit comments

Comments
 (0)