-
-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathhelpers.js
57 lines (50 loc) · 1.54 KB
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const os = require('os')
const path = require('path')
const p = require('playwright')
const electron = p._electron
const { expect } = require('@playwright/test')
async function openAtom(profilePath, videoName) {
const env = process.env
env.ATOM_HOME = path.join("tmp", profilePath)
const config = {
args: ["--no-sandbox", "."],
cwd: ".",
env: env,
timeout: 50000
}
if(env.BINARY_NAME) {
config.executablePath = env.BINARY_NAME
config.args = ["--no-sandbox"]
}
if(process.env.CI) {
config.recordVideo = {
dir: path.join('tests', 'videos', videoName)
}
}
const app = await electron.launch(config)
const page = await app.firstWindow()
await expect(page.locator('.tab-bar').first()).toBeVisible()
return {app, page}
}
async function runCommand({page}, command) {
if(os.platform() === 'darwin') {
await page.locator('atom-workspace').press('Meta+Shift+p')
} else {
await page.locator('atom-workspace').press('Control+Shift+p')
}
await expect(page.locator('atom-panel.modal:visible')).toBeVisible()
const palette = page.locator('.command-palette atom-text-editor.is-focused')
await palette.type(command)
await page.locator('.selected div', { hasText: command }).first().click()
await expect(page.locator('.modal:visible')).toBeHidden()
}
async function typeInEditor({page}, locator, text) {
const editor = page.locator(`${locator} atom-text-editor.is-focused`)
await expect(editor).toBeVisible()
await editor.type(text)
}
module.exports = {
openAtom,
runCommand,
typeInEditor
}