File size: 983 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Page } from '@playwright/test'
import path from 'path'

export const adminSessionFile = path.join(
  __dirname,
  '../../../admin.session.json',
)
export const userSessionFile = path.join(
  __dirname,
  '../../../user.session.json',
)

export const adminUserCreds = {
  name: 'Admin McIntegrationFace',
  user: 'admin',
  pass: 'admin123',
}
export const normalUserCreds = {
  name: 'User McIntegrationFace',
  user: 'user',
  pass: 'user1234',
}

export type Creds = typeof adminUserCreds | typeof normalUserCreds

export async function login(
  page: Page,
  user: string,
  pass: string,
): Promise<void> {
  await page.fill('input[name=username]', user)
  await page.fill('input[name=password]', pass)
  await page.click('button[type=submit] >> "Login"')
}

export async function logout(page: Page): Promise<void> {
  // click logout from manage profile
  await page.locator('[aria-label="Manage Profile"]').click()
  await page.locator('button >> "Logout"').click()
}