Skip to content

Commit c9f3a2e

Browse files
authored
test(remix): Fix integration test flakes (#17093)
Looks like `example.com` has some kind of rate limit or random unavailability. Switching to `docs.sentry.io` resolved the flakes. Maybe we can replace all `example.com` uses in the codebase with a Sentry domain 🤔 Wdyt?
1 parent 2390462 commit c9f3a2e

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

packages/remix/test/integration/app/root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export const loader: LoaderFunction = async ({ request }) => {
4848
case 'returnRedirect':
4949
return redirect('/?type=plain');
5050
case 'throwRedirectToExternal':
51-
throw redirect('https://example.com');
51+
throw redirect(`https://docs.sentry.io`);
5252
case 'returnRedirectToExternal':
53-
return redirect('https://example.com');
53+
return redirect('https://docs.sentry.io');
5454
default: {
5555
return {};
5656
}

packages/remix/test/integration/test/client/root-loader.test.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Page, expect, test } from '@playwright/test';
1+
import { type Page, expect, test, chromium } from '@playwright/test';
22

33
async function getRouteData(page: Page): Promise<any> {
44
return page.evaluate('window.__remixContext.state.loaderData').catch(err => {
@@ -22,7 +22,6 @@ async function extractTraceAndBaggageFromMeta(
2222

2323
test('should inject `sentry-trace` and `baggage` into root loader returning an empty object.', async ({ page }) => {
2424
await page.goto('/?type=empty');
25-
2625
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
2726

2827
expect(sentryTrace).toMatch(/.+/);
@@ -38,7 +37,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning an e
3837

3938
test('should inject `sentry-trace` and `baggage` into root loader returning a plain object.', async ({ page }) => {
4039
await page.goto('/?type=plain');
41-
4240
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
4341

4442
expect(sentryTrace).toMatch(/.+/);
@@ -56,7 +54,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a pl
5654

5755
test('should inject `sentry-trace` and `baggage` into root loader returning a `JSON response`.', async ({ page }) => {
5856
await page.goto('/?type=json');
59-
6057
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
6158

6259
expect(sentryTrace).toMatch(/.+/);
@@ -74,7 +71,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a `J
7471

7572
test('should inject `sentry-trace` and `baggage` into root loader returning a deferred response', async ({ page }) => {
7673
await page.goto('/?type=defer');
77-
7874
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
7975

8076
expect(sentryTrace).toMatch(/.+/);
@@ -90,7 +86,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a de
9086

9187
test('should inject `sentry-trace` and `baggage` into root loader returning `null`.', async ({ page }) => {
9288
await page.goto('/?type=null');
93-
9489
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
9590

9691
expect(sentryTrace).toMatch(/.+/);
@@ -106,7 +101,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning `nul
106101

107102
test('should inject `sentry-trace` and `baggage` into root loader returning `undefined`.', async ({ page }) => {
108103
await page.goto('/?type=undefined');
109-
110104
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
111105

112106
expect(sentryTrace).toMatch(/.+/);
@@ -124,12 +118,11 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red
124118
page,
125119
}) => {
126120
await page.goto('/?type=throwRedirect');
121+
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
127122

128123
// We should be successfully redirected to the path.
129124
expect(page.url()).toEqual(expect.stringContaining('/?type=plain'));
130125

131-
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
132-
133126
expect(sentryTrace).toMatch(/.+/);
134127
expect(sentryBaggage).toMatch(/.+/);
135128

@@ -143,14 +136,14 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red
143136

144137
test('should inject `sentry-trace` and `baggage` into root loader returning a redirection to valid path.', async ({
145138
page,
139+
baseURL,
146140
}) => {
147-
await page.goto('/?type=returnRedirect');
141+
await page.goto(`${baseURL}/?type=returnRedirect`);
142+
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
148143

149144
// We should be successfully redirected to the path.
150145
expect(page.url()).toEqual(expect.stringContaining('/?type=plain'));
151146

152-
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
153-
154147
expect(sentryTrace).toMatch(/.+/);
155148
expect(sentryBaggage).toMatch(/.+/);
156149

@@ -162,23 +155,22 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a re
162155
});
163156
});
164157

165-
test('should return redirect to an external path with no baggage and trace injected.', async ({ page }) => {
166-
await page.goto('/?type=returnRedirectToExternal');
158+
test('should return redirect to an external path with no baggage and trace injected.', async ({ page, baseURL }) => {
159+
await page.goto(`${baseURL}/?type=returnRedirectToExternal`);
167160

168-
// We should be successfully redirected to the external path.
169-
expect(page.url()).toEqual(expect.stringContaining('https://example.com'));
161+
expect(page.url()).toEqual(expect.stringContaining('docs.sentry.io'));
170162

171163
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
172164

173165
expect(sentryTrace).toBeUndefined();
174166
expect(sentryBaggage).toBeUndefined();
175167
});
176168

177-
test('should throw redirect to an external path with no baggage and trace injected.', async ({ page }) => {
178-
await page.goto('/?type=throwRedirectToExternal');
169+
test('should throw redirect to an external path with no baggage and trace injected.', async ({ page, baseURL }) => {
170+
await page.goto(`${baseURL}/?type=throwRedirectToExternal`);
179171

180172
// We should be successfully redirected to the external path.
181-
expect(page.url()).toEqual(expect.stringContaining('https://example.com'));
173+
expect(page.url()).toEqual(expect.stringContaining('docs.sentry.io'));
182174

183175
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
184176

0 commit comments

Comments
 (0)