Skip to content

Commit aeecc2a

Browse files
authored
Skip redhat.fabric8-analytics extension test in DS 3.22.0 and higher; log testing extensions (#23524)
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
1 parent 94e1091 commit aeecc2a

File tree

1 file changed

+61
-14
lines changed

1 file changed

+61
-14
lines changed

tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function getSectionForCategory(title: string): string {
7878
case '@outdated':
7979
return 'Outdated';
8080
case '@recommended':
81-
return 'Other Recommendations';
81+
return 'WORKSPACE RECOMMENDATIONS';
8282
default:
8383
return 'Marketplace';
8484
}
@@ -120,6 +120,15 @@ async function findItem(extSection: ExtensionsViewSection, title: string): Promi
120120
const sections: WebElement[] = await enclosingItem.findElements((extSection as any).constructor.locators.ViewContent.section);
121121
Logger.debug(`Found ${sections.length} sections`);
122122

123+
// debug: Log all available section titles
124+
const availableSections: string[] = [];
125+
for (const sec of sections) {
126+
const titleElement: WebElement = await sec.findElement((extSection as any).constructor.locators.ViewSection.title);
127+
const sectionTitleText: string = await titleElement.getText();
128+
availableSections.push(sectionTitleText);
129+
}
130+
Logger.debug(`Available sections: ${availableSections.join(', ')}`);
131+
123132
let targetSection: WebElement | undefined;
124133
for (const sec of sections) {
125134
const titleElement: WebElement = await sec.findElement((extSection as any).constructor.locators.ViewSection.title);
@@ -132,7 +141,7 @@ async function findItem(extSection: ExtensionsViewSection, title: string): Promi
132141
}
133142

134143
if (!targetSection) {
135-
Logger.debug(`Section "${sectionTitle}" not found`);
144+
Logger.debug(`Section "${sectionTitle}" not found. Available sections: ${availableSections.join(', ')}`);
136145
return undefined;
137146
}
138147

@@ -180,15 +189,36 @@ async function getVisibleFilteredItemsAndCompareWithRecommended(recommendations:
180189
}
181190
}
182191
Logger.debug('marketplaceSection.getVisibleItems()');
183-
const allFoundRecommendedItems: ExtensionsViewItem[] = await marketplaceSection.getVisibleItems();
184192

185-
const allFoundRecommendedAuthors: string[] = await Promise.all(
186-
allFoundRecommendedItems.map(async (item: ExtensionsViewItem): Promise<string> => await item.getAuthor())
187-
);
193+
// debug: Log all found recommended items
194+
try {
195+
const allFoundRecommendedItems: ExtensionsViewItem[] = await marketplaceSection.getVisibleItems();
196+
const itemTitles: string[] = await Promise.all(
197+
allFoundRecommendedItems.map(async (item: ExtensionsViewItem): Promise<string> => await item.getTitle())
198+
);
188199

189-
const allFoundAuthorsAsSortedString: string = allFoundRecommendedAuthors.sort().toString();
190-
const allPublisherNamesAsSortedString: string = recommendations.sort().toString();
191-
return allFoundAuthorsAsSortedString === allPublisherNamesAsSortedString;
200+
const allFoundRecommendedAuthors: string[] = await Promise.all(
201+
allFoundRecommendedItems.map(async (item: ExtensionsViewItem): Promise<string> => await item.getAuthor())
202+
);
203+
204+
Logger.debug(`Found ${allFoundRecommendedItems.length} recommended items: ${itemTitles.join(', ')}`);
205+
Logger.debug(`Found authors: ${allFoundRecommendedAuthors.join(', ')}`);
206+
Logger.debug(`Expected authors: ${recommendations.join(', ')}`);
207+
208+
const allFoundAuthorsAsSortedString: string = allFoundRecommendedAuthors.sort().toString();
209+
const allPublisherNamesAsSortedString: string = recommendations.sort().toString();
210+
211+
Logger.debug(`Sorted found authors: ${allFoundAuthorsAsSortedString}`);
212+
Logger.debug(`Sorted expected authors: ${allPublisherNamesAsSortedString}`);
213+
214+
const result: boolean = allFoundAuthorsAsSortedString === allPublisherNamesAsSortedString;
215+
Logger.debug(`Authors match: ${result}`);
216+
217+
return result;
218+
} catch (error) {
219+
Logger.error(`Error getting item titles: ${error}`);
220+
return false;
221+
}
192222
}
193223

