-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathEditor.e2e.test.js
53 lines (41 loc) · 1.23 KB
/
Editor.e2e.test.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
import puppeteer from "puppeteer"
import { t } from "../src/utils/languages"
const sleep = (milliseconds) => {
const timestamp = Date.now() + milliseconds
while (timestamp > Date.now()) {
//
}
}
const searchIcon =
"#root > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(8) > div:nth-child(1)"
describe("Editor End-To-End", () => {
let browser
let page
beforeAll(async () => {
browser = await puppeteer.launch({ headless: "new" })
page = await browser.newPage()
page.setUserAgent("test-agent")
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, "language", {
get: function () {
return "en-US"
},
})
})
try {
await page.goto("http://localhost:3000")
} catch (err) {
throw Error("Please run 'npm run start' first.")
}
})
test("Checking if the Code Editor is mounted and working", async () => {
await page.waitForSelector(searchIcon)
sleep(5000)
await page.click(searchIcon)
sleep(5000)
const bodyContent = await page.$eval(".ace_search_field", (el) => el.placeholder)
sleep(200)
expect(bodyContent).toContain(t("SEARCH_FOR"))
})
afterAll(() => browser.close())
})