diff --git a/tests/e2e/export.test.ts b/tests/e2e/export.test.ts index 916f668f97..ec930d0ff8 100644 --- a/tests/e2e/export.test.ts +++ b/tests/e2e/export.test.ts @@ -1,5 +1,4 @@ import { expect, type Locator } from '@playwright/test' -import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs' import { test } from '../utils/playwright-helpers.js' const expectImageWasLoaded = async (locator: Locator) => { diff --git a/tests/integration/wasm.test.ts b/tests/integration/wasm.test.ts index 679117de61..2de9050400 100644 --- a/tests/integration/wasm.test.ts +++ b/tests/integration/wasm.test.ts @@ -1,4 +1,5 @@ import { getLogger } from 'lambda-local' +import { platform } from 'node:process' import { v4 } from 'uuid' import { beforeEach, describe, expect, test, vi } from 'vitest' import { type FixtureTestContext } from '../utils/contexts.js' @@ -52,11 +53,16 @@ describe.each([ expect(og.headers['content-type']).toBe('image/png') }) - test('should work in app route with node runtime', async (ctx) => { - const ogNode = await invokeFunction(ctx, { url: '/og-node' }) - expect(ogNode.statusCode).toBe(200) - expect(ogNode.headers['content-type']).toBe('image/png') - }) + // on Node 18.20.6 on Windows, there seems to be an issue with OG image generation in this scenario + // that is reproducible with `next start` even outside of Netlify context + test.skipIf(platform === 'win32')( + 'should work in app route with node runtime', + async (ctx) => { + const ogNode = await invokeFunction(ctx, { url: '/og-node' }) + expect(ogNode.statusCode).toBe(200) + expect(ogNode.headers['content-type']).toBe('image/png') + }, + ) test('should work in middleware', async (ctx) => { const origin = new LocalServer() diff --git a/tests/netlify-deploy.ts b/tests/netlify-deploy.ts index 25835dfd0e..d7e4b76c88 100644 --- a/tests/netlify-deploy.ts +++ b/tests/netlify-deploy.ts @@ -129,10 +129,11 @@ export class NextDeployInstance extends NextInstance { const deployTitle = process.env.GITHUB_SHA ? `${testName} - ${process.env.GITHUB_SHA}` : testName + const deployAlias = 'vercel-next-e2e' const deployRes = await execa( 'npx', - ['netlify', 'deploy', '--build', '--message', deployTitle ?? ''], + ['netlify', 'deploy', '--build', '--message', deployTitle ?? '', '--alias', deployAlias], { cwd: this.testDir, reject: false, @@ -146,22 +147,23 @@ export class NextDeployInstance extends NextInstance { } try { - const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(deployRes.stdout) || [] - if (!url) { - throw new Error('Could not extract the URL from the build logs') + const deployUrlRegex = new RegExp( + /https:\/\/app\.netlify\.com\/sites\/(?.+)\/deploys\/(?[0-9a-f]+)/gm, + ).exec(deployRes.stdout) + const [buildLogsUrl] = deployUrlRegex || [] + const { deployID, siteName } = deployUrlRegex?.groups || {} + + if (!deployID) { + throw new Error('Could not extract DeployID from the build logs') } - const [deployID] = new URL(url).host.split('--') - this._url = url + + this._url = `https://${deployID}--${siteName}.netlify.app` this._parsedUrl = new URL(this._url) this._deployId = deployID this._shouldDeleteDeploy = !process.env.NEXT_TEST_SKIP_CLEANUP this._cliOutput = deployRes.stdout + deployRes.stderr - require('console').log(`Deployment URL: ${this._url}`) - const [buildLogsUrl] = - new RegExp(/https:\/\/app\.netlify\.com\/sites\/.+\/deploys\/[0-9a-f]+/gm).exec( - deployRes.stdout, - ) || [] + require('console').log(`Deployment URL: ${this._url}`) if (buildLogsUrl) { require('console').log(`Logs: ${buildLogsUrl}`) } diff --git a/tests/utils/create-e2e-fixture.ts b/tests/utils/create-e2e-fixture.ts index 31cf3496e1..cc9c588496 100644 --- a/tests/utils/create-e2e-fixture.ts +++ b/tests/utils/create-e2e-fixture.ts @@ -15,6 +15,7 @@ import { setNextVersionInFixture } from './next-version-helpers.mjs' const DEFAULT_SITE_ID = 'ee859ce9-44a7-46be-830b-ead85e445e53' export const SITE_ID = process.env.NETLIFY_SITE_ID ?? DEFAULT_SITE_ID const NEXT_VERSION = process.env.NEXT_VERSION || 'latest' +const NETLIFY_DEPLOY_ALIAS = 'next-e2e-tests' export interface DeployResult { deployID: string @@ -268,7 +269,7 @@ async function deploySite( console.log(`🚀 Building and deploying site...`) const outputFile = 'deploy-output.txt' - let cmd = `npx netlify deploy --build --site ${siteId}` + let cmd = `npx netlify deploy --build --site ${siteId} --alias ${NETLIFY_DEPLOY_ALIAS}` if (packagePath) { cmd += ` --filter ${packagePath}` @@ -278,12 +279,20 @@ async function deploySite( await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile)) const output = await readFile(join(siteDir, outputFile), 'utf-8') - const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(output) || [] - if (!url) { - throw new Error('Could not extract the URL from the build logs') + const { siteName, deployID } = + new RegExp(/app\.netlify\.com\/sites\/(?.+)\/deploys\/(?[0-9a-f]+)/gm).exec( + output, + )?.groups || {} + + if (!deployID) { + throw new Error('Could not extract DeployID from the build logs') + } + + return { + url: `https://${deployID}--${siteName}.netlify.app`, + deployID, + logs: output, } - const [deployID] = new URL(url).host.split('--') - return { url, deployID, logs: output } } export async function deleteDeploy(deployID?: string): Promise { diff --git a/tools/e2e/cleanup-deploys.ts b/tools/e2e/cleanup-deploys.ts deleted file mode 100644 index 67f3a3f3ad..0000000000 --- a/tools/e2e/cleanup-deploys.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { exec } from 'node:child_process' -import { SITE_ID, deleteDeploy } from '../../tests/utils/create-e2e-fixture.js' - -const runCommand = (cmd: string) => - new Promise((resolve, reject) => - exec(cmd, (err, stdout) => (err ? reject(err) : resolve(stdout))), - ) - -const output = await runCommand(`npx netlify api listSiteDeploys --data='{"site_id":"${SITE_ID}"}'`) -const deploys = JSON.parse(output) - -await Promise.allSettled(deploys.map((deploy) => deleteDeploy(deploy.id)))