modes.spec.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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('backend exposes only local backend contract endpoints', async ({ request }) => {
  21. for (const endpoint of ['/empty.php', '/garbage.php', '/getIP.php']) {
  22. const response = await request.get(`${baseUrls.backend}${endpoint}`);
  23. expect(response.ok()).toBeTruthy();
  24. }
  25. });
  26. test('frontend serves UI and server list without local backend contract', async ({ page, request }) => {
  27. const serverList = await request.get(`${baseUrls.frontend}/server-list.json`);
  28. expect(serverList.ok()).toBeTruthy();
  29. await expect(await serverList.text()).toContain('Backend testpoint');
  30. const localBackendEndpoint = await request.get(`${baseUrls.frontend}/backend/empty.php`);
  31. expect(localBackendEndpoint.status()).toBe(404);
  32. await page.goto(`${baseUrls.frontend}/index-modern.html`);
  33. await expect(modernStartButton(page)).toBeVisible();
  34. await expect(page.locator('#selected-server')).not.toHaveText(/searching nearest server/i);
  35. });
  36. test('dual combines frontend and local backend availability', async ({ page, request }) => {
  37. const serverList = await request.get(`${baseUrls.dual}/server-list.json`);
  38. expect(serverList.ok()).toBeTruthy();
  39. await expect(await serverList.text()).toContain('Local dual backend');
  40. for (const endpoint of ['/backend/empty.php', '/backend/garbage.php', '/backend/getIP.php']) {
  41. const response = await request.get(`${baseUrls.dual}${endpoint}`);
  42. expect(response.ok()).toBeTruthy();
  43. }
  44. await page.goto(`${baseUrls.dual}/index-modern.html`);
  45. await expect(modernStartButton(page)).toBeVisible();
  46. });
  47. });