modes.spec.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const { test, expect } = require('@playwright/test');
  2. const { baseUrls } = require('./helpers/env');
  3. const { modernStartButton } = require('./helpers/ui');
  4. const defaultTagline = 'No Flash, No Java, No Websockets, No Bullsh*t';
  5. test.describe('Runtime mode smoke coverage', () => {
  6. test('standalone exposes UI and local backend endpoints', async ({ page, request }) => {
  7. const root = await request.get(`${baseUrls.standalone}/`);
  8. expect(root.ok()).toBeTruthy();
  9. const index = await request.get(`${baseUrls.standalone}/index.html`);
  10. expect(index.ok()).toBeTruthy();
  11. await expect(await index.text()).toContain('design-switch.js');
  12. for (const endpoint of ['/backend/empty.php', '/backend/garbage.php', '/backend/getIP.php']) {
  13. const response = await request.get(`${baseUrls.standalone}${endpoint}`);
  14. expect(response.ok()).toBeTruthy();
  15. }
  16. await page.goto(`${baseUrls.standalone}/index-modern.html`);
  17. await expect(modernStartButton(page)).toBeVisible();
  18. await expect(page.locator('main > p.tagline')).toHaveText(defaultTagline);
  19. });
  20. test('Alpine standalone serves modern frontend settings', async ({ page, request }) => {
  21. const settings = await request.get(`${baseUrls.standaloneAlpine}/settings.json`);
  22. expect(settings.ok()).toBeTruthy();
  23. await expect(settings.json()).resolves.toMatchObject({ telemetry_level: 'off', time_dl_max: 12 });
  24. await page.goto(`${baseUrls.standaloneAlpine}/index-modern.html`);
  25. await expect(modernStartButton(page)).toBeVisible();
  26. });
  27. test('backend exposes only local backend contract endpoints', async ({ request }) => {
  28. for (const endpoint of ['/empty.php', '/garbage.php', '/getIP.php']) {
  29. const response = await request.get(`${baseUrls.backend}${endpoint}`);
  30. expect(response.ok()).toBeTruthy();
  31. }
  32. });
  33. test('frontend serves UI and server list without local backend contract', async ({ page, request }) => {
  34. const serverList = await request.get(`${baseUrls.frontend}/server-list.json`);
  35. expect(serverList.ok()).toBeTruthy();
  36. await expect(await serverList.text()).toContain('Backend testpoint');
  37. const localBackendEndpoint = await request.get(`${baseUrls.frontend}/backend/empty.php`);
  38. expect(localBackendEndpoint.status()).toBe(404);
  39. await page.goto(`${baseUrls.frontend}/index-modern.html`);
  40. await expect(modernStartButton(page)).toBeVisible();
  41. await expect(page.locator('#selected-server')).not.toHaveText(/searching nearest server/i);
  42. });
  43. test('dual combines frontend and local backend availability', async ({ page, request }) => {
  44. const serverList = await request.get(`${baseUrls.dual}/server-list.json`);
  45. expect(serverList.ok()).toBeTruthy();
  46. await expect(await serverList.text()).toContain('Local dual backend');
  47. for (const endpoint of ['/backend/empty.php', '/backend/garbage.php', '/backend/getIP.php']) {
  48. const response = await request.get(`${baseUrls.dual}${endpoint}`);
  49. expect(response.ok()).toBeTruthy();
  50. }
  51. await page.goto(`${baseUrls.dual}/index-modern.html`);
  52. await expect(modernStartButton(page)).toBeVisible();
  53. });
  54. });