diff --git a/_playwright-tests/tests/API/PopularRepos.spec.ts b/_playwright-tests/tests/API/PopularRepos.spec.ts index d476bd506..78cea24d3 100644 --- a/_playwright-tests/tests/API/PopularRepos.spec.ts +++ b/_playwright-tests/tests/API/PopularRepos.spec.ts @@ -2,7 +2,7 @@ import { expect } from '@playwright/test'; import { test } from './base_client'; import { PopularRepositoriesApi } from './client'; -test.describe('Populat repositories', () => { +test.describe('Popular repositories', () => { test('List popular repositories', async ({ client }) => { const resp = await new PopularRepositoriesApi(client).listPopularRepositories({ search: 'EPEL 9', diff --git a/_playwright-tests/tests/API/Repositories.spec.ts b/_playwright-tests/tests/API/Repositories.spec.ts index ac553cab3..6d8ea3ecc 100644 --- a/_playwright-tests/tests/API/Repositories.spec.ts +++ b/_playwright-tests/tests/API/Repositories.spec.ts @@ -6,10 +6,15 @@ import { ApiRepositoryValidationResponseFromJSON, type ListRepositoriesRequest, type ValidateRepositoryParametersRequest, + RpmsApi, + ApiSearchRpmResponse, + CreateRepositoryRequest, + ApiPopularRepositoriesCollectionResponse, + PopularRepositoriesApi, } from './client'; -import { expect } from '@playwright/test'; -import { poll } from './helpers/apiHelpers'; import { randomUUID } from 'crypto'; +import { expect } from '@playwright/test'; +import { poll, SmallRedHatRepoURL } from './helpers/apiHelpers'; test.describe('Repositories', () => { test('Verify repository introspection', async ({ client }) => { @@ -207,4 +212,64 @@ test.describe('Repositories', () => { expect(json.url?.httpCode).toEqual(0); }); }); + + test('Verify RPM search', async ({ client }) => { + let rpmSearch: ApiSearchRpmResponse[]; + await test.step('Search small red hat repo', async () => { + rpmSearch = await new RpmsApi(client).searchRpm({ + apiContentUnitSearchRequest: { + search: 'gcc-plugin-devel', + urls: [SmallRedHatRepoURL], + }, + }); + const names = rpmSearch.map((v) => v.packageName); + expect(names).toContain('gcc-plugin-devel'); + }); + }); + + test('Add popular repository', async ({ client }) => { + let popularRepos: ApiPopularRepositoriesCollectionResponse; + await test.step('List popular repositories', async () => { + popularRepos = await new PopularRepositoriesApi(client).listPopularRepositories({ + search: 'EPEL 9', + }); + expect(popularRepos.meta?.count).toBe(1); + expect(popularRepos.data?.[0].suggestedName).toBe('EPEL 9 Everything x86_64'); + }); + + await test.step('Delete existing repository if exists', async () => { + if (popularRepos?.data?.length && popularRepos?.data?.[0].uuid != '') { + const resp = await new RepositoriesApi(client).deleteRepositoryRaw({ + uuid: popularRepos.data[0].uuid?.toString(), + }); + expect(resp.raw.status).toBe(204); + } + }); + + await test.step('Create custom repository for popular repository', async () => { + const repo = await new RepositoriesApi(client).createRepository({ + apiRepositoryRequest: { + name: popularRepos.data?.[0].suggestedName, + url: popularRepos.data?.[0].url, + gpgKey: popularRepos.data?.[0].gpgKey, + }, + }); + expect(repo.name).toBe(popularRepos.data?.[0].suggestedName); + }); + + await test.step('Get repo uuid', async () => { + popularRepos = await new PopularRepositoriesApi(client).listPopularRepositories({ + search: 'EPEL 9', + }); + expect(popularRepos.meta?.count).toBe(1); + expect(popularRepos.data?.[0].suggestedName).toBe('EPEL 9 Everything x86_64'); + }); + + await test.step('Delete repository', async () => { + const resp = await new RepositoriesApi(client).deleteRepositoryRaw({ + uuid: popularRepos.data?.[0].uuid?.toString(), + }); + expect(resp.raw.status).toBe(204); + }); + }); }); diff --git a/_playwright-tests/tests/API/helpers/apiHelpers.tsx b/_playwright-tests/tests/API/helpers/apiHelpers.tsx index 8d480469f..e74346b04 100644 --- a/_playwright-tests/tests/API/helpers/apiHelpers.tsx +++ b/_playwright-tests/tests/API/helpers/apiHelpers.tsx @@ -17,3 +17,6 @@ export const poll = async ( // timer in ms, must await e.g. await timer(num) export const timer = (ms: number) => new Promise((res) => setTimeout(res, ms)); + +export const SmallRedHatRepoURL = + 'https://cdn.redhat.com/content/dist/rhel9/9/aarch64/codeready-builder/os/';