Skip to content

Commit

Permalink
feat: unflag experimental.assets (#7921)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
  • Loading branch information
3 people authored Aug 16, 2023
1 parent 30cb576 commit 8582ae5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
17 changes: 10 additions & 7 deletions packages/integrations/netlify/test/functions/prerender.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { after } from 'node:test';
import netlifyAdapter from '../../dist/index.js';
import { loadFixture, testIntegration } from './test-utils.js';
import { after } from 'node:test';

describe('Mixed Prerendering with SSR', () => {
/** @type {import('./test-utils').Fixture} */
Expand All @@ -27,9 +27,9 @@ describe('Mixed Prerendering with SSR', () => {

it('Wildcard 404 is sorted last', async () => {
const redir = await fixture.readFile('/_redirects');
const baseRouteIndex = redir.indexOf('/ /.netlify/functions/entry 200');
const oneRouteIndex = redir.indexOf('/one /one/index.html 200');
const fourOhFourWildCardIndex = redir.indexOf('/* /.netlify/functions/entry 404');
const baseRouteIndex = redir.indexOf('/ /.netlify/functions/entry 200');
const oneRouteIndex = redir.indexOf('/one /one/index.html 200');
const fourOhFourWildCardIndex = redir.indexOf('/* /.netlify/functions/entry 404');

expect(oneRouteIndex).to.not.be.equal(-1);
expect(fourOhFourWildCardIndex).to.be.greaterThan(baseRouteIndex);
Expand Down Expand Up @@ -61,12 +61,15 @@ describe('Mixed Hybrid rendering with SSR', () => {

it('outputs a correct redirect file', async () => {
const redir = await fixture.readFile('/_redirects');
const baseRouteIndex = redir.indexOf('/one /.netlify/functions/entry 200');
const rootRouteIndex = redir.indexOf('/ /index.html 200');
const fourOhFourIndex = redir.indexOf('/404 /404.html 200');
console.log(redir);
const baseRouteIndex = redir.indexOf('/one /.netlify/functions/entry 200');
const rootRouteIndex = redir.indexOf('/ /index.html 200');
const fourOhFourIndex = redir.indexOf('/404 /404.html 200');
const imageEndpoint = redir.indexOf('/_image /.netlify/functions/entry 200');

expect(rootRouteIndex).to.not.be.equal(-1);
expect(baseRouteIndex).to.not.be.equal(-1);
expect(fourOhFourIndex).to.not.be.equal(-1);
expect(imageEndpoint).to.not.be.equal(-1);
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { loadFixture, testIntegration } from './test-utils.js';
import netlifyAdapter from '../../dist/index.js';
import { loadFixture, testIntegration } from './test-utils.js';

describe('SSG - Redirects', () => {
/** @type {import('../../../astro/test/test-utils').Fixture} */
Expand All @@ -25,6 +25,7 @@ describe('SSG - Redirects', () => {
it('Creates a redirects file', async () => {
let redirects = await fixture.readFile('/_redirects');
let parts = redirects.split(/\s+/);
console.log(parts);
expect(parts).to.deep.equal([
'/other',
'/',
Expand All @@ -38,6 +39,11 @@ describe('SSG - Redirects', () => {
'/.netlify/functions/entry',
'200',

// Image endpoint
'/_image',
'/.netlify/functions/entry',
'200',

// A real route
'/team/articles/*',
'/.netlify/functions/entry',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ exports[`SSG - Redirects Creates a redirects file 1`] = `
"/other / 301
/nope /.netlify/functions/entry 200
/ /.netlify/functions/entry 200
/_image /.netlify/functions/entry 200
/team/articles/* /.netlify/functions/entry 200"
`;
22 changes: 12 additions & 10 deletions packages/integrations/netlify/test/functions/split-support.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Split support', () => {
it('outputs a correct redirect file', async () => {
const redir = await fixture.readFile('/_redirects');
const lines = redir.split(/[\r\n]+/);
expect(lines.length).to.equal(2);
expect(lines.length).to.equal(3);

expect(lines[0].includes('/blog')).to.be.true;
expect(lines[0].includes('blog.astro')).to.be.true;
Expand All @@ -43,15 +43,17 @@ describe('Split support', () => {
describe('Should create multiple functions', () => {
it('and hit 200', async () => {
if (_entryPoints) {
for (const [, filePath] of _entryPoints) {
const { handler } = await import(filePath.toString());
const resp = await handler({
httpMethod: 'POST',
headers: {},
rawUrl: 'http://example.com/',
body: '{}',
});
expect(resp.statusCode).to.equal(200);
for (const [routeData, filePath] of _entryPoints) {
if (routeData.route !== '/_image') {
const { handler } = await import(filePath.toString());
const resp = await handler({
httpMethod: 'GET',
headers: {},
rawUrl: `http://example.com${routeData.route}`,
body: '{}',
});
expect(resp.statusCode).to.equal(200);
}
}
} else {
expect(false).to.be.true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ import { defineConfig } from 'astro/config';
export default defineConfig({
output: 'server',
adapter: netlify(),
experimental: {
assets: true,
},
});

0 comments on commit 8582ae5

Please sign in to comment.