Skip to content

Commit 6a553f0

Browse files
Fix cleanup function
1 parent 691d7b5 commit 6a553f0

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

e2e/specs/audit/auditDashboard.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { projectList } from '../../pages/project/list.po';
55
import { dateUtil } from '../../utils/date.util';
66
import using from 'jasmine-data-provider';
77
import users from '../../data/users.json';
8+
import { logger } from '../../utils/log.util';
89

910
const editorExamples = {
1011
auditAdmin: users.auditAdmin,
@@ -25,7 +26,7 @@ const getLastSubmittedAuditsfileName = (): string => {
2526
return `Aquality_Tracking_Last_Submitted_Audits_${dateUtil.getDateFormat()}.xlsx`;
2627
};
2728

28-
describe('Audits Dashboard:', () => {
29+
fdescribe('Audits Dashboard:', () => {
2930
using(notEditorExamples, (user, description) => {
3031
describe(`${description} role:`, () => {
3132
it(`Is not available for role ${description}`, async () => {
@@ -51,14 +52,14 @@ describe('Audits Dashboard:', () => {
5152
await auditsDashboardPage.exportAllSubmittedAudits();
5253
return expect(
5354
await testData.waitUntilFileExists(testData.getSimpleDownloadsFolderPath(), getAllSubmittedAuditsfileName()))
54-
.toBe(true, 'All submitted audits should be exported to file');
55+
.toBe(true, `All submitted audits should be exported to file: ${getAllSubmittedAuditsfileName()}`);
5556
});
5657

5758
it('Can export last submitted audits', async () => {
5859
await auditsDashboardPage.exportLastSubmittedAudits();
5960
return expect(
6061
await testData.waitUntilFileExists(testData.getSimpleDownloadsFolderPath(), getLastSubmittedAuditsfileName()))
61-
.toBe(true, 'Last submitted audits should be exported to file');
62+
.toBe(true, `Last submitted audits should be exported to file: ${getLastSubmittedAuditsfileName()}`);
6263
});
6364
});
6465
});

e2e/utils/testData.util.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class TestData {
2121
* @return {string} full path
2222
*/
2323
getFullPath(pathFromDataFolder: string): string {
24-
return path.join(__dirname, '..', dataFolderName, pathFromDataFolder);
24+
const fullPath = path.join(__dirname, '..', dataFolderName, pathFromDataFolder);
25+
logger.info(`Full path from data folder: ${fullPath}`);
26+
return fullPath;
2527
}
2628

2729
/**
@@ -56,19 +58,27 @@ class TestData {
5658
*/
5759
cleanUpDownloadsData() {
5860
const downloadsPath = this.getFullPath(`/${downloadsFolderName}`);
59-
return new Promise((resolve) => {
61+
return new Promise((resolve, reject) => {
6062
logger.info('Running Downloads Clean UP!');
61-
if (fs.existsSync(downloadsPath)) {
62-
fs.readdirSync(downloadsPath).forEach(function (file, index) {
63-
const curPath = downloadsPath + '/' + file;
64-
if (fs.lstatSync(curPath).isDirectory()) {
65-
this.deleteFolderRecursive(curPath);
66-
} else {
67-
fs.unlinkSync(curPath);
68-
}
69-
});
70-
resolve();
63+
try {
64+
if (fs.existsSync(downloadsPath)) {
65+
logger.info('Downloads folder Exists');
66+
fs.readdirSync(downloadsPath).forEach(function (file, index) {
67+
logger.info(`Processing ${file}`);
68+
const curPath = path.join(downloadsPath, file);
69+
if (fs.lstatSync(curPath).isDirectory()) {
70+
logger.info(`Removing directory '${file}'`);
71+
this.deleteFolderRecursive(curPath);
72+
} else {
73+
logger.info(`Removing file '${file}'`);
74+
fs.unlinkSync(curPath);
75+
}
76+
});
77+
}
78+
} catch (error) {
79+
reject(`Was not able to clean up the downloads folder: ${error.message}`);
7180
}
81+
resolve();
7282
});
7383
}
7484

0 commit comments

Comments
 (0)