1
0

modes.spec.js 2.5 KB

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