From 663f76529c673480ed3779bbaf660e4252811556 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 31 Aug 2022 10:00:26 +0000 Subject: [PATCH] Add serverside integration tests --- .../pages/{ => [id]}/withInitialProps.tsx | 0 .../pages/{ => [id]}/withServerSideProps.tsx | 0 .../client/tracingClientGetInitialProps.js | 2 +- .../client/tracingClientGetServerSideProps.js | 2 +- .../server/tracingServerGetInitialProps.js | 33 +++++++++++++++++++ .../server/tracingServerGetServerSideProps.js | 33 +++++++++++++++++++ 6 files changed, 68 insertions(+), 2 deletions(-) rename packages/nextjs/test/integration/pages/{ => [id]}/withInitialProps.tsx (100%) rename packages/nextjs/test/integration/pages/{ => [id]}/withServerSideProps.tsx (100%) create mode 100644 packages/nextjs/test/integration/test/server/tracingServerGetInitialProps.js create mode 100644 packages/nextjs/test/integration/test/server/tracingServerGetServerSideProps.js diff --git a/packages/nextjs/test/integration/pages/withInitialProps.tsx b/packages/nextjs/test/integration/pages/[id]/withInitialProps.tsx similarity index 100% rename from packages/nextjs/test/integration/pages/withInitialProps.tsx rename to packages/nextjs/test/integration/pages/[id]/withInitialProps.tsx diff --git a/packages/nextjs/test/integration/pages/withServerSideProps.tsx b/packages/nextjs/test/integration/pages/[id]/withServerSideProps.tsx similarity index 100% rename from packages/nextjs/test/integration/pages/withServerSideProps.tsx rename to packages/nextjs/test/integration/pages/[id]/withServerSideProps.tsx diff --git a/packages/nextjs/test/integration/test/client/tracingClientGetInitialProps.js b/packages/nextjs/test/integration/test/client/tracingClientGetInitialProps.js index 90d7eeceef4a..fae23261b144 100644 --- a/packages/nextjs/test/integration/test/client/tracingClientGetInitialProps.js +++ b/packages/nextjs/test/integration/test/client/tracingClientGetInitialProps.js @@ -7,7 +7,7 @@ const { const assert = require('assert').strict; module.exports = async ({ page, url, requests }) => { - await page.goto(`${url}/withInitialProps`); + await page.goto(`${url}/42/withInitialProps`); await page.waitForRequest(isTransactionRequest); const transactionEnvelope = extractEnvelopeFromRequest(requests.transactions[0]); diff --git a/packages/nextjs/test/integration/test/client/tracingClientGetServerSideProps.js b/packages/nextjs/test/integration/test/client/tracingClientGetServerSideProps.js index 0f9ae8e07bac..2936ac5420fa 100644 --- a/packages/nextjs/test/integration/test/client/tracingClientGetServerSideProps.js +++ b/packages/nextjs/test/integration/test/client/tracingClientGetServerSideProps.js @@ -7,7 +7,7 @@ const { const assert = require('assert').strict; module.exports = async ({ page, url, requests }) => { - await page.goto(`${url}/withServerSideProps`); + await page.goto(`${url}/1337/withServerSideProps`); await page.waitForRequest(isTransactionRequest); const transactionEnvelope = extractEnvelopeFromRequest(requests.transactions[0]); diff --git a/packages/nextjs/test/integration/test/server/tracingServerGetInitialProps.js b/packages/nextjs/test/integration/test/server/tracingServerGetInitialProps.js new file mode 100644 index 000000000000..368ccb26a952 --- /dev/null +++ b/packages/nextjs/test/integration/test/server/tracingServerGetInitialProps.js @@ -0,0 +1,33 @@ +const assert = require('assert'); + +const { sleep } = require('../utils/common'); +const { getAsync, interceptTracingRequest } = require('../utils/server'); + +module.exports = async ({ url: urlBase, argv }) => { + const url = `${urlBase}/239/withInitialProps`; + + const capturedRequest = interceptTracingRequest( + { + contexts: { + trace: { + op: 'nextjs.data.server', + }, + }, + transaction: '/[id]/withInitialProps', + transaction_info: { + source: 'route', + }, + type: 'transaction', + request: { + url, + }, + }, + argv, + 'tracingGetInitialProps', + ); + + await getAsync(url); + await sleep(250); + + assert.ok(capturedRequest.isDone(), 'Did not intercept expected request'); +}; diff --git a/packages/nextjs/test/integration/test/server/tracingServerGetServerSideProps.js b/packages/nextjs/test/integration/test/server/tracingServerGetServerSideProps.js new file mode 100644 index 000000000000..8f195d337168 --- /dev/null +++ b/packages/nextjs/test/integration/test/server/tracingServerGetServerSideProps.js @@ -0,0 +1,33 @@ +const assert = require('assert'); + +const { sleep } = require('../utils/common'); +const { getAsync, interceptTracingRequest } = require('../utils/server'); + +module.exports = async ({ url: urlBase, argv }) => { + const url = `${urlBase}/193/withServerSideProps`; + + const capturedRequest = interceptTracingRequest( + { + contexts: { + trace: { + op: 'nextjs.data.server', + }, + }, + transaction: '/[id]/withServerSideProps', + transaction_info: { + source: 'route', + }, + type: 'transaction', + request: { + url, + }, + }, + argv, + 'tracingServerGetServerSideProps', + ); + + await getAsync(url); + await sleep(250); + + assert.ok(capturedRequest.isDone(), 'Did not intercept expected request'); +};