194224
// get visible items from Extension view, transform this from array to sorted string and compares it with existed installed extensions
@@ -223,6 +253,7 @@ for (const sample of samples) {
223253
let extensionSection: ExtensionsViewSection;
224254
let extensionsView: SideBarView | undefined;
225255
let publisherNames: string[];
256+
let skipSuite: boolean = false;
226257

227258
const [pathToExtensionsListFileName, extensionsListFileName]: string[] = ['.vscode', 'extensions.json'];
228259

@@ -237,6 +268,12 @@ for (const sample of samples) {
237268
await loginTests.loginIntoChe();
238269
});
239270

271+
setup('Skip follow-up tests if flagged', function (): void {
272+
if (skipSuite) {
273+
this.skip();
274+
}
275+
});
276+
240277
test(`Create and open new workspace, stack:${sample}`, async function (): Promise<void> {
241278
await workspaceHandlingTests.createAndOpenWorkspace(sample);
242279
});
@@ -298,19 +335,21 @@ for (const sample of samples) {
298335

299336
Logger.debug('recommendedExtensions.recommendations: Get recommendations clear names using map().');
300337

301-
// skip the test if only redhat.fabric8-analytics extension is found in Dev Spaces 3.22.x (issue CRW-9186)
338+
// skip redhat.fabric8-analytics extension in Dev Spaces 3.22+ (issue CRW-9186)
302339
if (
303340
BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME() === 'devspaces' &&
304-
BASE_TEST_CONSTANTS.TESTING_APPLICATION_VERSION.startsWith('3.22')
341+
BASE_TEST_CONSTANTS.TESTING_APPLICATION_VERSION >= '3.22'
305342
) {
306343
const dependencyAnalyticsExtensionName: string = 'redhat.fabric8-analytics';
307344
if (
308345
recommendedExtensions.recommendations.includes(dependencyAnalyticsExtensionName) &&
309346
recommendedExtensions.recommendations.length === 1
310347
) {
311-
throw new Error(
348+
Logger.info(
312349
`Only '${dependencyAnalyticsExtensionName}' extension found. This extension will not be installed because of known issue https://issues.redhat.com/browse/CRW-9186`
313350
);
351+
skipSuite = true;
352+
this.skip();
314353
} else {
315354
recommendedExtensions.recommendations = recommendedExtensions.recommendations.filter(
316355
(rec: string): boolean => !rec.includes(dependencyAnalyticsExtensionName)
@@ -389,8 +428,16 @@ for (const sample of samples) {
389428
}
390429

391430
Logger.debug('extensionSection.findItem by @recommended filter');
392-
expect(await getVisibleFilteredItemsAndCompareWithRecommended(publisherNames)).to.be.true;
393-
Logger.debug(`All recommended extensions were found by @recommended filter: ---- ${publisherNames} ----`);
431+
try {
432+
Logger.debug(`Expected publisher names: ${publisherNames.join(', ')}`);
433+
const comparisonResult: boolean = await getVisibleFilteredItemsAndCompareWithRecommended(publisherNames);
434+
Logger.debug(`Comparison result: ${comparisonResult}`);
435+
expect(comparisonResult).to.be.true;
436+
Logger.debug(`All recommended extensions were found by @recommended filter: ---- ${publisherNames} ----`);
437+
} catch (error) {
438+
Logger.error(`Error in getVisibleFilteredItemsAndCompareWithRecommended: ${error}`);
439+
throw error;
440+
}
394441

395442
Logger.debug('extensionSection.findItem by @installed filter');
396443
try {

0 commit comments

Comments
 (0)