소스 검색

test(e2e): verify static modern frontend assets

sstidl 23 시간 전
부모
커밋
bdc1521e14
2개의 변경된 파일40개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      playwright.config.js
  2. 35 0
      tests/e2e/static-repository-assets.spec.js

+ 5 - 0
playwright.config.js

@@ -18,6 +18,11 @@ module.exports = defineConfig({
   },
   globalSetup: require.resolve('./tests/e2e/global-setup.js'),
   globalTeardown: require.resolve('./tests/e2e/global-teardown.js'),
+  webServer: {
+    command: 'python3 -m http.server 18184 --bind 127.0.0.1 --directory .',
+    url: 'http://127.0.0.1:18184',
+    reuseExistingServer: !process.env.CI,
+  },
   projects: [
     {
       name: 'chromium',

+ 35 - 0
tests/e2e/static-repository-assets.spec.js

@@ -0,0 +1,35 @@
+const { test, expect } = require("@playwright/test");
+
+const staticRepositoryUrl = "http://127.0.0.1:18184";
+
+const expectedAssets = [
+  "/index-modern.html",
+  "/settings.json",
+  "/server-list.json",
+  "/frontend/styling/index.css",
+  "/frontend/javascript/index.js",
+  "/frontend/images/logo.svg",
+  "/frontend/images/favicon.svg",
+  "/frontend/images/close-button.svg",
+  "/frontend/images/chevron.svg",
+  "/frontend/fonts/Inter-latin.woff2",
+  "/frontend/fonts/Inter-latin-ext.woff2",
+  "/frontend/images/background.jpeg",
+  "/speedtest.js",
+  "/speedtest_worker.js",
+  "/design-switch.js",
+  "/config.json",
+  "/images/icon-192.png"
+];
+
+test.describe("Unmodified repository static assets", () => {
+  test("serves every modern frontend dependency and returns 404 for a missing path", async ({ request }) => {
+    for (const path of expectedAssets) {
+      const response = await request.get(`${staticRepositoryUrl}${path}`);
+      expect(response.ok(), `${path} should return 2xx`).toBeTruthy();
+    }
+
+    const missing = await request.get(`${staticRepositoryUrl}/does-not-exist`);
+    expect(missing.status()).toBe(404);
+  });
+});