modes.spec.js 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. const { test, expect } = require('@playwright/test');
  2. const { baseUrls } = require('./helpers/env');
  3. const { modernStartButton, classicStartButton } = require('./helpers/ui');
  4. const defaultTagline = 'No Flash, No Java, No Websockets, No Bullsh*t';
  5. const frontendRemoteServerListUrl = 'http://127.0.0.1:18184/tests/e2e/fixtures/servers-frontend-remote.json';
  6. test.describe('Runtime mode smoke coverage', () => {
  7. test('standalone exposes UI and local backend endpoints', async ({ page, request }) => {
  8. const root = await request.get(`${baseUrls.standalone}/`);
  9. expect(root.ok()).toBeTruthy();
  10. const index = await request.get(`${baseUrls.standalone}/index.html`);
  11. expect(index.ok()).toBeTruthy();
  12. await expect(await index.text()).toContain('design-switch.js');
  13. for (const endpoint of ['/backend/empty.php', '/backend/garbage.php', '/backend/getIP.php']) {
  14. const response = await request.get(`${baseUrls.standalone}${endpoint}`);
  15. expect(response.ok()).toBeTruthy();
  16. }
  17. await page.goto(`${baseUrls.standalone}/index-modern.html`);
  18. await expect(modernStartButton(page)).toBeVisible();
  19. await expect(page.locator('main > p.tagline')).toHaveText(defaultTagline);
  20. });
  21. test('Alpine standalone serves modern frontend settings', async ({ page, request }) => {
  22. const settings = await request.get(`${baseUrls.standaloneAlpine}/settings.json`);
  23. expect(settings.ok()).toBeTruthy();
  24. await expect(settings.json()).resolves.toMatchObject({ telemetry_level: 'off', time_dl_max: 12 });
  25. await page.goto(`${baseUrls.standaloneAlpine}/index-modern.html`);
  26. await expect(modernStartButton(page)).toBeVisible();
  27. });
  28. test('backend exposes only local backend contract endpoints', async ({ request }) => {
  29. for (const endpoint of ['/empty.php', '/garbage.php', '/getIP.php']) {
  30. const response = await request.get(`${baseUrls.backend}${endpoint}`);
  31. expect(response.ok()).toBeTruthy();
  32. }
  33. });
  34. test('frontend serves UI and server list without local backend contract', async ({ page, request }) => {
  35. const serverList = await request.get(`${baseUrls.frontend}/server-list.json`);
  36. expect(serverList.ok()).toBeTruthy();
  37. await expect(await serverList.text()).toContain('Backend testpoint');
  38. const localBackendEndpoint = await request.get(`${baseUrls.frontend}/backend/empty.php`);
  39. expect(localBackendEndpoint.status()).toBe(404);
  40. await page.goto(`${baseUrls.frontend}/index-modern.html`);
  41. await expect(modernStartButton(page)).toBeVisible();
  42. await expect(page.locator('#selected-server')).not.toHaveText(/searching nearest server/i);
  43. });
  44. test('frontend starts with SERVER_LIST_URL without requiring /servers.json', async ({ page, request }) => {
  45. const index = await request.get(`${baseUrls.frontendRemote}/index-modern.html`);
  46. expect(index.ok()).toBeTruthy();
  47. await expect(await index.text()).toContain(frontendRemoteServerListUrl);
  48. const stability = await request.get(`${baseUrls.frontendRemote}/stability.html`);
  49. expect(stability.ok()).toBeTruthy();
  50. await expect(await stability.text()).toContain(frontendRemoteServerListUrl);
  51. const localBackendEndpoint = await request.get(`${baseUrls.frontendRemote}/backend/empty.php`);
  52. expect(localBackendEndpoint.status()).toBe(404);
  53. await page.goto(`${baseUrls.frontendRemote}/index-modern.html`);
  54. await expect(modernStartButton(page)).toBeVisible();
  55. await expect(page.locator('#selected-server')).toContainText('Remote frontend backend', { timeout: 10_000 });
  56. });
  57. test('default entrypoint loads the classic frontend with SERVER_LIST_URL', async ({ page }) => {
  58. const pageErrors = [];
  59. page.on('pageerror', (error) => pageErrors.push(error.message));
  60. await page.goto(`${baseUrls.frontendRemote}/index.html`);
  61. await page.waitForURL(/index-classic\.html/);
  62. await expect(classicStartButton(page)).toBeVisible();
  63. await expect(page.locator('#server')).toContainText('Remote frontend backend', { timeout: 10_000 });
  64. expect(pageErrors).toEqual([]);
  65. });
  66. test('dual combines frontend and local backend availability', async ({ page, request }) => {
  67. const serverList = await request.get(`${baseUrls.dual}/server-list.json`);
  68. expect(serverList.ok()).toBeTruthy();
  69. await expect(await serverList.text()).toContain('Local dual backend');
  70. for (const endpoint of ['/backend/empty.php', '/backend/garbage.php', '/backend/getIP.php']) {
  71. const response = await request.get(`${baseUrls.dual}${endpoint}`);
  72. expect(response.ok()).toBeTruthy();
  73. }
  74. await page.goto(`${baseUrls.dual}/index-modern.html`);
  75. await expect(modernStartButton(page)).toBeVisible();
  76. });
  77. });