Skip to content

Commit

Permalink
#161 Add step for clearing download directory
Browse files Browse the repository at this point in the history
Before each run with a download step, the download directory of cypress
is cleared to avoid excessive accumulation of download files
  • Loading branch information
lgorzitze committed Sep 4, 2024
1 parent e118ec4 commit 49576f2
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 5 deletions.
4 changes: 4 additions & 0 deletions integrationTests/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild";
import doguTestLibrary from "@cloudogu/dogu-integration-test-library";
// @ts-ignore
import fsConf from "cypress-fs/plugins/index.js";

async function setupNodeEvents(
on: Cypress.PluginEvents,
Expand All @@ -19,6 +21,8 @@ async function setupNodeEvents(
})
);

fsConf(on);

config = doguTestLibrary.configure(config)

// Make sure to return the config object as it might have been modified by the plugin.
Expand Down
15 changes: 15 additions & 0 deletions integrationTests/cypress/support/step_definitions/before.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Before} from "@badeball/cypress-cucumber-preprocessor";
import "cypress-fs";

Before({tags: "@clean_new_group"}, () => {
cy.withUser("testuser").then(userData => {
Expand All @@ -20,3 +21,17 @@ Before({tags: "@clean_before"}, () => {
cy.log("clean TestGroups");
cy.usermgtCleanupTestGroups();
})

Before({tags: "@clear_downloadDir"}, () => {
const downloadsFolder = Cypress.config("downloadsFolder");
cy.fsDirExists(downloadsFolder).then((exists: boolean) => {
if (exists) {
cy.fsReadDir(downloadsFolder).then((files) => {
for (const file of files) {
console.log("clear file: " + downloadsFolder + file);
cy.fsDeleteFile(`${downloadsFolder}/${file}`);
}
});
}
});
});
1 change: 1 addition & 0 deletions integrationTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"@cloudogu/dogu-integration-test-library": "^6.1.1",
"cypress": "^13.13.1",
"cypress-fs": "^0.2.5",
"esbuild": "^0.17.17",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0",
Expand Down
71 changes: 66 additions & 5 deletions integrationTests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
dependencies:
debug "4.3.4"

"@cloudogu/dogu-integration-test-library@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@cloudogu/dogu-integration-test-library/-/dogu-integration-test-library-6.0.0.tgz#bfa7f2c498921b941ae0abcec00cb2ee40f14a70"
integrity sha512-lMPncz7SbMvc2Nj00NOP5jqnsFPHkXYrxDFStlOzpGUbgcntOJBlmDyk6ZwMRHpGxw+9QZVDSNaXeKHlvn3Iug==
"@cloudogu/dogu-integration-test-library@^6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@cloudogu/dogu-integration-test-library/-/dogu-integration-test-library-6.1.1.tgz#76a3cc5b585c84fdab92669b7f2b55c87482d040"
integrity sha512-plQpFu7QbuX4Kuuvq4XVhWNUwy5rKk5KPF3DY8XSQyodWvtuPtTWEgoJ2e8TwqN6WK5c0aEcMMBLoboiTh/CJg==
dependencies:
"@badeball/cypress-cucumber-preprocessor" "^16.0.0"
cypress "^12.9.0"
Expand Down Expand Up @@ -278,7 +278,7 @@
tunnel-agent "^0.6.0"
uuid "^8.3.2"

"@cypress/request@^3.0.0":
"@cypress/request@^3.0.0", "@cypress/request@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@cypress/request/-/request-3.0.1.tgz#72d7d5425236a2413bd3d8bb66d02d9dc3168960"
integrity sha512-TWivJlJi8ZDx2wGOw1dbLuHJKUYX7bWySw377nlnGOW3hP9/MUKIsEdXT/YngWxVdgNCHRBmFlBipE+5/2ZZlQ==
Expand Down Expand Up @@ -1032,6 +1032,14 @@ [email protected]:
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==

cypress-fs@^0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/cypress-fs/-/cypress-fs-0.2.5.tgz#fb24fbf9bf87c9af4ba73ca35e227c9e3c2cbac6"
integrity sha512-nv3a4iNozkhEyTUpa8LuAKARsj7nXPbr/QyVZoMx3+u1VtEaEKyUR+e78xpF/F+WjCtKWUIJOr+gGVfJeokKtQ==
dependencies:
cypress "^13.2.0"
typescript "^5.0.4"

cypress@^12.9.0:
version "12.9.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.9.0.tgz#e6ab43cf329fd7c821ef7645517649d72ccf0a12"
Expand Down Expand Up @@ -1128,6 +1136,54 @@ cypress@^13.13.1:
untildify "^4.0.0"
yauzl "^2.10.0"

cypress@^13.2.0:
version "13.14.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.14.1.tgz#05875bbbf6333e858a92aed33ba67d7ddf8370d7"
integrity sha512-Wo+byPmjps66hACEH5udhXINEiN3qS3jWNGRzJOjrRJF3D0+YrcP2LVB1T7oYaVQM/S+eanqEvBWYc8cf7Vcbg==
dependencies:
"@cypress/request" "^3.0.1"
"@cypress/xvfb" "^1.2.4"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
arch "^2.2.0"
blob-util "^2.0.2"
bluebird "^3.7.2"
buffer "^5.7.1"
cachedir "^2.3.0"
chalk "^4.1.0"
check-more-types "^2.24.0"
cli-cursor "^3.1.0"
cli-table3 "~0.6.1"
commander "^6.2.1"
common-tags "^1.8.0"
dayjs "^1.10.4"
debug "^4.3.4"
enquirer "^2.3.6"
eventemitter2 "6.4.7"
execa "4.1.0"
executable "^4.1.1"
extract-zip "2.0.1"
figures "^3.2.0"
fs-extra "^9.1.0"
getos "^3.2.1"
is-ci "^3.0.1"
is-installed-globally "~0.4.0"
lazy-ass "^1.6.0"
listr2 "^3.8.3"
lodash "^4.17.21"
log-symbols "^4.0.0"
minimist "^1.2.8"
ospath "^1.2.2"
pretty-bytes "^5.6.0"
process "^0.11.10"
proxy-from-env "1.0.0"
request-progress "^3.0.0"
semver "^7.5.3"
supports-color "^8.1.1"
tmp "~0.2.3"
untildify "^4.0.0"
yauzl "^2.10.0"

dashdash@^1.12.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
Expand Down Expand Up @@ -2674,6 +2730,11 @@ typescript@^5.0.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.2.tgz#891e1a90c5189d8506af64b9ef929fca99ba1ee5"
integrity sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==

typescript@^5.0.4:
version "5.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==

universalify@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0"
Expand Down

0 comments on commit 49576f2

Please sign in to comment.