Skip to content

Commit cdbd0fc

Browse files
committed
Fixes after review
1 parent c5262fd commit cdbd0fc

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"test:all": "npm run generate-config && ENABLE_E2E_TESTS=true ENABLE_UI_TESTS=true playwright test",
1818
"test:report": "playwright show-report",
1919
"test:tssc": "npm run generate-config && ENABLE_E2E_TESTS=true ENABLE_UI_TESTS=false playwright test",
20-
"test:import": "playwright test tests/templates/import-templates.test.ts"
20+
"test:import": "npm run generate-config && ENABLE_E2E_TESTS=false ENABLE_UI_TESTS=false ENABLE_IMPORT_TESTS=true playwright test tests/templates/import_templates.test.ts"
2121
},
2222
"keywords": [
2323
"typescript",

playwright.config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const DEFAULT_TIMEOUT = 2100000; // 35 minutes
1616
// Environment variable flags to control which tests run
1717
const ENABLE_E2E_TESTS = process.env.ENABLE_E2E_TESTS !== 'false'; // Default: true
1818
const ENABLE_UI_TESTS = process.env.ENABLE_UI_TESTS === 'true'; // Default: false
19+
const ENABLE_IMPORT_TESTS = process.env.ENABLE_IMPORT_TESTS === 'true'; // Default: false
1920
const DEFAULT_WORKERS = 6;
2021

2122
let projectConfigs: ProjectConfig[] = [];
@@ -30,6 +31,7 @@ try {
3031

3132
let e2eProjects: any[] = [];
3233
let uiProjects: any[] = [];
34+
let importProjects: any[] = [];
3335
let authProjects: any[] = [];
3436

3537
// Create e2e projects if enabled
@@ -72,10 +74,22 @@ try {
7274
}));
7375
}
7476

77+
// Create import template projects if enabled
78+
if (ENABLE_IMPORT_TESTS) {
79+
importProjects = projectConfigs.map(config => ({
80+
name: `import-${config.name}`,
81+
testMatch: 'tests/templates/**/*.test.ts',
82+
use: {
83+
testItem: config.testItem,
84+
},
85+
}));
86+
}
87+
7588
allProjects = [
7689
...authProjects,
7790
...e2eProjects,
78-
...uiProjects
91+
...uiProjects,
92+
...importProjects
7993
];
8094

8195
} catch (error) {

src/api/rhdh/developerhub.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class DeveloperHub {
212212

213213
// Delete all filtered entities
214214
const results = await Promise.all(
215-
filteredEntities.map((entity: any) => this.unregisterComponentById(entity.metadata.uid))
215+
filteredEntities.map((entity: any) => this.unregisterEntityByUid(entity.metadata.uid))
216216
);
217217

218218
if (results.every(r => r === true)) {
@@ -228,24 +228,24 @@ export class DeveloperHub {
228228
}
229229
}
230230

231+
231232
/**
232-
* Unregisters a component by its ID
233-
* @param id The component ID to delete
233+
* Unregisters an entity by its UID
234+
* @param id The entity UID to delete
234235
* @returns Promise<boolean> - true if deletion was successful, false otherwise
235236
*/
236-
private async unregisterComponentById(id: string): Promise<boolean> {
237+
private async unregisterEntityByUid(id: string): Promise<boolean> {
237238
try {
238239
const response = await this.axios.delete(`${this.url}/api/catalog/entities/by-uid/${id}`);
239-
240-
if (response.status === 204) {
241-
console.log(`Component ID: ${id} deleted successfully`);
240+
if (response.status >= 200 && response.status < 300) {
241+
console.log(`Entity UID: ${id} deleted successfully (status ${response.status})`);
242242
return true;
243243
} else {
244-
console.log(`Failed to delete component: ${response.status} ${response.statusText}`);
244+
console.log(`Failed to delete entity UID ${id}: ${response.status} ${response.statusText}`);
245245
return false;
246246
}
247247
} catch (error) {
248-
console.error(`Error deleting component with ID ${id}:`, error);
248+
console.error(`Error deleting entity with UID ${id}:`, error);
249249
return false;
250250
}
251251
}

src/rhtap/core/integration/git/providers/github.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,6 @@ export class GithubProvider extends BaseGitProvider {
767767
try {
768768
// Get the contents of the folder
769769
const folderContents = await this.githubClient.repository.getContent(owner, repoName, folderPath, branch);
770-
771770
if (!Array.isArray(folderContents)) {
772771
throw new Error(`Path ${folderPath} is not a folder`);
773772
}

tests/templates/import-templates.test.ts renamed to tests/templates/import_templates.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,16 @@ test.describe.serial('Import Template Tests', () => {
106106
if (!component) {
107107
throw new Error('Component was not created successfully');
108108
}
109-
109+
110110
const git = component.getGit() as GithubProvider;
111111
const componentName = component.getName();
112-
112+
113113
// Delete .tekton folder
114114
await git.deleteFolderInRepository(git.getOrganization(), componentName, '.tekton');
115-
116-
// Delete gitops folder
117-
//await git.deleteFolderInRepository(git.getOrganization(), componentName, 'gitops');
118-
115+
119116
// Delete catalog-info.yaml file
120117
await git.deleteFileInRepository(git.getOrganization(), componentName, 'catalog-info.yaml');
121-
118+
122119
console.log(`Deleted .tekton, gitops folders and catalog-info.yaml from ${componentName}`);
123120
});
124121

@@ -131,7 +128,8 @@ test.describe.serial('Import Template Tests', () => {
131128
const componentName = component.getName();
132129

133130
// Delete entities from Developer Hub
134-
await developerHub.deleteEntitiesBySelector(componentName);
131+
const deleted = await developerHub.deleteEntitiesBySelector(componentName);
132+
expect(deleted).toBeTruthy();
135133
console.log(`Deleted entities for ${componentName} from Developer Hub`);
136134
});
137135

@@ -183,9 +181,9 @@ test.describe.serial('Import Template Tests', () => {
183181
}
184182

185183
// Wait for ArgoCD application to be healthy
186-
git = component.getGit();
184+
git = importedComponent.getGit();
187185
const commitSha = await git.getGitOpsRepoCommitSha();
188-
const cd = component.getCD();
186+
const cd = importedComponent.getCD();
189187

190188
// Wait for ArgoCD application to be healthy
191189
const result = await cd.waitUntilApplicationIsSynced(Environment.DEVELOPMENT, commitSha);

0 commit comments

Comments
 (0)