Skip to content

Commit 112d36b

Browse files
authored
fix(e2e-helper): Ensure repo is created before file creation (#71)
* Ensure repo is created before file creation Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> * Poll repository creation Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> * Add getOrg gh endpoint Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> * Update version Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> * Update intervals Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> --------- Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
1 parent 376269d commit 112d36b

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

docs/changelog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [1.1.27] - Current
5+
## [1.1.28] - Current
6+
7+
- **APIHelper.createGitHubRepoWithFile**: Ensure file creation happens after repository creation.
8+
9+
### Added
10+
11+
- **`GITHUB_API_ENDPOINTS.getOrg(owner)`**: Get GitHub organization
12+
- **`GITHUB_API_ENDPOINTS.getRepo(owner, repo)`**: Get GitHub repository
13+
14+
## [1.1.27]
615

716
### Fixed
817

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/e2e-test-utils",
3-
"version": "1.1.27",
3+
"version": "1.1.28",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

src/playwright/helpers/api-endpoints.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ export const GITHUB_API_ENDPOINTS = {
1616

1717
workflowRuns: `${backstageShowcaseAPI}/actions/runs?per_page=${perPage}`,
1818

19+
getOrg: getOrgUrl,
20+
21+
createRepo: (owner: string) => `${getOrgUrl(owner)}/repos`,
22+
23+
getRepo: getRepoUrl,
24+
1925
deleteRepo: getRepoUrl,
2026

2127
mergePR: (owner: string, repoName: string, pullNumber: number) =>
2228
`${getRepoUrl(owner, repoName)}/pulls/${pullNumber}/merge`,
2329

24-
createRepo: (owner: string) => `${getOrgUrl(owner)}/repos`,
25-
2630
pullFiles: (owner: string, repoName: string, pr: number) =>
2731
`${getRepoUrl(owner, repoName)}/pulls/${pr}/files`,
2832

src/playwright/helpers/api-helper.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ export class APIHelper {
8080
// Create the repository
8181
await APIHelper.createGitHubRepo(owner, repoName);
8282

83+
// Wait until repository is created
84+
await expect
85+
.poll(
86+
async () => {
87+
const res = await APIHelper.githubRequest(
88+
"GET",
89+
GITHUB_API_ENDPOINTS.getRepo(owner, repoName),
90+
);
91+
return res.status();
92+
},
93+
{
94+
timeout: 30_000,
95+
intervals: [5000],
96+
},
97+
)
98+
.toBe(200);
99+
83100
// Add the specified file
84101
await APIHelper.createFileInRepo(
85102
owner,

0 commit comments

Comments
 (0)