Skip to content

Commit d8f7595

Browse files
s1gr1dclaude
andauthored
test(e2e): Add nuxt-4-static app to keep static trace lifecycle coverage (#23952)
Reference #23804 This is a verbatim copy of the nuxt-4 app that stays pinned to `traceLifecycle: 'static'` and keeps the transaction-based specs. With the Nuxt/Nitro apps migrating to span streaming, this copy keeps the static trace lifecycle covered by one representative app. Only the app name changed: `package.json` name, the event proxy server name, the `waitFor*` calls in the specs, and the CI variant labels. The e2e matrix discovers apps by directory, so no CI config change is needed. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 999a79a commit d8f7595

67 files changed

Lines changed: 3256 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup>
2+
import { defineProps } from 'vue';
3+
4+
const props = defineProps({
5+
errorText: {
6+
type: String,
7+
required: true,
8+
},
9+
id: {
10+
type: String,
11+
required: true,
12+
},
13+
});
14+
15+
const triggerError = () => {
16+
throw new Error(props.errorText);
17+
};
18+
</script>
19+
20+
<template>
21+
<button :id="props.id" @click="triggerError">Trigger Error</button>
22+
</template>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// fixme: this needs to be imported from @sentry/core, not @sentry/nuxt in dev mode (because of import-in-the-middle error)
2+
// This could also be a problem with the specific setup of the pnpm E2E test setup, because this could not be reproduced outside of the E2E test.
3+
// Related to this: https://github.com/getsentry/sentry-javascript/issues/15204#issuecomment-2948908130
4+
import { setTag } from '@sentry/nuxt';
5+
6+
export default function useSentryTestTag(): void {
7+
setTag('test-tag', null);
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script setup>
2+
import ErrorButton from '../components/ErrorButton.vue';
3+
4+
const catchErr = () => {
5+
console.log('Additional functionality in NuxtErrorBoundary');
6+
};
7+
</script>
8+
9+
<template>
10+
<ErrorButton id="errorBtn" error-text="Error thrown from Nuxt-4 E2E test app" />
11+
<ErrorButton id="errorBtn2" error-text="Another Error thrown from Nuxt-4 E2E test app" />
12+
13+
<NuxtErrorBoundary @error="catchErr">
14+
<ErrorButton id="error-in-error-boundary" error-text="Error thrown in Error Boundary" />
15+
</NuxtErrorBoundary>
16+
</template>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div>
3+
<button @click="fetchError">Fetch Server API Error</button>
4+
<button @click="fetchNitroFetch">Fetch Nitro $fetch</button>
5+
</div>
6+
</template>
7+
8+
<script setup lang="ts">
9+
import { useFetch } from '#imports';
10+
11+
const fetchError = async () => {
12+
await useFetch('/api/server-error');
13+
};
14+
15+
const fetchNitroFetch = async () => {
16+
await useFetch('/api/nitro-fetch');
17+
};
18+
</script>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<NuxtLayout>
3+
<header>
4+
<nav>
5+
<ul>
6+
<li><NuxtLink to="/fetch-server-routes">Fetch Server Routes</NuxtLink></li>
7+
<li><NuxtLink to="/test-param/1234">Fetch Param</NuxtLink></li>
8+
<li><NuxtLink to="/client-error">Client Error</NuxtLink></li>
9+
</ul>
10+
</nav>
11+
</header>
12+
<NuxtPage />
13+
</NuxtLayout>
14+
</template>
15+
16+
<script setup lang="ts">
17+
import { useSentryTestTag } from '#imports';
18+
19+
useSentryTestTag();
20+
</script>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<script setup lang="ts">
2+
import { ref } from '#imports';
3+
import { useCartStore } from '~~/stores/cart';
4+
5+
const cart = useCartStore();
6+
7+
const itemName = ref('');
8+
9+
function addItemToCart() {
10+
if (!itemName.value) return;
11+
cart.addItem(itemName.value);
12+
itemName.value = '';
13+
}
14+
15+
function throwError() {
16+
throw new Error('This is an error');
17+
}
18+
19+
function clearCart() {
20+
if (window.confirm('Are you sure you want to clear the cart?')) {
21+
cart.rawItems = [];
22+
}
23+
}
24+
</script>
25+
26+
<template>
27+
<Layout>
28+
<div>
29+
<div style="margin: 1rem 0">
30+
<PiniaLogo />
31+
</div>
32+
33+
<form @submit.prevent="addItemToCart" data-testid="add-items">
34+
<input id="item-input" type="text" v-model="itemName" />
35+
<button id="item-add">Add</button>
36+
<button id="throw-error" @click="throwError">Throw error</button>
37+
</form>
38+
39+
<form>
40+
<ul data-testid="items">
41+
<li v-for="item in cart.items" :key="item.name">
42+
{{ item.name }} ({{ item.amount }})
43+
<button @click="cart.removeItem(item.name)" type="button">X</button>
44+
</li>
45+
</ul>
46+
47+
<button :disabled="!cart.items.length" @click="clearCart" type="button" data-testid="clear">
48+
Clear the cart
49+
</button>
50+
</form>
51+
</div>
52+
</Layout>
53+
</template>
54+
55+
<style scoped>
56+
img {
57+
width: 200px;
58+
}
59+
60+
button,
61+
input {
62+
margin-right: 0.5rem;
63+
margin-bottom: 0.5rem;
64+
}
65+
</style>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template><p>Client Side Only Page</p></template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template><p>ISR 1h Cached Page</p></template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template><p>ISR Cached Page</p></template>

0 commit comments

Comments
 (0)