@@ -9,6 +9,8 @@ import { TestItem } from '../../src/playwright/testItem';
99import { createBasicFixture } from '../../src/utils/test/fixtures' ;
1010import { Environment } from '../../src/rhtap/core/integration/cd/argocd' ;
1111import { GithubProvider } from '../../src/rhtap/core/integration/git/providers/github' ;
12+ import { GitlabProvider } from '../../src/rhtap/core/integration/git/providers/gitlab' ;
13+ import { BitbucketProvider } from '../../src/rhtap/core/integration/git/providers/bitbucket' ;
1214import { expect } from '@playwright/test' ;
1315import { Git } from '../../src/rhtap/core/integration/git' ;
1416
@@ -33,7 +35,7 @@ test.describe.serial('Import Template Tests', () => {
3335 let git : Git ;
3436 const templateName = 'go' ; // You can change this to test different templates
3537
36- test ( `verifies if ${ templateName } template exists in the catalog` , async ( { testItem } ) => {
38+ test ( `verifies if ${ templateName } template exists in the catalog` , async ( ) => {
3739 // This would require implementing a method to get golden path templates
3840 // For now, we'll assume the template exists if we can create a component
3941 expect ( templateName ) . toBeDefined ( ) ;
@@ -83,40 +85,66 @@ test.describe.serial('Import Template Tests', () => {
8385 console . log ( `ArgoCD application for ${ component . getName ( ) } is synced and healthy` ) ;
8486 } ) ;
8587
86- test ( `verifies if component ${ templateName } was created in GitHub and contains 'catalog-info.yaml' file` , async ( ) => {
88+ test ( `verifies if component ${ templateName } was created in Git provider and contains 'catalog-info.yaml' file` , async ( ) => {
8789 if ( ! component ) {
8890 throw new Error ( 'Component was not created successfully' ) ;
8991 }
9092
91- const git = component . getGit ( ) as GithubProvider ;
93+ const git = component . getGit ( ) ;
9294 const componentName = component . getName ( ) ;
95+ const gitType = git . getGitType ( ) ;
9396
94- // Check if repository exists in GitHub
95- const repositoryExists = await git . checkIfRepositoryExists ( git . getOrganization ( ) , componentName ) ;
97+ // Get the appropriate owner based on Git provider type
98+ let owner : string ;
99+ if ( git instanceof GithubProvider ) {
100+ owner = git . getOrganization ( ) ;
101+ } else if ( git instanceof GitlabProvider ) {
102+ owner = git . getGroup ( ) ;
103+ } else if ( git instanceof BitbucketProvider ) {
104+ owner = git . getWorkspace ( ) ;
105+ } else {
106+ throw new Error ( `Unsupported Git provider type: ${ gitType } ` ) ;
107+ }
108+
109+ // Check if repository exists
110+ const repositoryExists = await git . checkIfRepositoryExists ( owner , componentName ) ;
96111 expect ( repositoryExists ) . toBe ( true ) ;
97112
98113 // Check if catalog-info.yaml exists
99- const catalogFileExists = await git . checkIfFileExistsInRepository ( git . getOrganization ( ) , componentName , 'catalog-info.yaml' ) ;
114+ const catalogFileExists = await git . checkIfFileExistsInRepository ( owner , componentName , 'catalog-info.yaml' ) ;
100115 expect ( catalogFileExists ) . toBe ( true ) ;
101116
102- console . log ( `Repository ${ componentName } and catalog-info.yaml verified in GitHub ` ) ;
117+ console . log ( `Repository ${ componentName } and catalog-info.yaml verified in ${ gitType } ` ) ;
103118 } ) ;
104119
105120 test ( `deletes catalog file and tekton folder` , async ( ) => {
106121 if ( ! component ) {
107122 throw new Error ( 'Component was not created successfully' ) ;
108123 }
109124
110- const git = component . getGit ( ) as GithubProvider ;
125+ const git = component . getGit ( ) ;
111126 const componentName = component . getName ( ) ;
127+ const gitType = git . getGitType ( ) ;
128+
129+ // Get the appropriate owner based on Git provider type
130+ let owner : string ;
131+ if ( git instanceof GithubProvider ) {
132+ owner = git . getOrganization ( ) ;
133+ } else if ( git instanceof GitlabProvider ) {
134+ owner = git . getGroup ( ) ;
135+ } else if ( git instanceof BitbucketProvider ) {
136+ owner = git . getWorkspace ( ) ;
137+ } else {
138+ throw new Error ( `Unsupported Git provider type: ${ gitType } ` ) ;
139+ }
112140
113141 // Delete .tekton folder
114- await git . deleteFolderInRepository ( git . getOrganization ( ) , componentName , '.tekton' ) ;
142+ await git . deleteFolderInRepository ( owner , componentName , '.tekton' ) ;
115143
116144 // Delete catalog-info.yaml file
117- await git . deleteFileInRepository ( git . getOrganization ( ) , componentName , 'catalog-info.yaml' ) ;
145+ await git . deleteFileInRepository ( owner , componentName , 'catalog-info.yaml' ) ;
118146
119- console . log ( `Deleted .tekton, gitops folders and catalog-info.yaml from ${ componentName } ` ) ;
147+ console . log ( `Deleted .tekton, gitops folders and catalog-info.yaml from ${ componentName } in ${ gitType } ` ) ;
120148 } ) ;
121149
122150 test ( `deletes location from backstage` , async ( ) => {
@@ -191,22 +219,35 @@ test.describe.serial('Import Template Tests', () => {
191219 console . log ( `ArgoCD application for imported ${ importedComponent . getName ( ) } is synced and healthy` ) ;
192220 } ) ;
193221
194- test ( `verifies if imported component ${ templateName } was created in GitHub and contains 'catalog-info.yaml' file` , async ( ) => {
222+ test ( `verifies if imported component ${ templateName } was created in Git provider and contains 'catalog-info.yaml' file` , async ( ) => {
195223 if ( ! importedComponent ) {
196224 throw new Error ( 'Imported component was not created successfully' ) ;
197225 }
198226
199- const git = importedComponent . getGit ( ) as GithubProvider ;
227+ const git = importedComponent . getGit ( ) ;
200228 const importedComponentName = importedComponent . getName ( ) ;
229+ const gitType = git . getGitType ( ) ;
230+
231+ // Get the appropriate owner based on Git provider type
232+ let owner : string ;
233+ if ( git instanceof GithubProvider ) {
234+ owner = git . getOrganization ( ) ;
235+ } else if ( git instanceof GitlabProvider ) {
236+ owner = git . getGroup ( ) ;
237+ } else if ( git instanceof BitbucketProvider ) {
238+ owner = git . getWorkspace ( ) ;
239+ } else {
240+ throw new Error ( `Unsupported Git provider type: ${ gitType } ` ) ;
241+ }
201242
202- // Check if imported repository exists in GitHub
203- const repositoryExists = await git . checkIfRepositoryExists ( git . getOrganization ( ) , importedComponentName ) ;
243+ // Check if imported repository exists
244+ const repositoryExists = await git . checkIfRepositoryExists ( owner , importedComponentName ) ;
204245 expect ( repositoryExists ) . toBe ( true ) ;
205246
206247 // Check if catalog-info.yaml exists in imported repository
207- const catalogFileExists = await git . checkIfFileExistsInRepository ( git . getOrganization ( ) , importedComponentName , 'catalog-info.yaml' ) ;
248+ const catalogFileExists = await git . checkIfFileExistsInRepository ( owner , importedComponentName , 'catalog-info.yaml' ) ;
208249 expect ( catalogFileExists ) . toBe ( true ) ;
209250
210- console . log ( `Imported repository ${ importedComponentName } and catalog-info.yaml verified in GitHub ` ) ;
251+ console . log ( `Imported repository ${ importedComponentName } and catalog-info.yaml verified in ${ gitType } ` ) ;
211252 } ) ;
212253} ) ;
0 commit comments