Skip to content

Commit 5933757

Browse files
committed
Add e2e tests
1 parent 7bb07cb commit 5933757

File tree

19 files changed

+191
-471
lines changed

19 files changed

+191
-471
lines changed

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"vite-tsconfig-paths": "^4.2.1",
5050
"ts-node": "10.9.1"
5151
},
52-
"engines": {
53-
"node": ">=18.0.0"
52+
"volta": {
53+
"extends": "../../package.json"
5454
}
5555
}

dev-packages/e2e-tests/test-applications/create-remix-app-express/README.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/entry.client.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* By default, Remix will handle hydrating your app on the client for you.
3-
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
4-
* For more information, see https://remix.run/file-conventions/entry.client
5-
*/
6-
71
import { RemixBrowser, useLocation, useMatches } from '@remix-run/react';
82
import * as Sentry from '@sentry/remix';
93
import { StrictMode, startTransition, useEffect } from 'react';
@@ -24,6 +18,7 @@ Sentry.init({
2418
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
2519
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
2620
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
21+
tunnel: 'http://localhost:3031/', // proxy server
2722
});
2823

2924
Sentry.addEventProcessor(event => {

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/entry.server.tsx

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
1-
/**
2-
* By default, Remix will handle generating the HTTP Response for you.
3-
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
4-
* For more information, see https://remix.run/file-conventions/entry.server
5-
*/
1+
import * as Sentry from '@sentry/remix';
2+
import * as isbotModule from 'isbot';
3+
4+
Sentry.init({
5+
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
6+
environment: 'qa', // dynamic sampling bias to keep transactions
7+
dsn: process.env.E2E_TEST_DSN,
8+
tunnel: 'http://localhost:3031/', // proxy server
9+
sendDefaultPii: true, // Testing the FormData
10+
});
611

712
import { PassThrough } from 'node:stream';
813

914
import type { AppLoadContext, EntryContext } from '@remix-run/node';
1015
import { createReadableStreamFromReadable } from '@remix-run/node';
1116
import { installGlobals } from '@remix-run/node';
1217
import { RemixServer } from '@remix-run/react';
13-
import * as Sentry from '@sentry/remix';
14-
import { isbot } from 'isbot';
1518
import { renderToPipeableStream } from 'react-dom/server';
1619

1720
installGlobals();
1821

1922
const ABORT_DELAY = 5_000;
2023

21-
Sentry.init({
22-
environment: 'qa', // dynamic sampling bias to keep transactions
23-
dsn: process.env.E2E_TEST_DSN,
24-
// Performance Monitoring
25-
tunnel: 'http://localhost:3031/', // proxy server
26-
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
27-
sendDefaultPii: true, // Testing the FormData
28-
});
29-
3024
export const handleError = Sentry.wrapRemixHandleError;
3125

3226
export default function handleRequest(
@@ -36,11 +30,32 @@ export default function handleRequest(
3630
remixContext: EntryContext,
3731
loadContext: AppLoadContext,
3832
) {
39-
return isbot(request.headers.get('user-agent'))
33+
return isBotRequest(request.headers.get('user-agent'))
4034
? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext)
4135
: handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext);
4236
}
4337

38+
// We have some Remix apps in the wild already running with isbot@3 so we need
39+
// to maintain backwards compatibility even though we want new apps to use
40+
// isbot@4. That way, we can ship this as a minor Semver update to @remix-run/dev.
41+
function isBotRequest(userAgent: string | null) {
42+
if (!userAgent) {
43+
return false;
44+
}
45+
46+
// isbot >= 3.8.0, >4
47+
if ('isbot' in isbotModule && typeof isbotModule.isbot === 'function') {
48+
return isbotModule.isbot(userAgent);
49+
}
50+
51+
// isbot < 3.8.0
52+
if ('default' in isbotModule && typeof isbotModule.default === 'function') {
53+
return isbotModule.default(userAgent);
54+
}
55+
56+
return false;
57+
}
58+
4459
function handleBotRequest(
4560
request: Request,
4661
responseStatusCode: number,

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/routes/_index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import { Link } from '@remix-run/react';
1+
import { Link, useSearchParams } from '@remix-run/react';
22
import * as Sentry from '@sentry/remix';
33

44
export default function Index() {
5+
const [searchParams] = useSearchParams();
6+
7+
if (searchParams.get('tag')) {
8+
Sentry.setTag('sentry_test', searchParams.get('tag'));
9+
}
10+
511
return (
612
<div>
713
<input
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
import { json } from '@remix-run/node';
12
import { Form } from '@remix-run/react';
23

3-
export default function Index() {
4+
export async function action({ request }) {
5+
const formData = await request.formData();
6+
7+
console.log('form data', formData.get('text'), formData.get('file'));
8+
9+
return json({ message: 'success' });
10+
}
11+
12+
export default function ActionFormData() {
413
return (
5-
<Form method="POST">
6-
<input name="test" />
14+
<Form method="post" action="/action-formdata" navigate={false}>
15+
<input type="text" name="text" />
716
<input type="file" name="file" />
8-
<input type="file" multiple name="multifile" />
917

1018
<button type="submit">submit</button>
1119
</Form>
1220
);
1321
}
14-
15-
export async function action({ request }) {
16-
const formData = await request.formData();
17-
18-
console.log('form data', formData.get('test'), formData.get('file'));
19-
20-
return new Response('ok');
21-
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/// <reference types="@remix-run/dev" />
21
/// <reference types="@remix-run/node" />
2+
/// <reference types="vite/client" />

0 commit comments

Comments
 (0)