-
-
Notifications
You must be signed in to change notification settings - Fork 641
/
setup.ts
65 lines (55 loc) · 1.77 KB
/
setup.ts
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
58
59
60
61
62
63
64
65
import { Before, BeforeAll, AfterAll, After } from "@cucumber/cucumber"
import debug from "debug"
import * as playwright from "playwright"
import { getLatestLinkSentTo } from "./step_definitions/fns"
import { FiderWorld } from "./world"
let browser: playwright.Browser
let tenantName: string
type BrowserName = "chromium" | "firefox" | "webkit"
BeforeAll({ timeout: 30 * 1000 }, async function () {
const name = (process.env.BROWSER || "chromium") as BrowserName
browser = await playwright[name].launch({
headless: true,
slowMo: 10,
})
if (!tenantName) {
const now = new Date().getTime()
tenantName = `feedback${now}`
await createNewSite()
}
})
AfterAll(async function () {
await browser.close()
})
Before(async function (this: FiderWorld) {
const context = await browser.newContext({
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
})
this.page = await context.newPage()
this.tenantName = tenantName
this.log = debug("e2e")
})
After(async function (this: FiderWorld) {
await this.page.close()
})
async function createNewSite() {
const context = await browser.newContext({
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
})
const page = await context.newPage()
const adminEmail = `admin-${tenantName}@fider.io`
//Create site
await page.goto("https://login.dev.fider.io:3000/signup")
await page.type("#input-name", "admin")
await page.type("#input-email", adminEmail)
await page.type("#input-tenantName", tenantName)
await page.type("#input-subdomain", tenantName)
await page.check("#input-legalAgreement")
await page.click(".c-button--primary")
//Activate site
const activationLink = await getLatestLinkSentTo(adminEmail)
await page.goto(activationLink)
await page.close()
}