Skip to content

Commit b56be97

Browse files
committed
wip
1 parent 06b8a82 commit b56be97

6 files changed

Lines changed: 352 additions & 117 deletions

File tree

dashboard/e2e/tree-details.spec.ts

Lines changed: 50 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { test, expect } from '@playwright/test';
22

33
import { TREE_DETAILS_SELECTORS, TREE_LISTING_SELECTORS } from './selectors';
4+
import {
5+
navigateAndWait,
6+
navigateBackViaBreadcrumb,
7+
clickAndVerifyNavigation,
8+
withFilterDrawer,
9+
} from './utils';
410

511
test.describe('Tree Details Page Tests', () => {
612
const TREE_URL =
@@ -12,55 +18,38 @@ test.describe('Tree Details Page Tests', () => {
1218
});
1319

1420
test('opens and closes filter drawer', async ({ page }) => {
15-
await page.goto(TREE_URL, { timeout: 30000 });
16-
await page.waitForLoadState('domcontentloaded');
17-
18-
const filterButton = page.locator(TREE_DETAILS_SELECTORS.filters.button);
19-
await filterButton.waitFor({ state: 'visible', timeout: 10000 });
20-
await filterButton.click();
21+
await navigateAndWait(page, TREE_URL);
2122

22-
const cancelButton = page.locator(
23+
await withFilterDrawer(
24+
page,
25+
TREE_DETAILS_SELECTORS.filters.button,
2326
TREE_DETAILS_SELECTORS.filters.cancelButton,
27+
TREE_DETAILS_SELECTORS.filters.drawerContent,
2428
);
25-
await expect(cancelButton).toBeVisible();
26-
await cancelButton.click();
27-
28-
await expect(cancelButton).not.toBeVisible();
2929
});
3030

3131
test('clicks on details button on build table and goes back via breadcrumb', async ({
3232
page,
3333
}) => {
34-
await page.goto(TREE_URL, { timeout: 30000 });
35-
await page.waitForLoadState('domcontentloaded');
34+
await navigateAndWait(page, TREE_URL);
3635

3736
const detailsButton = page
3837
.locator(TREE_DETAILS_SELECTORS.buildTable.detailsButton)
3938
.first();
4039
await expect(detailsButton).toBeVisible({ timeout: 30000 });
4140

42-
await detailsButton.click();
41+
await clickAndVerifyNavigation(detailsButton, /\/build\//);
4342

44-
await page.waitForURL(/\/build\//, { timeout: 30000 });
45-
46-
const url = page.url();
47-
expect(url).toMatch(/\/build\//);
48-
49-
const breadcrumbLink = page.locator(
43+
await navigateBackViaBreadcrumb(
44+
page,
5045
TREE_DETAILS_SELECTORS.breadcrumbTreesLink,
5146
);
52-
await expect(breadcrumbLink).toBeVisible();
53-
await breadcrumbLink.click();
54-
55-
await page.waitForURL(/\/tree/, { timeout: 20000 });
56-
await expect(page).toHaveURL(/\/tree/);
5747
});
5848

5949
test('clicks on an issue details button on issue card and goes back via breadcrumb', async ({
6050
page,
6151
}) => {
62-
await page.goto(TREE_URL, { timeout: 30000 });
63-
await page.waitForLoadState('domcontentloaded');
52+
await navigateAndWait(page, TREE_URL);
6453

6554
const issuesCardButton = page.locator(
6655
TREE_DETAILS_SELECTORS.issuesCard.button,
@@ -70,27 +59,17 @@ test.describe('Tree Details Page Tests', () => {
7059
if (hasIssues) {
7160
await expect(issuesCardButton).toBeVisible();
7261

73-
await issuesCardButton.click();
74-
75-
await page.waitForURL(/\/issues\//, { timeout: 20000 });
62+
await clickAndVerifyNavigation(issuesCardButton, /\/issues\//);
7663

77-
const url = page.url();
78-
expect(url).toMatch(/\/issues\//);
79-
80-
const breadcrumbLink = page.locator(
64+
await navigateBackViaBreadcrumb(
65+
page,
8166
TREE_DETAILS_SELECTORS.breadcrumbTreesLink,
8267
);
83-
await expect(breadcrumbLink).toBeVisible();
84-
await breadcrumbLink.click();
85-
86-
await page.waitForURL(/\/tree/, { timeout: 20000 });
87-
await expect(page).toHaveURL(/\/tree/);
8868
}
8969
});
9070

9171
test('selects other tabs', async ({ page }) => {
92-
await page.goto(TREE_URL, { timeout: 30000 });
93-
await page.waitForLoadState('domcontentloaded');
72+
await navigateAndWait(page, TREE_URL);
9473

9574
const bootsTab = page.locator(TREE_DETAILS_SELECTORS.tabs.boots);
9675
await expect(bootsTab).toBeVisible();
@@ -112,8 +91,7 @@ test.describe('Tree Details Page Tests', () => {
11291
test('clicks on a test item and clicks on detail button for test item', async ({
11392
page,
11493
}) => {
115-
await page.goto(TREE_URL, { timeout: 30000 });
116-
await page.waitForLoadState('domcontentloaded');
94+
await navigateAndWait(page, TREE_URL);
11795

11896
const testsTab = page.locator(TREE_DETAILS_SELECTORS.tabs.tests);
11997
await expect(testsTab).toBeVisible();
@@ -141,30 +119,20 @@ test.describe('Tree Details Page Tests', () => {
141119
.first();
142120
await expect(detailsButton).toBeVisible({ timeout: 10000 });
143121

144-
await detailsButton.click();
145-
146-
await page.waitForURL(/\/test\//, { timeout: 30000 });
122+
await clickAndVerifyNavigation(detailsButton, /\/test\//);
147123

148-
const url = page.url();
149-
expect(url).toMatch(/\/test\//);
150-
151-
const breadcrumbLink = page.locator(
124+
await navigateBackViaBreadcrumb(
125+
page,
152126
TREE_DETAILS_SELECTORS.breadcrumbTreesLink,
153127
);
154-
await expect(breadcrumbLink).toBeVisible();
155-
await breadcrumbLink.click();
156-
157-
await page.waitForURL(/\/tree/, { timeout: 20000 });
158-
await expect(page).toHaveURL(/\/tree/);
159128
}
160129
}
161130
});
162131

163132
test('full workflow: navigate to tree details and back via breadcrumb', async ({
164133
page,
165134
}) => {
166-
await page.goto('/tree', { timeout: 30000 });
167-
await page.waitForLoadState('domcontentloaded');
135+
await navigateAndWait(page, '/tree');
168136

169137
await expect(page).toHaveURL(/\/tree$/);
170138

@@ -173,26 +141,19 @@ test.describe('Tree Details Page Tests', () => {
173141
.first();
174142
await expect(firstTreeLink).toBeVisible();
175143

176-
await firstTreeLink.click();
177-
178-
await page.waitForURL(/\/tree\/[^/]+\/[^/]+\/[^/]+$/, { timeout: 30000 });
179-
180-
const url = page.url();
181-
expect(url).toMatch(/\/tree\/[^/]+\/[^/]+\/[^/]+$/);
144+
await clickAndVerifyNavigation(
145+
firstTreeLink,
146+
/\/tree\/[^/]+\/[^/]+\/[^/]+$/,
147+
);
182148

183-
const breadcrumbLink = page.locator(
149+
await navigateBackViaBreadcrumb(
150+
page,
184151
TREE_DETAILS_SELECTORS.breadcrumbTreesLink,
185152
);
186-
await expect(breadcrumbLink).toBeVisible();
187-
await breadcrumbLink.click();
188-
189-
await page.waitForURL(/\/tree/, { timeout: 20000 });
190-
await expect(page).toHaveURL(/\/tree/);
191153
});
192154

193155
test('build table status filters work correctly', async ({ page }) => {
194-
await page.goto(TREE_URL, { timeout: 30000 });
195-
await page.waitForLoadState('domcontentloaded');
156+
await navigateAndWait(page, TREE_URL);
196157

197158
const allFilter = page.locator(
198159
TREE_DETAILS_SELECTORS.buildTable.statusFilters.all,
@@ -210,8 +171,7 @@ test.describe('Tree Details Page Tests', () => {
210171
});
211172

212173
test('search input is visible and functional', async ({ page }) => {
213-
await page.goto(TREE_URL, { timeout: 30000 });
214-
await page.waitForLoadState('domcontentloaded');
174+
await navigateAndWait(page, TREE_URL);
215175

216176
const searchInput = page.locator(
217177
TREE_DETAILS_SELECTORS.buildTable.searchInput,
@@ -224,8 +184,7 @@ test.describe('Tree Details Page Tests', () => {
224184
});
225185

226186
test('navigates back one commit via commit graph', async ({ page }) => {
227-
await page.goto(TREE_URL, { timeout: 30000 });
228-
await page.waitForLoadState('domcontentloaded');
187+
await navigateAndWait(page, TREE_URL);
229188

230189
const currentUrl = page.url();
231190

@@ -259,38 +218,25 @@ test.describe('Tree Details Page Tests', () => {
259218
});
260219

261220
test('clears all filters', async ({ page }) => {
262-
await page.goto(TREE_URL, { timeout: 30000 });
263-
await page.waitForLoadState('domcontentloaded');
221+
await navigateAndWait(page, TREE_URL);
264222

265-
// Open the filters drawer
266-
const filterButton = page.locator(TREE_DETAILS_SELECTORS.filters.button);
267-
await filterButton.waitFor({ state: 'visible', timeout: 10000 });
268-
await filterButton.click();
269-
270-
// Wait for the drawer content to be visible (it's in a portal)
271-
const drawerContent = page.locator(
223+
await withFilterDrawer(
224+
page,
225+
TREE_DETAILS_SELECTORS.filters.button,
226+
TREE_DETAILS_SELECTORS.filters.cancelButton,
272227
TREE_DETAILS_SELECTORS.filters.drawerContent,
273-
);
274-
await expect(drawerContent).toBeVisible({ timeout: 10000 });
275-
276-
// Check if "Clear all" button exists and click it
277-
const clearAllButton = page.locator(
278-
TREE_DETAILS_SELECTORS.filters.clearAllFilters,
279-
);
280-
const hasClearAllButton = (await clearAllButton.count()) > 0;
281-
282-
if (hasClearAllButton) {
283-
await clearAllButton.click();
284-
285-
await page.waitForTimeout(1000);
286-
}
228+
async page => {
229+
// Check if "Clear all" button exists and click it
230+
const clearAllButton = page.locator(
231+
TREE_DETAILS_SELECTORS.filters.clearAllFilters,
232+
);
233+
const hasClearAllButton = (await clearAllButton.count()) > 0;
287234

288-
const cancelButton = page.locator(
289-
TREE_DETAILS_SELECTORS.filters.cancelButton,
235+
if (hasClearAllButton) {
236+
await clearAllButton.click();
237+
await page.waitForTimeout(1000);
238+
}
239+
},
290240
);
291-
await expect(cancelButton).toBeVisible();
292-
await cancelButton.click();
293-
294-
await expect(drawerContent).not.toBeVisible();
295241
});
296242
});

dashboard/e2e/tree-listing.spec.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {
55
COMMON_SELECTORS,
66
TREE_DETAILS_SELECTORS,
77
} from './selectors';
8+
import { navigateBackViaBreadcrumb, clickAndVerifyNavigation } from './utils';
89

910
const PAGE_LOAD_TIMEOUT = 5000;
1011
const DEFAULT_ACTION_TIMEOUT = 1000;
1112
const SEARCH_UPDATE_TIMEOUT = 2000;
1213
const NAVIGATION_TIMEOUT = 5000;
13-
const GO_BACK_TIMEOUT = 3000;
1414

1515
test.describe('Tree Listing Page Tests', () => {
1616
test.beforeEach(async ({ page }) => {
@@ -84,21 +84,17 @@ test.describe('Tree Listing Page Tests', () => {
8484
const firstTreeLink = page.locator('td a').first();
8585
await expect(firstTreeLink).toBeVisible();
8686

87-
await firstTreeLink.click();
88-
89-
await page.waitForTimeout(NAVIGATION_TIMEOUT);
90-
91-
const url = page.url();
92-
expect(url).toMatch(/\/tree\/[^/]+\/[^/]+\/[^/]+$/);
87+
await clickAndVerifyNavigation(
88+
firstTreeLink,
89+
/\/tree\/[^/]+\/[^/]+\/[^/]+$/,
90+
{ waitAfterClick: NAVIGATION_TIMEOUT },
91+
);
9392

94-
const breadcrumbLink = page.locator(
93+
await navigateBackViaBreadcrumb(
94+
page,
9595
TREE_DETAILS_SELECTORS.breadcrumbTreesLink,
96+
{ expectedUrl: /\/tree$/ },
9697
);
97-
await expect(breadcrumbLink).toBeVisible({ timeout: 15000 });
98-
await breadcrumbLink.click();
99-
await page.waitForTimeout(GO_BACK_TIMEOUT);
100-
101-
await expect(page).toHaveURL(/\/tree$/);
10298
});
10399

104100
test('pagination navigation', async ({ page }) => {

0 commit comments

Comments
 (0)