Skip to content

Commit 07c303a

Browse files
committed
test(fix): space not found debug in ci
1 parent 4714835 commit 07c303a

1 file changed

Lines changed: 50 additions & 16 deletions

File tree

  • tests/e2e/support/objects/app-files/spaces

tests/e2e/support/objects/app-files/spaces/actions.ts

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,56 @@ export interface openSpaceArgs {
8282
export const openSpace = async (args: openSpaceArgs): Promise<void> => {
8383
const { page, id } = args
8484
await objects.a11y.Accessibility.assertNoSevereA11yViolations(page, ['filesView'], 'spaces page')
85-
const locator = page.locator(util.format(spaceIdSelector, id))
86-
// Debug: log expected id and all visible space ids with names before waiting for the target space
87-
// eslint-disable-next-line no-console
88-
console.log('DEBUG: Looking for space id:', id)
89-
const allSpaceDetails = await page.$$eval('[data-item-id]', (els) =>
90-
els.map((e) => ({
91-
id: e.getAttribute('data-item-id'),
92-
name: e.querySelector('.oc-resource-basename')?.textContent?.trim()
93-
}))
94-
)
95-
// eslint-disable-next-line no-console
96-
console.log('DEBUG: Visible spaces with names:', allSpaceDetails)
97-
await locator.waitFor({ state: 'visible', timeout: 30000 }) // Wait up to 30s for the space to appear
98-
await locator.click()
99-
await page.locator(spaceHeaderSelector).waitFor({ state: 'visible', timeout: 15000 })
100-
await objects.a11y.Accessibility.assertNoSevereA11yViolations(page, ['filesView'], 'spaces page')
85+
86+
// Retry logic: handle spaces disappearing temporarily in parallel tests
87+
const maxRetries = 3
88+
const retryDelay = 2000 // 2 seconds between retries
89+
90+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
91+
try {
92+
const locator = page.locator(util.format(spaceIdSelector, id))
93+
// Debug: log expected id and all visible space ids with names
94+
// eslint-disable-next-line no-console
95+
console.log(`DEBUG: Attempt ${attempt}/${maxRetries} - Looking for space id:`, id)
96+
const allSpaceDetails = await page.$$eval('[data-item-id]', (els) =>
97+
els.map((e) => ({
98+
id: e.getAttribute('data-item-id'),
99+
name: e.querySelector('.oc-resource-basename')?.textContent?.trim()
100+
}))
101+
)
102+
// eslint-disable-next-line no-console
103+
console.log(`DEBUG: Attempt ${attempt} - Visible spaces with names:`, allSpaceDetails)
104+
105+
await locator.waitFor({ state: 'visible', timeout: 30000 })
106+
await locator.click()
107+
await page.locator(spaceHeaderSelector).waitFor({ state: 'visible', timeout: 15000 })
108+
await objects.a11y.Accessibility.assertNoSevereA11yViolations(page, ['filesView'], 'spaces page')
109+
return // Success - exit function
110+
} catch (error) {
111+
// Check if page is still valid before retrying
112+
if (!page || page.isClosed()) {
113+
throw new Error('Page closed during retry, cannot continue')
114+
}
115+
116+
if (attempt === maxRetries) {
117+
// eslint-disable-next-line no-console
118+
console.log(`DEBUG: All ${maxRetries} attempts failed for space id:`, id)
119+
throw error // Re-throw on final attempt
120+
}
121+
// eslint-disable-next-line no-console
122+
console.log(`DEBUG: Retry ${attempt} failed, waiting ${retryDelay}ms before retry...`)
123+
try {
124+
await page.waitForTimeout(retryDelay)
125+
// Refresh the page to get latest space list (only if page is still valid)
126+
if (!page.isClosed()) {
127+
await page.reload({ waitUntil: 'load' })
128+
}
129+
} catch {
130+
// Page closed during wait - re-throw original error
131+
throw new Error('Page closed during retry, cannot continue')
132+
}
133+
}
134+
}
101135
}
102136
/**/
103137

0 commit comments

Comments
 (0)