|
1 | 1 | import { expect, test } from '@playwright/test' |
2 | | -import { login } from './helpers.js' |
3 | 2 |
|
4 | | -test.describe.serial('App Flow', () => { |
5 | | - let stackName: string |
6 | | - let displayName: string |
7 | | - |
8 | | - test('Login and view dashboard', async ({ page }) => { |
9 | | - await page.goto('/') |
10 | | - await login(page) |
11 | | - }) |
12 | | - |
13 | | - test('Create stack, create service, verify dashboard', async ({ page, browserName }) => { |
14 | | - const uuid = crypto.randomUUID() |
15 | | - |
16 | | - stackName = `e2e-test-stack-${uuid}` |
17 | | - displayName = `E2E Test Stack - ${browserName} - ${uuid}` |
18 | | - |
19 | | - const workingDirectory = `/tmp/e2e-test-stack-${uuid}` |
20 | | - |
21 | | - await page.goto('/') |
22 | | - await login(page) |
23 | | - |
24 | | - // Create stack |
25 | | - await page.locator('button, a', { hasText: 'Create Stack' }).first().click() |
26 | | - await expect(page.locator('shade-create-stack')).toBeVisible() |
27 | | - |
28 | | - await page.locator('input[name="name"]').fill(stackName) |
29 | | - await page.locator('input[name="displayName"]').fill(displayName) |
30 | | - await page.locator('textarea[name="description"]').fill('Created by E2E test') |
31 | | - await page.locator('input[name="mainDirectory"]').fill('/tmp/e2e-test') |
32 | | - await page.locator('button', { hasText: 'Create' }).click() |
33 | | - |
34 | | - await expect(page.locator('shade-noty-list')).toContainText(`Stack "${displayName}" was created successfully.`) |
35 | | - |
36 | | - await expect(page.locator('shade-dashboard')).toBeVisible() |
37 | | - |
38 | | - await expect(page.getByTestId('page-header-title')).toContainText(displayName) |
39 | | - |
40 | | - // Navigate to services list via the dashboard card's "View All" link |
41 | | - await page.locator('shade-dashboard a', { hasText: 'View All' }).first().click() |
42 | | - await expect(page.locator('shade-services-list')).toBeVisible() |
43 | | - await page.locator('button', { hasText: 'Create Service' }).first().click() |
44 | | - await expect(page.locator('shade-create-service-wizard')).toBeVisible() |
45 | | - |
46 | | - await page.locator('input[name="displayName"]').fill('E2E Service') |
47 | | - await page.locator('input[name="workingDirectory"]').fill(workingDirectory) |
48 | | - await page.locator('input[name="runCommand"]').fill('echo hello') |
49 | | - await page.locator('button', { hasText: 'Create' }).click() |
50 | | - |
51 | | - await expect(page.locator('shade-services-list')).toBeVisible() |
52 | | - |
53 | | - // Scope all sidebar interactions to the correct stack |
54 | | - const stackSidebar = page.locator('shade-accordion-item').filter({ hasText: displayName }) |
55 | | - |
56 | | - // Navigate to repositories list |
57 | | - await stackSidebar.locator('shade-sidebar-stack-link a', { hasText: 'Repositories' }).click() |
58 | | - await expect(page.locator('shade-repositories-list')).toBeVisible() |
59 | | - await page.locator('button', { hasText: 'Add Repository' }).first().click() |
60 | | - await expect(page.locator('shade-create-repository')).toBeVisible() |
61 | | - |
62 | | - await page.locator('input[name="displayName"]').fill('FuryStack') |
63 | | - await page.locator('input[name="url"]').fill('https://github.com/furystack/furystack') |
64 | | - await page.locator('button', { hasText: 'Add' }).click() |
65 | | - |
66 | | - await expect(page.locator('shade-repositories-list')).toBeVisible() |
67 | | - |
68 | | - // Navigate to services list |
69 | | - await stackSidebar.locator('shade-sidebar-stack-link a', { hasText: 'Services' }).click() |
70 | | - await expect(page.locator('shade-services-list')).toBeVisible() |
71 | | - await page.locator('button', { hasText: 'Create Service' }).first().click() |
72 | | - await expect(page.locator('shade-create-service-wizard')).toBeVisible() |
73 | | - |
74 | | - await page.locator('input[name="displayName"]').fill('StackCraft DOG FOODING TIME!') |
75 | | - await page.locator('input[name="workingDirectory"]').fill(workingDirectory) |
76 | | - await page.locator('input[name="runCommand"]').fill('echo hello') |
77 | | - await page.locator('button', { hasText: 'Create' }).click() |
78 | | - |
79 | | - await expect(page.locator('shade-services-list')).toBeVisible() |
80 | | - }) |
81 | | - |
82 | | - test('Clean up stack', async ({ page }) => { |
83 | | - await page.goto('/') |
84 | | - await login(page) |
85 | | - |
86 | | - // Click on the stack card in the main dashboard to open its overview |
87 | | - await page.locator('stack-list-dashboard shade-card', { hasText: displayName }).click() |
88 | | - await expect(page.getByTestId('page-header-title')).toContainText(displayName) |
89 | | - |
90 | | - // Navigate to Edit Stack via the header button |
91 | | - await page.locator('a', { hasText: 'Edit Stack' }).click() |
92 | | - await expect(page.locator('shade-edit-stack')).toBeVisible() |
93 | | - |
94 | | - // Delete the stack |
95 | | - await page.locator('button', { hasText: 'Delete Stack' }).click() |
96 | | - await page.locator('shade-dialog .dialog-confirm-btn').click() |
97 | | - |
98 | | - await expect(page.locator('shade-noty-list')).toContainText(`"${displayName}" was deleted.`) |
99 | | - await expect(page.locator('shade-dashboard')).toBeVisible({ timeout: 10000 }) |
100 | | - }) |
| 3 | +import { |
| 4 | + addRepository, |
| 5 | + createStack, |
| 6 | + deleteStack, |
| 7 | + fillServiceForm, |
| 8 | + login, |
| 9 | + navigateToCreateService, |
| 10 | + submitServiceForm, |
| 11 | +} from './helpers/index.js' |
| 12 | + |
| 13 | +test('App Flow', async ({ page, browserName }) => { |
| 14 | + const uuid = crypto.randomUUID() |
| 15 | + |
| 16 | + const stackName = `e2e-test-stack-${uuid}` |
| 17 | + const displayName = `E2E Test Stack - ${browserName} - ${uuid}` |
| 18 | + const workingDirectory = `/tmp/e2e-test-stack-${uuid}` |
| 19 | + |
| 20 | + await page.goto('/') |
| 21 | + await login(page) |
| 22 | + |
| 23 | + try { |
| 24 | + await test.step('Create stack', async () => { |
| 25 | + await createStack(page, { |
| 26 | + name: stackName, |
| 27 | + displayName, |
| 28 | + description: 'Created by E2E test', |
| 29 | + mainDirectory: '/tmp/e2e-test', |
| 30 | + }) |
| 31 | + }) |
| 32 | + |
| 33 | + await test.step('Create first service', async () => { |
| 34 | + await navigateToCreateService(page, displayName) |
| 35 | + await fillServiceForm(page, { displayName: 'E2E Service', workingDirectory, runCommand: 'echo hello' }) |
| 36 | + await submitServiceForm(page) |
| 37 | + await expect(page.locator('shade-services-list')).toBeVisible() |
| 38 | + }) |
| 39 | + |
| 40 | + await test.step('Add repository', async () => { |
| 41 | + await addRepository(page, displayName, { |
| 42 | + displayName: 'FuryStack', |
| 43 | + url: 'https://github.com/furystack/furystack', |
| 44 | + }) |
| 45 | + }) |
| 46 | + |
| 47 | + await test.step('Create second service', async () => { |
| 48 | + await navigateToCreateService(page, displayName) |
| 49 | + await fillServiceForm(page, { |
| 50 | + displayName: 'StackCraft DOG FOODING TIME!', |
| 51 | + workingDirectory, |
| 52 | + runCommand: 'echo hello', |
| 53 | + }) |
| 54 | + await submitServiceForm(page) |
| 55 | + await expect(page.locator('shade-services-list')).toBeVisible() |
| 56 | + }) |
| 57 | + } finally { |
| 58 | + await test.step('Clean up stack', async () => { |
| 59 | + await deleteStack(page, displayName) |
| 60 | + }) |
| 61 | + } |
101 | 62 | }) |
0 commit comments