diff --git a/docs/changelog.md b/docs/changelog.md index f1950f6..a20702d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,7 +2,16 @@ All notable changes to this project will be documented in this file. -## [1.1.27] - Current +## [1.1.28] - Current + +- **APIHelper.createGitHubRepoWithFile**: Ensure file creation happens after repository creation. + +### Added + +- **`GITHUB_API_ENDPOINTS.getOrg(owner)`**: Get GitHub organization +- **`GITHUB_API_ENDPOINTS.getRepo(owner, repo)`**: Get GitHub repository + +## [1.1.27] ### Fixed diff --git a/package.json b/package.json index b278af1..7e0ad02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@red-hat-developer-hub/e2e-test-utils", - "version": "1.1.27", + "version": "1.1.28", "description": "Test utilities for RHDH E2E tests", "license": "Apache-2.0", "repository": { diff --git a/src/playwright/helpers/api-endpoints.ts b/src/playwright/helpers/api-endpoints.ts index 15c4e65..aa8e5ac 100644 --- a/src/playwright/helpers/api-endpoints.ts +++ b/src/playwright/helpers/api-endpoints.ts @@ -16,13 +16,17 @@ export const GITHUB_API_ENDPOINTS = { workflowRuns: `${backstageShowcaseAPI}/actions/runs?per_page=${perPage}`, + getOrg: getOrgUrl, + + createRepo: (owner: string) => `${getOrgUrl(owner)}/repos`, + + getRepo: getRepoUrl, + deleteRepo: getRepoUrl, mergePR: (owner: string, repoName: string, pullNumber: number) => `${getRepoUrl(owner, repoName)}/pulls/${pullNumber}/merge`, - createRepo: (owner: string) => `${getOrgUrl(owner)}/repos`, - pullFiles: (owner: string, repoName: string, pr: number) => `${getRepoUrl(owner, repoName)}/pulls/${pr}/files`, diff --git a/src/playwright/helpers/api-helper.ts b/src/playwright/helpers/api-helper.ts index 66dba80..9495378 100644 --- a/src/playwright/helpers/api-helper.ts +++ b/src/playwright/helpers/api-helper.ts @@ -80,6 +80,23 @@ export class APIHelper { // Create the repository await APIHelper.createGitHubRepo(owner, repoName); + // Wait until repository is created + await expect + .poll( + async () => { + const res = await APIHelper.githubRequest( + "GET", + GITHUB_API_ENDPOINTS.getRepo(owner, repoName), + ); + return res.status(); + }, + { + timeout: 30_000, + intervals: [5000], + }, + ) + .toBe(200); + // Add the specified file await APIHelper.createFileInRepo( owner,