2020-06-17 00:42:35 +08:00
|
|
|
import 'cypress-file-upload';
|
|
|
|
|
2020-06-02 01:55:37 +08:00
|
|
|
interface CompareScreenshotsConfig {
|
2020-06-01 20:48:23 +08:00
|
|
|
name: string;
|
2019-12-09 16:14:25 +08:00
|
|
|
threshold?: number;
|
|
|
|
}
|
|
|
|
|
2020-06-02 01:55:37 +08:00
|
|
|
Cypress.Commands.add('compareScreenshots', (config: CompareScreenshotsConfig | string) => {
|
|
|
|
cy.task('compareScreenshots', {
|
2020-06-01 20:48:23 +08:00
|
|
|
config,
|
|
|
|
screenshotsFolder: Cypress.config('screenshotsFolder'),
|
|
|
|
specName: Cypress.spec.name,
|
2019-12-09 16:14:25 +08:00
|
|
|
});
|
|
|
|
});
|
2019-12-10 16:47:03 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('logToConsole', (message: string, optional?: any) => {
|
2021-05-04 20:23:26 +08:00
|
|
|
cy.task('log', { message: '(' + new Date().toISOString() + ') ' + message, optional });
|
2019-12-10 16:47:03 +08:00
|
|
|
});
|
2020-03-27 00:15:58 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('readProvisions', (filePaths: string[]) => {
|
|
|
|
cy.task('readProvisions', {
|
|
|
|
CWD: Cypress.env('CWD'),
|
|
|
|
filePaths,
|
|
|
|
});
|
|
|
|
});
|
2021-09-29 22:27:49 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('getJSONFilesFromDir', (dirPath: string) => {
|
|
|
|
return cy.task('getJSONFilesFromDir', {
|
2021-10-13 03:48:36 +08:00
|
|
|
// CWD is set for plugins in the cli but not for the main grafana repo: https://github.com/grafana/grafana/blob/main/packages/grafana-e2e/cli.js#L12
|
|
|
|
projectPath: Cypress.env('CWD') || Cypress.config().parentTestsFolder,
|
2021-09-29 22:27:49 +08:00
|
|
|
relativePath: dirPath,
|
|
|
|
});
|
|
|
|
});
|
2022-01-13 02:15:29 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('startBenchmarking', (testName: string) => {
|
|
|
|
return cy.task('startBenchmarking', { testName });
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add('stopBenchmarking', (testName: string, appStats: Record<string, unknown>) => {
|
|
|
|
return cy.task('stopBenchmarking', { testName, appStats });
|
|
|
|
});
|