diff --git a/packages/test-integration/src/parts/GetRoot/GetRoot.ts b/packages/test-integration/src/parts/GetRoot/GetRoot.ts new file mode 100644 index 00000000..aaf9c838 --- /dev/null +++ b/packages/test-integration/src/parts/GetRoot/GetRoot.ts @@ -0,0 +1,3 @@ +export const getRoot = (): string => { + return new URL('../../../', import.meta.url).toString() +} diff --git a/packages/test-integration/test/PreviewProcessCreateAndStart.test.ts b/packages/test-integration/test/PreviewProcessCreateAndStart.test.ts index d883abac..7c19341a 100644 --- a/packages/test-integration/test/PreviewProcessCreateAndStart.test.ts +++ b/packages/test-integration/test/PreviewProcessCreateAndStart.test.ts @@ -2,13 +2,14 @@ import { expect, test } from '@jest/globals' import getPort from 'get-port' import { createPreviewProcess } from '../src/parts/CreatePreviewProcess/CreatePreviewProcess.js' import { get } from '../src/parts/Get/Get.js' +import { getRoot } from '../src/parts/GetRoot/GetRoot.ts' test('preview process - create and start server', async () => { const previewProcess = createPreviewProcess() const id = 1 const port = await getPort() - const root = new URL('../../../', import.meta.url) const csp = "default-src 'self'; script-src 'self'" + const root = getRoot() await previewProcess.invoke('WebViewServer.create', id) await previewProcess.invoke('WebViewServer.setHandler', id, '', root, csp, '

Hello World

') diff --git a/packages/test-integration/test/PreviewProcessInjectedJs.test.ts b/packages/test-integration/test/PreviewProcessInjectedJs.test.ts index ec35fa8a..dde5f1d9 100644 --- a/packages/test-integration/test/PreviewProcessInjectedJs.test.ts +++ b/packages/test-integration/test/PreviewProcessInjectedJs.test.ts @@ -2,12 +2,13 @@ import { expect, test } from '@jest/globals' import getPort from 'get-port' import { createPreviewProcess } from '../src/parts/CreatePreviewProcess/CreatePreviewProcess.js' import { get } from '../src/parts/Get/Get.js' +import { getRoot } from '../src/parts/GetRoot/GetRoot.js' test('preview process - serves injected js', async () => { const previewProcess = createPreviewProcess() const id = 1 const port = await getPort() - const root = new URL('../../../', import.meta.url) + const root = getRoot() await previewProcess.invoke('WebViewServer.create', id) await previewProcess.invoke('WebViewServer.setHandler', id, '', root, '', '') diff --git a/packages/test-integration/test/PreviewProcessNotFound.test.ts b/packages/test-integration/test/PreviewProcessNotFound.test.ts index 8c77bd02..91afde9e 100644 --- a/packages/test-integration/test/PreviewProcessNotFound.test.ts +++ b/packages/test-integration/test/PreviewProcessNotFound.test.ts @@ -2,12 +2,13 @@ import { expect, test } from '@jest/globals' import getPort from 'get-port' import { createPreviewProcess } from '../src/parts/CreatePreviewProcess/CreatePreviewProcess.js' import { get } from '../src/parts/Get/Get.js' +import { getRoot } from '../src/parts/GetRoot/GetRoot.js' test('preview process - 404 for non-existent files', async () => { const previewProcess = createPreviewProcess() const id = 1 const port = await getPort() - const root = new URL('../../../', import.meta.url) + const root = getRoot() await previewProcess.invoke('WebViewServer.create', id) await previewProcess.invoke('WebViewServer.setHandler', id, '', root, '', '') diff --git a/packages/test-integration/test/PreviewProcessServeStatic.test.ts b/packages/test-integration/test/PreviewProcessServeStatic.test.ts index 2faf85fc..b0db9542 100644 --- a/packages/test-integration/test/PreviewProcessServeStatic.test.ts +++ b/packages/test-integration/test/PreviewProcessServeStatic.test.ts @@ -2,12 +2,13 @@ import { expect, test } from '@jest/globals' import getPort from 'get-port' import { createPreviewProcess } from '../src/parts/CreatePreviewProcess/CreatePreviewProcess.js' import { get } from '../src/parts/Get/Get.js' +import { getRoot } from '../src/parts/GetRoot/GetRoot.js' test('preview process - serve static files', async () => { const previewProcess = createPreviewProcess() const id = 1 const port = await getPort() - const root = new URL('../../../', import.meta.url) + const root = getRoot() await previewProcess.invoke('WebViewServer.create', id) await previewProcess.invoke('WebViewServer.setHandler', id, '', root, '', '')