async function fetchDefaultDevice()

in integration_test/functions/src/testLab-utils.ts [30:59]


async function fetchDefaultDevice(
  accessToken: admin.GoogleOAuthAccessToken
): Promise<AndroidDevice> {
  const response = await utils.makeRequest(
    requestOptions(accessToken, 'GET', '/v1/testEnvironmentCatalog/ANDROID')
  );
  const data = JSON.parse(response);
  const models = data?.androidDeviceCatalog?.models || [];
  const defaultModels = models.filter(
    (m) =>
      m.tags !== undefined &&
      m.tags.indexOf('default') > -1 &&
      m.supportedVersionIds !== undefined &&
      m.supportedVersionIds.length > 0
  );

  if (defaultModels.length === 0) {
    throw new Error('No default device found');
  }

  const model = defaultModels[0];
  const versions = model.supportedVersionIds;

  return {
    androidModelId: model.id,
    androidVersionId: versions[versions.length - 1],
    locale: 'en',
    orientation: 'portrait',
  } as AndroidDevice;
}