Files
threshold-ui/e2e-tests/helpers/boundary-http/scopes.js
T
Zhihe Li 7c1814118d refactor: 💡 Move e2e tests to new folder (#2546)
* refactor: 💡 Move e2e tests to new folder

* refactor: 💡 Convert desktop tests to mjs and use es6 imports

* refactor: 💡 Use module setting for e2e directory and remove mjs

* refactor: 💡 Remove "e2e" in all scripts in package.json
2024-11-12 11:21:37 -05: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();
}