|
1 | | -import path from 'node:path'; |
2 | 1 | import process from 'node:process'; |
3 | | -import { fileURLToPath } from 'node:url'; |
4 | 2 | import { expect } from '@playwright/test'; |
5 | 3 | import { test } from '../../../utils.js'; |
6 | 4 |
|
7 | | -/** @typedef {import('@playwright/test').Response} Response */ |
| 5 | +test.skip(() => !!process.env.REGISTER_SERVICE_WORKER); |
8 | 6 |
|
9 | 7 | test.describe.configure({ mode: 'parallel' }); |
10 | 8 |
|
@@ -107,60 +105,22 @@ test.describe('paths', () => { |
107 | 105 | }); |
108 | 106 |
|
109 | 107 | test.describe('trailing slash', () => { |
110 | | - if (!process.env.DEV) { |
111 | | - test('trailing slash server prerendered without server load', async ({ |
112 | | - page, |
113 | | - clicknav, |
114 | | - javaScriptEnabled |
115 | | - }) => { |
116 | | - if (!javaScriptEnabled) return; |
117 | | - |
118 | | - await page.goto('/basepath/trailing-slash-server'); |
119 | | - |
120 | | - await clicknav('a[href="/basepath/trailing-slash-server/prerender"]'); |
121 | | - expect(await page.textContent('h2')).toBe('/basepath/trailing-slash-server/prerender/'); |
122 | | - }); |
123 | | - } |
| 108 | + test('trailing slash server prerendered without server load', async ({ |
| 109 | + page, |
| 110 | + clicknav, |
| 111 | + javaScriptEnabled |
| 112 | + }) => { |
| 113 | + test.skip(!javaScriptEnabled || !process.env.DEV); |
| 114 | + |
| 115 | + await page.goto('/basepath/trailing-slash-server'); |
| 116 | + |
| 117 | + await clicknav('a[href="/basepath/trailing-slash-server/prerender"]'); |
| 118 | + expect(await page.textContent('h2')).toBe('/basepath/trailing-slash-server/prerender/'); |
| 119 | + }); |
124 | 120 | }); |
125 | 121 |
|
126 | 122 | test.describe('Service worker', () => { |
127 | | - if (process.env.DEV) { |
128 | | - test('import proxy /basepath/service-worker.js', async ({ request }) => { |
129 | | - const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
130 | | - const response = await request.get('/basepath/service-worker.js'); |
131 | | - const content = await response.text(); |
132 | | - expect(content).toEqual( |
133 | | - `import '${path.join('/basepath', '/@fs', __dirname, '../src/service-worker.js')}';` |
134 | | - ); |
135 | | - }); |
136 | | - |
137 | | - return; |
138 | | - } |
139 | | - |
140 | | - test('build /basepath/service-worker.js', async ({ baseURL, request }) => { |
141 | | - const response = await request.get('/basepath/service-worker.js'); |
142 | | - const content = await response.text(); |
143 | | - |
144 | | - const fn = new Function('self', 'location', content); |
145 | | - |
146 | | - const self = { |
147 | | - addEventListener: () => {}, |
148 | | - base: null, |
149 | | - build: null, |
150 | | - image_src: undefined |
151 | | - }; |
152 | | - |
153 | | - const pathname = '/basepath/service-worker.js'; |
154 | | - |
155 | | - fn(self, { |
156 | | - href: baseURL + pathname, |
157 | | - pathname |
158 | | - }); |
159 | | - |
160 | | - expect(self.base).toBe('/basepath'); |
161 | | - expect(self.build?.[0]).toMatch(/\/basepath\/_app\/immutable\/bundle\.[\w-]+\.js/); |
162 | | - expect(self.image_src).toMatch(/\/basepath\/_app\/immutable\/assets\/image\.[\w-]+\.jpg/); |
163 | | - }); |
| 123 | + test.skip(({ javaScriptEnabled }) => !javaScriptEnabled); |
164 | 124 |
|
165 | 125 | test('does not register /basepath/service-worker.js', async ({ page }) => { |
166 | 126 | await page.goto('/basepath'); |
|
0 commit comments