yaGeey commited on
Commit
20f1d9d
·
1 Parent(s): 7102b00
Files changed (2) hide show
  1. src/actions.ts +9 -1
  2. src/browser.ts +1 -1
src/actions.ts CHANGED
@@ -21,27 +21,34 @@ export const addToPlaylistAction = async (page: Page) => {
21
 
22
  await page.waitForLoadState('networkidle', { timeout: slowHostTimeoutMs }) // Важливо: networkidle краще ніж domcontentloaded для SPA
23
  await dismissConsentIfPresent(page)
 
24
 
25
  const track = page.locator('[data-testid="tracklist-row"]').first()
26
  await track.waitFor({ state: 'visible', timeout: slowHostTimeoutMs })
 
27
 
28
  // ТРЮК 1: Примусовий скрол до елемента перед кліком
29
  await track.scrollIntoViewIfNeeded()
30
  await track.click({ button: 'right', timeout: slowHostTimeoutMs })
 
31
 
32
  const menu = page.locator('[data-testid="context-menu"]')
33
  await menu.waitFor({ state: 'visible', timeout: slowHostTimeoutMs })
 
34
 
35
  const addToPlaylistButton = menu.getByText('Add to Playlist', { exact: false })
36
  await addToPlaylistButton.waitFor({ state: 'visible' })
37
  await addToPlaylistButton.hover() // Hover обов'язковий
 
38
 
39
  const input = page.locator('[placeholder="Find a playlist"]')
40
  await input.waitFor({ state: 'visible', timeout: slowHostTimeoutMs })
 
41
 
42
  // ТРЮК 2: Повільний ввід тексту. Це дає React час обробити стейт.
43
  // Замість fill використовуємо pressSequentially з затримкою
44
  await input.pressSequentially('TEST', { delay: 100 })
 
45
 
46
  // Даємо час на рендеринг відфільтрованого списку
47
  await page.waitForTimeout(1500)
@@ -65,7 +72,8 @@ export const addToPlaylistAction = async (page: Page) => {
65
  }
66
 
67
  // Wait for context menu to close implicitly
68
- await menu.waitFor({ state: 'hidden', timeout: 15000 }).catch(() => {})
 
69
 
70
  // --- БЛОК ОБРОБКИ "Add Anyway" ---
71
  // Тут важливо чекати не просто появи, а появи АБО зникнення діалогу
 
21
 
22
  await page.waitForLoadState('networkidle', { timeout: slowHostTimeoutMs }) // Важливо: networkidle краще ніж domcontentloaded для SPA
23
  await dismissConsentIfPresent(page)
24
+ console.log('page loaded')
25
 
26
  const track = page.locator('[data-testid="tracklist-row"]').first()
27
  await track.waitFor({ state: 'visible', timeout: slowHostTimeoutMs })
28
+ console.log('track found')
29
 
30
  // ТРЮК 1: Примусовий скрол до елемента перед кліком
31
  await track.scrollIntoViewIfNeeded()
32
  await track.click({ button: 'right', timeout: slowHostTimeoutMs })
33
+ console.log('right-clicked track')
34
 
35
  const menu = page.locator('[data-testid="context-menu"]')
36
  await menu.waitFor({ state: 'visible', timeout: slowHostTimeoutMs })
37
+ console.log('context menu visible')
38
 
39
  const addToPlaylistButton = menu.getByText('Add to Playlist', { exact: false })
40
  await addToPlaylistButton.waitFor({ state: 'visible' })
41
  await addToPlaylistButton.hover() // Hover обов'язковий
42
+ console.log('hovered "Add to Playlist"')
43
 
44
  const input = page.locator('[placeholder="Find a playlist"]')
45
  await input.waitFor({ state: 'visible', timeout: slowHostTimeoutMs })
46
+ console.log('search input visible')
47
 
48
  // ТРЮК 2: Повільний ввід тексту. Це дає React час обробити стейт.
49
  // Замість fill використовуємо pressSequentially з затримкою
50
  await input.pressSequentially('TEST', { delay: 100 })
51
+ console.log('typed playlist name with delay')
52
 
53
  // Даємо час на рендеринг відфільтрованого списку
54
  await page.waitForTimeout(1500)
 
72
  }
73
 
74
  // Wait for context menu to close implicitly
75
+ await menu.waitFor({ state: 'hidden', timeout: 15000 }).catch(() => { })
76
+ console.log('context menu closed')
77
 
78
  // --- БЛОК ОБРОБКИ "Add Anyway" ---
79
  // Тут важливо чекати не просто появи, а появи АБО зникнення діалогу
src/browser.ts CHANGED
@@ -47,7 +47,7 @@ export async function createInstance() {
47
  ])
48
  const page = await context.newPage()
49
  await page.route('**/*.{png,jpg,jpeg,gif,woff,woff2,sentry}', (r) => r.abort())
50
- await page.route('**/*onetrust*', (r) => r.abort())
51
  return { browser, context, page }
52
  }
53
 
 
47
  ])
48
  const page = await context.newPage()
49
  await page.route('**/*.{png,jpg,jpeg,gif,woff,woff2,sentry}', (r) => r.abort())
50
+ await page.route('**/*{onetrust,i.scdn.co/image/,mosaic.scdn.co/,encore.scdn.co/fonts}*', (r) => r.abort())
51
  return { browser, context, page }
52
  }
53