feat: добавить управление окружениями и Playwright для E2E
This commit is contained in:
73
e2e/environment.spec.ts
Normal file
73
e2e/environment.spec.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Environment Management', () => {
|
||||
test('should not allow removing DEFAULT environment', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.click('button:has-text("Create new")');
|
||||
|
||||
// Try to remove DEFAULT - should be blocked
|
||||
const removeButton = page.locator('button.btn-danger[title="Remove environment"]');
|
||||
|
||||
// The button should be disabled for DEFAULT
|
||||
await expect(removeButton).toBeDisabled();
|
||||
});
|
||||
|
||||
test('should remove non-DEFAULT environment', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.click('button:has-text("Create new")');
|
||||
|
||||
// Create a new environment
|
||||
page.once('dialog', async dialog => {
|
||||
await dialog.accept('toRemove');
|
||||
});
|
||||
await page.click('button.btn-success[title="Add environment"]');
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Verify we have 2 envs
|
||||
await expect(page.locator('#environments option')).toHaveCount(2);
|
||||
|
||||
// Remove the new environment
|
||||
page.once('dialog', async dialog => {
|
||||
await dialog.accept(); // Confirm removal
|
||||
});
|
||||
await page.click('button.btn-danger[title="Remove environment"]');
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// Verify we're back to 1 env (DEFAULT)
|
||||
await expect(page.locator('#environments option')).toHaveCount(1);
|
||||
await expect(page.locator('#environments')).toContainText('DEFAULT');
|
||||
});
|
||||
|
||||
test('should create new environment and switch without errors', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.click('button:has-text("Create new")');
|
||||
|
||||
// Verify DEFAULT environment is loaded
|
||||
await expect(page.locator('#environments')).toContainText('DEFAULT');
|
||||
|
||||
// Create a new environment
|
||||
page.once('dialog', async dialog => {
|
||||
await dialog.accept('env1');
|
||||
});
|
||||
await page.click('button.btn-success[title="Add environment"]');
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Verify new environment is created
|
||||
await expect(page.locator('#environments option')).toHaveCount(2);
|
||||
|
||||
// Switch back to DEFAULT (by index 0)
|
||||
await page.locator('#environments').selectOption({ index: 0 });
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// Verify the page is still working
|
||||
await expect(page.locator('#environments')).toBeVisible();
|
||||
|
||||
// Switch to env1 (by text) - this should NOT cause error
|
||||
await page.locator('#environments').selectOption('env1');
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// Verify the page is still working (no white screen of death)
|
||||
await expect(page.locator('#environments')).toBeVisible();
|
||||
await expect(page.locator('#environments option')).toHaveCount(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user