use node's native fetch, add ensureLicense flag and update snapshots (#28279)

Этот коммит содержится в:
Saturnino Abril
2024-09-23 21:11:45 +08:00
коммит произвёл GitHub
родитель 343746c4b6
Коммит 073e2cecaa
23 изменённых файлов: 109 добавлений и 309 удалений

Просмотреть файл

@@ -35,6 +35,41 @@ export async function shouldRunInLinux() {
await expect(platform, 'Run in Linux or Playwright docker image only').toBe('linux');
}
export async function ensureLicense() {
const {adminClient} = await getAdminClient();
let license = await adminClient.getClientLicenseOld();
if (license?.IsLicensed !== 'true') {
const config = await adminClient.getClientConfigOld();
await expect(
config.ServiceEnvironment === 'dev',
'The trial license request fails in the local development environment. Please manually upload the test license.',
).toBeFalsy();
await requestTrialLicense();
license = await adminClient.getClientLicenseOld();
}
await expect(license?.IsLicensed === 'true', 'Ensure server has license').toBeTruthy();
}
export async function requestTrialLicense() {
const {adminClient} = await getAdminClient();
try {
// @ts-expect-error This may fail requesting for trial license
await adminClient.requestTrialLicense({
receive_emails_accepted: true,
terms_accepted: true,
users: 100,
});
} catch (error) {
// eslint-disable-next-line no-console
expect(error, 'Failed to request trial license').toBeFalsy();
throw error;
}
}
export async function skipIfNoLicense() {
const {adminClient} = await getAdminClient();
const license = await adminClient.getClientLicenseOld();