Merge pull request #11489 from gavindsouza/move-cypress
fix: Install Cypress only if running UI tests
This commit is contained in:
commit
66dcaf1e4e
4 changed files with 76 additions and 559 deletions
|
|
@ -20,10 +20,14 @@ context('FileUploader', () => {
|
|||
open_upload_dialog();
|
||||
|
||||
cy.fixture('example.json').then(fileContent => {
|
||||
cy.get_open_dialog().find('.file-upload-area').upload(
|
||||
{ fileContent, fileName: 'example.json', mimeType: 'application/json' },
|
||||
{ subjectType: 'drag-n-drop' },
|
||||
);
|
||||
cy.get_open_dialog().find('.file-upload-area').upload({
|
||||
fileContent,
|
||||
fileName: 'example.json',
|
||||
mimeType: 'application/json'
|
||||
}, {
|
||||
subjectType: 'drag-n-drop',
|
||||
force: true
|
||||
});
|
||||
cy.get_open_dialog().find('.file-info').should('contain', 'example.json');
|
||||
cy.server();
|
||||
cy.route('POST', '/api/method/upload_file').as('upload_file');
|
||||
|
|
|
|||
|
|
@ -554,10 +554,24 @@ def run_ui_tests(context, app, headless=False):
|
|||
site_env = 'CYPRESS_baseUrl={}'.format(site_url)
|
||||
password_env = 'CYPRESS_adminPassword={}'.format(admin_password) if admin_password else ''
|
||||
|
||||
os.chdir(app_base_path)
|
||||
|
||||
node_bin = subprocess.getoutput("npm bin")
|
||||
cypress_path = "{0}/cypress".format(node_bin)
|
||||
plugin_path = "{0}/cypress-file-upload".format(node_bin)
|
||||
|
||||
# check if cypress in path...if not, install it.
|
||||
if not (os.path.exists(cypress_path) or os.path.exists(plugin_path)):
|
||||
# install cypress
|
||||
click.secho("Installing Cypress...", fg="yellow")
|
||||
frappe.commands.popen("yarn add cypress@3 cypress-file-upload@^3.1 --no-lockfile")
|
||||
|
||||
# run for headless mode
|
||||
run_or_open = 'run --browser chrome --record --key 4a48f41c-11b3-425b-aa88-c58048fa69eb' if headless else 'open'
|
||||
command = '{site_env} {password_env} yarn run cypress {run_or_open}'
|
||||
formatted_command = command.format(site_env=site_env, password_env=password_env, run_or_open=run_or_open)
|
||||
command = '{site_env} {password_env} {cypress} {run_or_open}'
|
||||
formatted_command = command.format(site_env=site_env, password_env=password_env, cypress=cypress_path, run_or_open=run_or_open)
|
||||
|
||||
click.secho("Running Cypress...", fg="yellow")
|
||||
frappe.commands.popen(formatted_command, cwd=app_base_path, raise_err=True)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
"build": "node rollup/build.js",
|
||||
"production": "FRAPPE_ENV=production node rollup/build.js",
|
||||
"watch": "node rollup/watch.js",
|
||||
"cypress:open": "cypress open",
|
||||
"snyk-protect": "snyk protect",
|
||||
"prepare": "yarn run snyk-protect"
|
||||
},
|
||||
|
|
@ -55,8 +54,6 @@
|
|||
"devDependencies": {
|
||||
"babel-runtime": "^6.26.0",
|
||||
"chalk": "^2.3.2",
|
||||
"cypress": "3",
|
||||
"cypress-file-upload": "^3.1.0",
|
||||
"graphlib": "^2.1.8",
|
||||
"less": "^3.11.1",
|
||||
"rollup": "^1.2.2",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue