aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/hosted
diff options
context:
space:
mode:
authorGravatar github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> 2025-06-05 14:25:23 +0000
committerGravatar github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> 2025-06-05 14:25:23 +0000
commite586d7d704d475afe3373a1de6ae20d504f79d6d (patch)
tree7e3fa24807cebd48a86bd40f866d792181191ee9 /packages/integrations/netlify/test/hosted
downloadastro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.gz
astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.zst
astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.zip
Sync from a8e1c0a7402940e0fc5beef669522b315052df1blatest
Diffstat (limited to 'packages/integrations/netlify/test/hosted')
-rw-r--r--packages/integrations/netlify/test/hosted/README.md3
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs19
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml3
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/package.json12
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.pngbin0 -> 7295878 bytes
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts1
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts11
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro7
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro13
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro5
-rw-r--r--packages/integrations/netlify/test/hosted/hosted.test.js29
11 files changed, 103 insertions, 0 deletions
diff --git a/packages/integrations/netlify/test/hosted/README.md b/packages/integrations/netlify/test/hosted/README.md
new file mode 100644
index 000000000..8c1814844
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/README.md
@@ -0,0 +1,3 @@
+The tests in this folder are done directly on a deployed Netlify website (hosted at https://curious-boba-495d6d.netlify.app) and are not run by the test suite. They instead run every week through a GitHub action.
+
+The purpose of those tests is to make sure that everything works as expected while deployed. In a way, they're as E2E as it gets.
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs b/packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs
new file mode 100644
index 000000000..94cc00f7b
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs
@@ -0,0 +1,19 @@
+import netlify from '@astrojs/netlify';
+import { defineConfig } from 'astro/config';
+
+// https://astro.build/config
+export default defineConfig({
+ output: 'server',
+ adapter: netlify({
+ edgeMiddleware: true,
+ }),
+ image: {
+ remotePatterns: [
+ {
+ protocol: 'https',
+ hostname: 'images.unsplash.com',
+ pathname: '/photo-1567674867291-b2595ac53ab4',
+ },
+ ],
+ },
+});
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml b/packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml
new file mode 100644
index 000000000..55c8404ee
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/netlify.toml
@@ -0,0 +1,3 @@
+[build]
+command = "pnpm run --filter @test/netlify-hosted-astro-project... build"
+publish = "/packages/netlify/test/hosted/hosted-astro-project/dist"
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json b/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
new file mode 100644
index 000000000..0624ca789
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "@test/netlify-hosted-astro-project",
+ "version": "0.0.0",
+ "private": true,
+ "scripts": {
+ "build": "astro build"
+ },
+ "dependencies": {
+ "@astrojs/netlify": "workspace:*",
+ "astro": "workspace:*"
+ }
+}
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png
new file mode 100644
index 000000000..218acde5b
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png
Binary files differ
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts
new file mode 100644
index 000000000..f7cbe9c1d
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts
@@ -0,0 +1 @@
+/// <reference types="astro/client-image" />
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts
new file mode 100644
index 000000000..1112a3566
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/middleware.ts
@@ -0,0 +1,11 @@
+import https from 'node:https';
+
+export const onRequest = (context, next) => {
+ console.info(context.netlify);
+ context.locals.middleware = context?.locals?.netlify?.context?.geo?.country?.code ?? null;
+ context.locals.runtime = 'Deno' in globalThis ? 'Deno' : 'Node';
+ context.locals.title = 'Middleware';
+ context.locals.nodePrefixedImportExists = !!https;
+
+ return next();
+};
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro
new file mode 100644
index 000000000..cad7116d6
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/country.astro
@@ -0,0 +1,7 @@
+---
+const country = Astro.locals.middleware;
+---
+
+<h1>{country}</h1>
+<h3>{country ? 'has context' : 'no context'}</h3>
+<h2>{Astro.locals.runtime}</h2>
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro
new file mode 100644
index 000000000..7d2cfcdc3
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro
@@ -0,0 +1,13 @@
+---
+import { Image } from 'astro:assets';
+import penguin from '../assets/penguin.png';
+---
+
+<Image src={penguin} width={300} alt="" />
+
+<Image
+ src="https://images.unsplash.com/photo-1567674867291-b2595ac53ab4"
+ width={300}
+ height={400}
+ alt="Astro"
+/>
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro
new file mode 100644
index 000000000..873b5c720
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/time.astro
@@ -0,0 +1,5 @@
+---
+const currentTime = new Date().getTime();
+---
+
+{currentTime}
diff --git a/packages/integrations/netlify/test/hosted/hosted.test.js b/packages/integrations/netlify/test/hosted/hosted.test.js
new file mode 100644
index 000000000..3bc9349f9
--- /dev/null
+++ b/packages/integrations/netlify/test/hosted/hosted.test.js
@@ -0,0 +1,29 @@
+import * as assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
+
+const NETLIFY_TEST_URL = 'https://curious-boba-495d6d.netlify.app';
+
+describe('Hosted Netlify Tests', () => {
+ it('Image endpoint works', async () => {
+ const image = await fetch(
+ `${NETLIFY_TEST_URL}/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp`,
+ );
+
+ assert.equal(image.status, 200);
+ });
+
+ it('passes context from edge middleware', async () => {
+ const response = await fetch(`${NETLIFY_TEST_URL}/country`);
+ const body = await response.text();
+ assert.match(body, /has context/);
+ assert.match(body, /Deno/);
+ });
+
+ it('Server returns fresh content', async () => {
+ const responseOne = await fetch(`${NETLIFY_TEST_URL}/time`).then((res) => res.text());
+
+ const responseTwo = await fetch(`${NETLIFY_TEST_URL}/time`).then((res) => res.text());
+
+ assert.notEqual(responseOne.body, responseTwo.body);
+ });
+});