Skip to content

Commit c6c3681

Browse files
committed
regression for monitoring alerting
1 parent a3013ee commit c6c3681

18 files changed

Lines changed: 2004 additions & 1086 deletions

web/cypress.config.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'cypress';
2-
import * as fs from 'fs';
2+
import * as fs from 'fs-extra';
33
import * as console from 'console';
4+
import * as path from 'path';
45

56
export default defineConfig({
67
screenshotsFolder: './cypress/screenshots',
@@ -81,6 +82,40 @@ export default defineConfig({
8182
}
8283
return null;
8384
},
85+
clearDownloads(folder: string = config.downloadsFolder): null {
86+
// You must return a value or a promise from a task.
87+
// Returning null is a common practice for tasks that don't need to yield a value.
88+
console.log(`Clearing downloads folder: ${folder}`);
89+
fs.emptyDirSync(folder);
90+
return null;
91+
},
92+
/**
93+
* Checks if a file exists in the specified folder (defaults to downloads folder).
94+
* @param args Object containing fileName and optional folder.
95+
* @returns True if the file exists, false otherwise.
96+
*/
97+
doesFileExist({ fileName, folder = config.downloadsFolder }: { fileName: string; folder?: string }): boolean {
98+
const filePath = path.join(folder, fileName);
99+
const exists = fs.existsSync(filePath);
100+
console.log(`Checking if file "${fileName}" exists at "${filePath}": ${exists}`);
101+
return exists;
102+
},
103+
104+
/**
105+
* Gets a list of file names in the specified folder (defaults to downloads folder).
106+
* @param folder The folder to list files from.
107+
* @returns An array of file names.
108+
*/
109+
getFilesInFolder(folder: string = config.downloadsFolder): string[] {
110+
if (!fs.existsSync(folder)) {
111+
console.log(`Folder does not exist: ${folder}`);
112+
return [];
113+
}
114+
const files = fs.readdirSync(folder);
115+
console.log(`Files in "${folder}": ${files.join(', ')}`);
116+
return files;
117+
},
118+
84119
});
85120
on('after:spec', (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
86121
if (results && results.video) {
@@ -98,6 +133,7 @@ export default defineConfig({
98133
},
99134
supportFile: './cypress/support/index.ts',
100135
specPattern: './cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
136+
downloadsFolder: './cypress/downloads',
101137
numTestsKeptInMemory: 1,
102138
testIsolation: false,
103139
experimentalModifyObstructiveThirdPartyCode: true,

0 commit comments

Comments
 (0)