Files
threshold-ui/ui/admin/tests/e2e/helpers/boundary-http/scopes.mjs
T
Michael Li 075d8c6d8f refact(e2e): Create HTTP methods and more page objects (#2448)
* refact(e2e): Create LoginPage

* refact(e2e): Create http methods

* refact(e2e): Create more methods
2024-08-23 10:17:10 -04:00

38 lines
888 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { nanoid } from 'nanoid';
/**
* Creates a new org
* @param {import('@playwright/test').APIRequestContext} request
* @returns {Promise<Serializable>}
*/
export async function createOrgHttp(request) {
const org = await request.post(`/v1/scopes`, {
data: {
name: 'Org ' + nanoid(),
scope_id: 'global',
},
});
return await org.json();
}
/**
* Creates a new project
* @param {import('@playwright/test').APIRequestContext} request
* @param {string} scopeId ID of the scope where target will be created
* @returns {Promise<Serializable>}
*/
export async function createProjectHttp(request, scopeId) {
const project = await request.post(`/v1/scopes`, {
data: {
name: 'Project ' + nanoid(),
scope_id: scopeId,
},
});
return await project.json();
}