main
ts 42 lines 1.15 KB
Raw
1 import { expect } from '@playwright/test'
2 import { _electron as electron } from 'playwright-core'
3 import { getLibp2p } from './fixtures/get-libp2p.ts'
4 import type { Libp2p } from '@libp2p/interface'
5 import type { ElectronApplication } from 'playwright-core'
6
7 const TEST_USER_AGENT = 'libp2p/test'
8
9 describe('launch app', () => {
10 let electronApp: ElectronApplication
11 let libp2p: Libp2p
12
13 beforeEach(async () => {
14 electronApp = await electron.launch({
15 args: [
16 // https://github.com/electron/electron/issues/42510
17 '--no-sandbox',
18 './dist/src/main/index.js'
19 ]
20 })
21 libp2p = await getLibp2p({
22 nodeInfo: {
23 userAgent: TEST_USER_AGENT
24 }
25 })
26 })
27
28 afterEach(async () => {
29 await electronApp?.close()
30 await libp2p?.stop()
31 })
32
33 it('should detect libp2p node', async () => {
34 const targetListSelector = '.TargetListPanel'
35 const window = await electronApp.firstWindow()
36
37 await window.waitForSelector(`${targetListSelector}:has-text("${TEST_USER_AGENT}")`)
38
39 const outputContent = await window.textContent(targetListSelector)
40 expect(outputContent).toContain(TEST_USER_AGENT)
41 })
42 })