mirror of
https://github.com/grafana/grafana.git
synced 2025-09-25 10:24:02 +08:00
@grafana/e2e: screenshots and panel flow (#25203)
* Cleanup * addPanel now supports (optional) custom dashboardUid * addPanel now supports (optional) visualization name * Added CLI option for updating screenshot fixtures * Added support for console.* functions within tests * Refactored screenshot command for greater simplicity * addPanel now sets a unique title * Updated lockfile
This commit is contained in:
@ -3,12 +3,18 @@ const program = require('commander');
|
||||
const resolveBin = require('resolve-as-bin');
|
||||
const { resolve, sep } = require('path');
|
||||
|
||||
const cypress = commandName => {
|
||||
const cypress = (commandName, { updateScreenshots }) => {
|
||||
// Support running an unpublished dev build
|
||||
const dirname = __dirname.split(sep).pop();
|
||||
const projectPath = resolve(`${__dirname}${dirname === 'dist' ? '/..' : ''}`);
|
||||
|
||||
const cypressOptions = [commandName, '--env', `CWD=${process.cwd()}`, `--project=${projectPath}`];
|
||||
// For plugins/extendConfig
|
||||
const CWD = `CWD=${process.cwd()}`;
|
||||
|
||||
// For plugins/compareSnapshots
|
||||
const UPDATE_SCREENSHOTS = `UPDATE_SCREENSHOTS=${updateScreenshots ? 1 : 0}`;
|
||||
|
||||
const cypressOptions = [commandName, '--env', `${CWD},${UPDATE_SCREENSHOTS}`, `--project=${projectPath}`];
|
||||
|
||||
const execaOptions = {
|
||||
cwd: __dirname,
|
||||
@ -24,20 +30,20 @@ const cypress = commandName => {
|
||||
};
|
||||
|
||||
module.exports = () => {
|
||||
const configOption = '-c, --config <path>';
|
||||
const configDescription = 'path to JSON file where configuration values are set; defaults to "cypress.json"';
|
||||
const updateOption = '-u, --update-screenshots';
|
||||
const updateDescription = 'update expected screenshots';
|
||||
|
||||
program
|
||||
.command('open')
|
||||
.description('runs tests within the interactive GUI')
|
||||
.option(configOption, configDescription)
|
||||
.action(() => cypress('open'));
|
||||
.option(updateOption, updateDescription)
|
||||
.action(options => cypress('open', options));
|
||||
|
||||
program
|
||||
.command('run')
|
||||
.description('runs tests from the CLI without the GUI')
|
||||
.option(configOption, configDescription)
|
||||
.action(() => cypress('run'));
|
||||
.option(updateOption, updateDescription)
|
||||
.action(options => cypress('run', options));
|
||||
|
||||
program.parse(process.argv);
|
||||
};
|
||||
|
Reference in New Issue
Block a user