mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 00:43:59 +03:00
Revert "update test scripts to exclude livness tests" (#5663)
Signed-off-by: Jasmin <jasmin@hardcoreeng.com>
This commit is contained in:
parent
dff3ccd4a4
commit
0b76c264bc
@ -3,6 +3,7 @@ PLATFORM_TRANSACTOR='ws://localhost:3334'
|
||||
PLATFORM_USER='user1'
|
||||
PLATFORM_USER_SECOND='user2'
|
||||
PLATFORM_TOKEN='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InVzZXIxIiwid29ya3NwYWNlIjoic2FuaXR5LXdzIn0.hfUCqePHO-WNps2by4B-CYGKIpDpLG0WVCUUtU-SVI4'
|
||||
ACCOUNT_URL='http://localhost:3003/'
|
||||
LOCAL_URL='http://localhost:3003/'
|
||||
DEV_URL='http://localhost:8080/account'
|
||||
SETTING=storage.json
|
||||
SETTING_SECOND=storageSecond.json
|
||||
|
@ -19,10 +19,10 @@
|
||||
"format": "format tests",
|
||||
"ci": "playwright install --with-deps chromium",
|
||||
"test": "",
|
||||
"uitest": "playwright test -c ./tests/playwright.config.ts --grep-invert '@livness'",
|
||||
"dev-uitest": "cross-env PLATFORM_URI=http://localhost:8080 PLATFORM_TRANSACTOR=ws://localhost:3333 SETTING=storage-dev.json SETTING_SECOND=storageSecond-dev.json playwright test -c ./tests/playwright.config.ts --grep-invert '@livness'",
|
||||
"uitest": "cross-env LOCAL_URL=http://localhost:3003/ DEV_URL= playwright test -c ./tests/playwright.config.ts",
|
||||
"dev-uitest": "cross-env PLATFORM_URI=http://localhost:8080 PLATFORM_TRANSACTOR=ws://localhost:3333 SETTING=storage-dev.json SETTING_SECOND=storageSecond-dev.json DEV_URL=http://localhost:8080/account playwright test -c ./tests/playwright.config.ts",
|
||||
"debug": "playwright test -c ./tests/playwright.config.ts --debug --headed",
|
||||
"dev-debug": "cross-env PLATFORM_URI=http://localhost:8080 PLATFORM_TRANSACTOR=ws://localhost:3333 SETTING=storage-dev.json SETTING_SECOND=storageSecond-dev.json playwright test -c ./tests/playwright.config.ts --debug --headed --grep-invert '@livness'",
|
||||
"dev-debug": "cross-env PLATFORM_URI=http://localhost:8080 PLATFORM_TRANSACTOR=ws://localhost:3333 SETTING=storage-dev.json SETTING_SECOND=storageSecond-dev.json playwright test -c ./tests/playwright.config.ts --debug --headed",
|
||||
"codegen": "playwright codegen --load-storage storage.json http://localhost:8083/workbench/sanity-ws/",
|
||||
"dev-codegen": "cross-env playwright codegen --load-storage storage-dev.json http://localhost:8080/workbench/sanity-ws/",
|
||||
"allure:generate": "allure generate allure-results -o allure-report --clean"
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { APIRequestContext } from '@playwright/test'
|
||||
import { PlatformURI, AccountUrl } from '../utils'
|
||||
import { PlatformURI, LocalUrl, DevUrl } from '../utils'
|
||||
|
||||
export class ApiEndpoint {
|
||||
private readonly request: APIRequestContext
|
||||
private readonly baseUrl: string
|
||||
|
||||
constructor (request: APIRequestContext) {
|
||||
this.request = request
|
||||
this.baseUrl = typeof DevUrl === 'string' && DevUrl.trim() !== '' ? DevUrl : LocalUrl
|
||||
}
|
||||
|
||||
private getDefaultHeaders (token: string = ''): Record<string, string> {
|
||||
@ -21,7 +23,7 @@ export class ApiEndpoint {
|
||||
}
|
||||
|
||||
private async loginAndGetToken (username: string, password: string): Promise<string> {
|
||||
const loginUrl = AccountUrl
|
||||
const loginUrl = this.baseUrl
|
||||
const loginPayload = {
|
||||
method: 'login',
|
||||
params: [username, password]
|
||||
@ -32,13 +34,16 @@ export class ApiEndpoint {
|
||||
Referer: PlatformURI
|
||||
}
|
||||
const response = await this.request.post(loginUrl, { data: loginPayload, headers })
|
||||
if (response.status() !== 200) {
|
||||
throw new Error(`Login failed with status: ${response.status()}`)
|
||||
}
|
||||
const token = (await response.json()).result.token
|
||||
return token
|
||||
}
|
||||
|
||||
async createWorkspaceWithLogin (workspaceName: string, username: string, password: string): Promise<any> {
|
||||
const token = await this.loginAndGetToken(username, password)
|
||||
const url = AccountUrl
|
||||
const url = this.baseUrl
|
||||
const payload = {
|
||||
method: 'createWorkspace',
|
||||
params: [workspaceName]
|
||||
@ -49,7 +54,7 @@ export class ApiEndpoint {
|
||||
}
|
||||
|
||||
async createAccount (username: string, password: string, firstName: string, lastName: string): Promise<any> {
|
||||
const url = AccountUrl
|
||||
const url = this.baseUrl
|
||||
const payload = {
|
||||
method: 'createAccount',
|
||||
params: [username, password, firstName, lastName]
|
||||
|
@ -10,7 +10,8 @@ export const PlatformUserSecond = process.env.PLATFORM_USER_SECOND as string
|
||||
export const PlatformSetting = process.env.SETTING as string
|
||||
export const PlatformSettingSecond = process.env.SETTING_SECOND as string
|
||||
export const DefaultWorkspace = 'SanityTest'
|
||||
export const AccountUrl = process.env.ACCOUNT_URL as string
|
||||
export const LocalUrl = process.env.LOCAL_URL as string
|
||||
export const DevUrl = process.env.DEV_URL as string
|
||||
|
||||
export function generateTestData (): TestData {
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user