Unverified Commit 99bf5e9a authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Add (failing) test for module based feature telemetry in App Router (#75952)

Noticed this while adding bundle layers to Pages router. The telemetry Webpack plugin is picking up these features but then we're not recording them properly.
parent 2cbd03c8
import Image from 'next/image'
import LegacyImage from 'next/legacy/image'
import profilePic from '../../public/small.jpg'
function About() {
return (
<>
<h1>My Homepage</h1>
<LegacyImage src={profilePic} alt="Picture of the author" />
<Image src={profilePic} alt="Picture of the author" />
<p>Welcome to my homepage!</p>
</>
)
}
export default About
export default function Page() {
return 'hello world'
}
export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
......@@ -84,7 +84,7 @@ describe('config telemetry', () => {
expect(event1).toMatch(/"reactStrictMode": false/)
expect(event1).toMatch(/"turboFlag": false/)
expect(event1).toMatch(/"pagesDir": true/)
expect(event1).toMatch(/"appDir": false/)
expect(event1).toMatch(/"appDir": true/)
} catch (err) {
require('console').error('failing stderr', stderr, err)
throw err
......@@ -287,6 +287,7 @@ describe('config telemetry', () => {
expect.arrayContaining([
{
featureName: 'next/image',
// FIXME: Should be +1 from App Router
invocationCount: 2,
},
{
......@@ -532,12 +533,14 @@ describe('config telemetry', () => {
)
// eslint-disable-next-line jest/no-standalone-expect
expect(featureUsageEvents).toContainEqual({
// FIXME: Should be +1 from App Router
featureName: 'next/legacy/image',
invocationCount: 2,
})
// eslint-disable-next-line jest/no-standalone-expect
expect(featureUsageEvents).toContainEqual({
featureName: 'next/image',
// FIXME: Should be +1 from App Router
invocationCount: 2,
})
}
......@@ -724,6 +727,7 @@ describe('config telemetry', () => {
path.join(appDir, 'next.config.js')
)
await fs.move(path.join(appDir, 'app'), path.join(appDir, '~app'))
await fs.move(path.join(appDir, '_app'), path.join(appDir, 'app'))
const { stderr } = await nextBuild(appDir, [], {
......@@ -737,6 +741,7 @@ describe('config telemetry', () => {
)
await fs.move(path.join(appDir, 'app'), path.join(appDir, '_app'))
await fs.move(path.join(appDir, '~app'), path.join(appDir, 'app'))
const featureUsageEvents = findAllTelemetryEvents(
stderr,
......
......@@ -382,8 +382,8 @@ describe('Telemetry CLI', () => {
expect(event1).toMatch(/"ssrPageCount": 3/)
expect(event1).toMatch(/"staticPageCount": 5/)
expect(event1).toMatch(/"totalPageCount": 12/)
expect(event1).toMatch(/"totalAppPagesCount": 0/)
expect(event1).toMatch(/"staticAppPagesCount": 0/)
expect(event1).toMatch(/"totalAppPagesCount": 3/)
expect(event1).toMatch(/"staticAppPagesCount": 3/)
expect(event1).toMatch(/"serverAppPagesCount": 0/)
expect(event1).toMatch(/"edgeRuntimeAppCount": 0/)
expect(event1).toMatch(/"edgeRuntimePagesCount": 2/)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment