@comeonautomation/reportportal-client
Advanced tools
Comparing version
@@ -325,27 +325,31 @@ /* eslint-disable quotes,no-console,class-methods-use-this */ | ||
async deleteSkippedInterruptedTest() { | ||
const launchIds = helpers.readLaunchesFromFile(); | ||
const launchIds = helpers.readLaunchesFromFile(); // Retrieve the list of launch IDs | ||
const hasSkipTestItems = []; | ||
for (let item in launchIds) { | ||
for (const launchId of launchIds) { | ||
try { | ||
// Retrieve items for the current launchId | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchIds[item]}&page.size=100`); | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchId}&page.size=100`); | ||
if (response.status !== 200) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to HTTP ${response.status}.`); | ||
if (response.status === 404) { | ||
this.logDebug(`Skipping launchId ${launchId} due to HTTP 404.`); | ||
continue; | ||
} | ||
this.logDebug(`Total elements in ${launchIds[item]}: ` + response.page.totalElements); | ||
this.logDebug(`Total elements in ${launchId}: ${response.page.totalElements}`); | ||
for (let i = 0; i < response.page.totalElements; i++) { | ||
this.logDebug(`Test ID: ${response.content[i].id} ${response.content[i].name} Skipped: ${response.content[i].statistics.executions.skipped}`); | ||
const item_id_url = `/item/uuid/${response.content[i].id}`; | ||
const testItem = response.content[i]; | ||
const item_id_url = `/item/uuid/${testItem.id}`; | ||
this.logDebug( | ||
`Test ID: ${testItem.id}, Name: ${testItem.name}, Skipped: ${testItem.statistics.executions.skipped}` | ||
); | ||
// Check if the test meets criteria for deletion | ||
if ( | ||
(response.content[i].statistics.executions.skipped === 1 && !response.content[i].hasChildren) || | ||
(response.content[i].statistics.executions.total === response.content[i].statistics.executions.skipped) || | ||
(response.content[i].status === 'INTERRUPTED' && !response.content[i].hasChildren) | ||
(testItem.statistics.executions.skipped === 1 && !testItem.hasChildren) || | ||
(testItem.statistics.executions.total === testItem.statistics.executions.skipped) || | ||
(testItem.status === 'INTERRUPTED' && !testItem.hasChildren) | ||
) { | ||
@@ -357,5 +361,5 @@ try { | ||
await this.restClient.delete(`/item?ids=${itemDetails.id}`); | ||
this.logDebug('Deleted Skipped & Interrupted tests successfully'); | ||
this.logDebug(`Deleted Skipped & Interrupted test: ${itemDetails.id}`); | ||
} catch (innerError) { | ||
this.logDebug(`Failed to retrieve or delete item ${response.content[i].id}. Error: ${innerError.message}`); | ||
this.logDebug(`Failed to retrieve or delete item ${testItem.id}. Error: ${innerError.message}`); | ||
} | ||
@@ -365,4 +369,4 @@ } | ||
} catch (error) { | ||
// Log error and continue to next item | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to error: ${error.message}`); | ||
// Log error and continue to the next launchId | ||
this.logDebug(`Skipping launchId ${launchId} due to error: ${error.message}`); | ||
continue; | ||
@@ -375,2 +379,3 @@ } | ||
isLaunchWithFailedTests(launchTempId) { | ||
@@ -403,11 +408,11 @@ const launchObj = this.map[launchTempId]; | ||
async deleteEmptyExecutionTest() { | ||
const launchIds = helpers.readLaunchesFromFile(); | ||
const launchIds = helpers.readLaunchesFromFile(); // Retrieve the list of launch IDs | ||
for (let item in launchIds) { | ||
for (const launchId of launchIds) { | ||
try { | ||
// Retrieve items for the current launchId | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchIds[item]}&page.size=100`); | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchId}&page.size=100`); | ||
if (response.status !== 200) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to HTTP ${response.status}.`); | ||
if (response.status === 404) { | ||
this.logDebug(`Skipping launchId ${launchId} due to HTTP 404.`); | ||
continue; | ||
@@ -420,4 +425,6 @@ } | ||
try { | ||
// Retrieve item details | ||
const itemDetails = await this.restClient.retrieve(item_id_url); | ||
// Check if the test has empty executions | ||
if (Object.values(itemDetails.statistics.executions).length === 0) { | ||
@@ -428,8 +435,7 @@ await this.restClient.delete(`/item?ids=${itemDetails.id}`); | ||
} catch (innerError) { | ||
this.logDebug(`Failed to retrieve or delete item ${response.content[i].id}. Error: ${innerError.message}`); | ||
this.logDebug(`Failed to process item ${response.content[i].id}. Error: ${innerError.message}`); | ||
} | ||
} | ||
} catch (error) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to error: ${error.message}`); | ||
continue; | ||
this.logDebug(`Error processing launchId ${launchId}: ${error.message}`); | ||
} | ||
@@ -441,26 +447,29 @@ } | ||
async deleteEmptyExecutionLaunch() { | ||
const launchIds = helpers.readLaunchesFromFile(); | ||
const launchIds = helpers.readLaunchesFromFile(); // Retrieve the list of launch IDs | ||
for (let item in launchIds) { | ||
for (const launchId of launchIds) { | ||
try { | ||
// Retrieve items for the current launchId | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchIds[item]}&page.size=100`); | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchId}&page.size=100`); | ||
if (response.status !== 200) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to HTTP ${response.status}.`); | ||
if (response.status === 404) { | ||
this.logDebug(`Skipping launchId ${launchId} due to HTTP 404.`); | ||
continue; | ||
} | ||
// Check if there are no executions for this launch | ||
if (response.page.totalElements === 0) { | ||
try { | ||
await this.restClient.delete(`/launch/${launchIds[item]}`); | ||
this.logDebug(`Deleted launch with empty executions: ${launchIds[item]}`); | ||
await this.restClient.delete(`/launch/${launchId}`); | ||
this.logDebug(`Deleted launch with empty executions: ${launchId}`); | ||
} catch (deleteError) { | ||
this.logDebug(`Failed to delete launch ${launchIds[item]}. Error: ${deleteError.message}`); | ||
this.logDebug(`Failed to delete launch ${launchId}. Error: ${deleteError.message}`); | ||
} | ||
} | ||
} catch (error) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to error: ${error.message}`); | ||
// Log error and continue to the next launchId | ||
this.logDebug(`Skipping launchId ${launchId} due to error: ${error.message}`); | ||
continue; | ||
@@ -473,38 +482,2 @@ } | ||
async deleteEmptyExecutionTest() { | ||
const launchIds = helpers.readLaunchesFromFile(); | ||
for (let item in launchIds) { | ||
try { | ||
// Retrieve items for the current launchId | ||
const response = await this.restClient.retrieve(`/item?filter.eq.launchId=${launchIds[item]}&page.size=100`); | ||
if (response.status !== 200) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to HTTP ${response.status}.`); | ||
continue; | ||
} | ||
for (let i = 0; i < response.page.totalElements; i++) { | ||
const item_id_url = `/item/uuid/${response.content[i].id}`; | ||
try { | ||
const itemDetails = await this.restClient.retrieve(item_id_url); | ||
if (Object.values(itemDetails.statistics.executions).length === 0) { | ||
await this.restClient.delete(`/item?ids=${itemDetails.id}`); | ||
this.logDebug(`Deleted test with empty executions: ${itemDetails.id}`); | ||
} | ||
} catch (innerError) { | ||
this.logDebug(`Failed to retrieve or delete item ${response.content[i].id}. Error: ${innerError.message}`); | ||
} | ||
} | ||
} catch (error) { | ||
this.logDebug(`Skipping launchId ${launchIds[item]} due to error: ${error.message}`); | ||
continue; | ||
} | ||
} | ||
this.logDebug('Completed processing all launch IDs for empty execution tests.'); | ||
} | ||
@@ -511,0 +484,0 @@ /* |
{ | ||
"name": "@comeonautomation/reportportal-client", | ||
"version": "2.3.9", | ||
"version": "2.4.0", | ||
"description": "ReportPortal client for node.js", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
155499
-0.86%1952
-1.11%