summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/functions/prerender.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2023-01-23 09:47:33 -0500
committerGravatar GitHub <noreply@github.com> 2023-01-23 09:47:33 -0500
commitf5adbd6b55ca13a7523dff2cfc5dccdab9980fa7 (patch)
treeb7955f7140c8ea757687441a5ac307e4db4b884d /packages/integrations/netlify/test/functions/prerender.test.js
parent9e57268f1318853b612711b31d7461e9b9ce1978 (diff)
downloadastro-f5adbd6b55ca13a7523dff2cfc5dccdab9980fa7.tar.gz
astro-f5adbd6b55ca13a7523dff2cfc5dccdab9980fa7.tar.zst
astro-f5adbd6b55ca13a7523dff2cfc5dccdab9980fa7.zip
Support prerender in Netlify redirects (#5904)
* Support prerender in Netlify redirects * Updated sorting algorithm * Update packages/integrations/netlify/src/shared.ts Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Diffstat (limited to 'packages/integrations/netlify/test/functions/prerender.test.js')
-rw-r--r--packages/integrations/netlify/test/functions/prerender.test.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/packages/integrations/netlify/test/functions/prerender.test.js b/packages/integrations/netlify/test/functions/prerender.test.js
new file mode 100644
index 000000000..324ebc5c5
--- /dev/null
+++ b/packages/integrations/netlify/test/functions/prerender.test.js
@@ -0,0 +1,30 @@
+import { expect } from 'chai';
+import netlifyAdapter from '../../dist/index.js';
+import { loadFixture, testIntegration } from './test-utils.js';
+
+describe('Mixed Prerendering with SSR', () => {
+ /** @type {import('./test-utils').Fixture} */
+ let fixture;
+
+ before(async () => {
+ fixture = await loadFixture({
+ root: new URL('./fixtures/prerender/', import.meta.url).toString(),
+ output: 'server',
+ adapter: netlifyAdapter({
+ dist: new URL('./fixtures/prerender/dist/', import.meta.url),
+ }),
+ site: `http://example.com`,
+ integrations: [testIntegration()],
+ });
+ await fixture.build();
+ });
+ 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');
+
+ expect(fourOhFourWildCardIndex).to.be.greaterThan(baseRouteIndex);
+ expect(fourOhFourWildCardIndex).to.be.greaterThan(oneRouteIndex);
+ });
+});