Merge branch 'develop' of github.com:frappe/frappe into modules-refactor

This commit is contained in:
Gavin D'souza 2022-08-08 12:15:12 +05:30
commit 624c308659
1669 changed files with 58505 additions and 59162 deletions

View file

@ -9,6 +9,7 @@ trim_trailing_whitespace = true
charset = utf-8
# python, js indentation settings
[{*.py,*.js,*.vue}]
[{*.py,*.js,*.vue,*.css,*.scss,*.html}]
indent_style = tab
indent_size = 4
max_line_length = 99

View file

@ -5,7 +5,7 @@
"es6": true
},
"parserOptions": {
"ecmaVersion": 9,
"ecmaVersion": 11,
"sourceType": "module"
},
"extends": "eslint:recommended",
@ -134,7 +134,6 @@
"Webcam": true,
"PhotoSwipe": true,
"PhotoSwipeUI_Default": true,
"fluxify": true,
"io": true,
"JsBarcode": true,
"L": true,

View file

@ -28,6 +28,10 @@ ignore =
B007,
B950,
W191,
E124, # closing bracket, irritating while writing QB code
E131, # continuation line unaligned for hanging indent
E123, # closing bracket does not match indentation of opening bracket's line
E101, # ensured by use of black
max-line-length = 200
exclude=.github/helper/semgrep_rules

View file

@ -22,3 +22,12 @@ b2fc959307c7c79f5584625569d5aed04133ba13
# Format codebase and sort imports
c0c5b2ebdddbe8898ce2d5e5365f4931ff73b6bf
# update python code to use 3.10 supported features
81b37cb7d2160866afa2496873656afe53f0c145
# mass minified JSON schema
85e3ee940353d7b0b517b33815148672e9a8b15b
# format JS files with pretter
40f27f908a3890c9a90d2d96794fc31fcea63c59

6
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View file

@ -30,7 +30,7 @@ def docs_link_exists(body):
if __name__ == "__main__":
pr = sys.argv[1]
response = requests.get("https://api.github.com/repos/frappe/frappe/pulls/{}".format(pr))
response = requests.get(f"https://api.github.com/repos/frappe/frappe/pulls/{pr}")
if response.ok:
payload = response.json()

75
.github/helper/flake8.conf vendored Normal file
View file

@ -0,0 +1,75 @@
[flake8]
ignore =
B001,
B007,
B009,
B010,
B950,
E101,
E111,
E114,
E116,
E117,
E121,
E122,
E123,
E124,
E125,
E126,
E127,
E128,
E131,
E201,
E202,
E203,
E211,
E221,
E222,
E223,
E224,
E225,
E226,
E228,
E231,
E241,
E242,
E251,
E261,
E262,
E265,
E266,
E271,
E272,
E273,
E274,
E301,
E302,
E303,
E305,
E306,
E402,
E501,
E502,
E701,
E702,
E703,
E741,
F401,
F403,
F405,
W191,
W291,
W292,
W293,
W391,
W503,
W504,
E711,
E129,
F841,
E713,
E712,
max-line-length = 200
exclude=.github/helper/semgrep_rules,test_*.py

View file

@ -1,65 +1,67 @@
#!/bin/bash
set -e
cd ~ || exit
pip install frappe-bench
echo "Setting Up Bench..."
bench init frappe-bench --skip-assets --python "$(which python)" --frappe-path "${GITHUB_WORKSPACE}"
pip install frappe-bench
bench -v init frappe-bench --skip-assets --python "$(which python)" --frappe-path "${GITHUB_WORKSPACE}"
cd ./frappe-bench || exit
bench -v setup requirements --dev
if [ "$TYPE" == "ui" ]; then
bench -v setup requirements --node;
fi
echo "Setting Up Sites & Database..."
mkdir ~/frappe-bench/sites/test_site
cp "${GITHUB_WORKSPACE}/.github/helper/consumer_db/$DB.json" ~/frappe-bench/sites/test_site/site_config.json
if [ "$TYPE" == "server" ]; then
mkdir ~/frappe-bench/sites/test_site_producer;
cp "${GITHUB_WORKSPACE}/.github/helper/producer_db/$DB.json" ~/frappe-bench/sites/test_site_producer/site_config.json;
mkdir ~/frappe-bench/sites/test_site_producer;
cp "${GITHUB_WORKSPACE}/.github/helper/producer_db/$DB.json" ~/frappe-bench/sites/test_site_producer/site_config.json;
fi
if [ "$DB" == "mariadb" ];then
sudo apt update && sudo apt install mariadb-client-10.3
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'";
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "SET GLOBAL character_set_server = 'utf8mb4'";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'";
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe_consumer";
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe_consumer'@'localhost' IDENTIFIED BY 'test_frappe_consumer'";
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe_consumer\`.* TO 'test_frappe_consumer'@'localhost'";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "CREATE DATABASE test_frappe_consumer";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "CREATE USER 'test_frappe_consumer'@'localhost' IDENTIFIED BY 'test_frappe_consumer'";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "GRANT ALL PRIVILEGES ON \`test_frappe_consumer\`.* TO 'test_frappe_consumer'@'localhost'";
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe_producer";
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe_producer'@'localhost' IDENTIFIED BY 'test_frappe_producer'";
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe_producer\`.* TO 'test_frappe_producer'@'localhost'";
mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'";
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES";
fi
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "CREATE DATABASE test_frappe_producer";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "CREATE USER 'test_frappe_producer'@'localhost' IDENTIFIED BY 'test_frappe_producer'";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "GRANT ALL PRIVILEGES ON \`test_frappe_producer\`.* TO 'test_frappe_producer'@'localhost'";
mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e "FLUSH PRIVILEGES";
fi
if [ "$DB" == "postgres" ];then
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe_consumer" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe_consumer WITH PASSWORD 'test_frappe'" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe_consumer" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe_consumer WITH PASSWORD 'test_frappe'" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe_producer" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe_producer WITH PASSWORD 'test_frappe'" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe_producer" -U postgres;
echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe_producer WITH PASSWORD 'test_frappe'" -U postgres;
fi
cd ./frappe-bench || exit
echo "Setting Up Procfile..."
sed -i 's/^watch:/# watch:/g' Procfile
sed -i 's/^schedule:/# schedule:/g' Procfile
if [ "$TYPE" == "server" ]; then
sed -i 's/^socketio:/# socketio:/g' Procfile;
sed -i 's/^redis_socketio:/# redis_socketio:/g' Procfile;
fi
if [ "$TYPE" == "ui" ]; then
sed -i 's/^web: bench serve/web: bench serve --with-coverage/g' Procfile;
fi
if [ "$TYPE" == "server" ]; then sed -i 's/^socketio:/# socketio:/g' Procfile; fi
if [ "$TYPE" == "server" ]; then sed -i 's/^redis_socketio:/# redis_socketio:/g' Procfile; fi
echo "Starting Bench..."
if [ "$TYPE" == "ui" ]; then bench setup requirements --node; fi
bench setup requirements --dev
if [ "$TYPE" == "ui" ]; then sed -i 's/^web: bench serve/web: bench serve --with-coverage/g' Procfile; fi
# install node-sass which is required for website theme test
cd ./apps/frappe || exit
yarn add node-sass@4.13.1
cd ../..
bench start &
bench start &> bench_start.log &
bench --site test_site reinstall --yes
if [ "$TYPE" == "server" ]; then bench --site test_site_producer reinstall --yes; fi
if [ "$TYPE" == "server" ]; then CI=Yes bench build --app frappe; fi
if [ "$TYPE" == "server" ]; then
bench --site test_site_producer reinstall --yes;
CI=Yes bench build --app frappe;
fi

View file

@ -1,16 +1,14 @@
#!/bin/bash
set -e
# install wkhtmltopdf
wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
sudo chmod o+x /usr/local/bin/wkhtmltopdf
echo "Setting Up System Dependencies..."
# install cups
sudo apt-get install libcups2-dev
install_wkhtmltopdf() {
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
}
install_wkhtmltopdf &
# install redis
sudo apt-get install redis-server
sudo apt update
sudo apt install libcups2-dev redis-server mariadb-client-10.3

View file

@ -5,19 +5,40 @@ import shlex
import subprocess
import sys
import urllib.request
from functools import lru_cache
@lru_cache(maxsize=None)
def fetch_pr_data(pr_number, repo, endpoint=""):
api_url = f"https://api.github.com/repos/{repo}/pulls/{pr_number}"
if endpoint:
api_url += f"/{endpoint}"
req = urllib.request.Request(api_url)
res = urllib.request.urlopen(req)
return json.loads(res.read().decode('utf8'))
def get_files_list(pr_number, repo="frappe/frappe"):
req = urllib.request.Request(f"https://api.github.com/repos/{repo}/pulls/{pr_number}/files")
res = urllib.request.urlopen(req)
dump = json.loads(res.read().decode('utf8'))
return [change["filename"] for change in dump]
return [change["filename"] for change in fetch_pr_data(pr_number, repo, "files")]
def get_output(command, shell=True):
print(command)
command = shlex.split(command)
return subprocess.check_output(command, shell=shell, encoding="utf8").strip()
def has_skip_ci_label(pr_number, repo="frappe/frappe"):
return has_label(pr_number, "Skip CI", repo)
def has_run_server_tests_label(pr_number, repo="frappe/frappe"):
return has_label(pr_number, "Run Server Tests", repo)
def has_run_ui_tests_label(pr_number, repo="frappe/frappe"):
return has_label(pr_number, "Run UI Tests", repo)
def has_label(pr_number, label, repo="frappe/frappe"):
return any([fetched_label["name"] for fetched_label in fetch_pr_data(pr_number, repo)["labels"] if fetched_label["name"] == label])
def is_py(file):
return file.endswith("py")
@ -25,10 +46,10 @@ def is_ci(file):
return ".github" in file
def is_frontend_code(file):
return file.lower().endswith((".css", ".scss", ".less", ".sass", ".styl", ".js", ".ts", ".vue"))
return file.lower().endswith((".css", ".scss", ".less", ".sass", ".styl", ".js", ".ts", ".vue", ".html"))
def is_docs(file):
regex = re.compile(r'\.(md|png|jpg|jpeg|csv)$|^.github|LICENSE')
regex = re.compile(r'\.(md|png|jpg|jpeg|csv|svg)$|^.github|LICENSE')
return bool(regex.search(file))
@ -56,23 +77,23 @@ if __name__ == "__main__":
updated_py_file_count = len(list(filter(is_py, files_list)))
only_py_changed = updated_py_file_count == len(files_list)
if ci_files_changed:
if has_skip_ci_label(pr_number, repo):
print("Found `Skip CI` label on pr, stopping build process.")
sys.exit(0)
elif ci_files_changed:
print("CI related files were updated, running all build processes.")
elif only_docs_changed:
print("Only docs were updated, stopping build process.")
sys.exit(0)
elif only_frontend_code_changed and build_type == "server":
elif only_frontend_code_changed and build_type == "server" and not has_run_server_tests_label(pr_number, repo):
print("Only Frontend code was updated; Stopping Python build process.")
sys.exit(0)
elif build_type == "ui":
if only_py_changed:
print("Only Python code was updated, stopping Cypress build process.")
sys.exit(0)
elif updated_py_file_count > 0:
# both frontend and backend code were updated
os.system('echo "::set-output name=build-server::strawberry"')
elif build_type == "ui" and only_py_changed and not has_run_ui_tests_label(pr_number, repo):
print("Only Python code was updated, stopping Cypress build process.")
sys.exit(0)
os.system('echo "::set-output name=build::strawberry"')

View file

@ -20,19 +20,12 @@ for _file in files_to_scan:
if 'frappe-lint: disable-translate' in line:
continue
start_matches = start_pattern.search(line)
if start_matches:
starts_with_f = starts_with_f_pattern.search(line)
if starts_with_f:
has_f_string = f_string_pattern.search(line)
if has_f_string:
if start_matches := start_pattern.search(line):
if starts_with_f := starts_with_f_pattern.search(line):
if has_f_string := f_string_pattern.search(line):
errors_encounter += 1
print(f'\nF-strings are not supported for translations at line number {line_number}\n{line.strip()[:100]}')
continue
else:
continue
continue
match = pattern.search(line)
error_found = False

4
.github/labeler.yml vendored Normal file
View file

@ -0,0 +1,4 @@
# Any python files modifed but no test files modified
add-test-cases:
- any: ['frappe/**/*.py']
all: ['!frappe/**/test*.py']

30
.github/semantic.yml vendored
View file

@ -1,30 +0,0 @@
# Always validate the PR title AND all the commits
titleAndCommits: true
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowMergeCommits: true
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowRevertCommits: true
# For allowed PR types: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json
# Tool Reference: https://github.com/zeke/semantic-pull-requests
# By default types specified in commitizen/conventional-commit-types is used.
# See: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json
# You can override the valid types
types:
- BREAKING CHANGE
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert

View file

@ -1,4 +1,4 @@
<svg width="201" height="60" viewBox="0 0 201 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="4 2 193 52">
<g filter="url(#filter0_dd)">
<rect x="4" y="2" width="193" height="52" rx="6" fill="#2490EF"/>
<path d="M28 22.2891H32.8786V35.5H36.2088V22.2891H41.0874V19.5H28V22.2891Z" fill="white"/>
@ -29,4 +29,4 @@
<feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow" result="shape"/>
</filter>
</defs>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

34
.github/workflows/create-release.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: Generate Semantic Release
on:
push:
branches:
- version-14-beta
permissions:
contents: read
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Entire Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup dependencies
run: |
npm install @semantic-release/git @semantic-release/exec --no-save
- name: Create Release
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GIT_AUTHOR_NAME: "Frappe PR Bot"
GIT_AUTHOR_EMAIL: "developers@frappe.io"
GIT_COMMITTER_NAME: "Frappe PR Bot"
GIT_COMMITTER_EMAIL: "developers@frappe.io"
run: npx semantic-release

View file

@ -1,15 +0,0 @@
name: 'Trigger Docker build on release'
on:
release:
types: [released]
jobs:
curl:
name: 'Trigger Docker build on release'
runs-on: ubuntu-latest
container:
image: alpine:latest
steps:
- name: curl
run: |
apk add curl bash
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.CI_PAT }}" https://api.github.com/repos/frappe/frappe_docker/actions/workflows/build_stable.yml/dispatches -d '{"ref":"main"}'

View file

@ -1,25 +0,0 @@
name: 'Documentation Check'
on:
pull_request:
types: [ opened, synchronize, reopened, edited ]
jobs:
docs-required:
name: 'Documentation Required'
runs-on: ubuntu-latest
steps:
- name: 'Setup Environment'
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: 'Clone repo'
uses: actions/checkout@v2
- name: Validate Docs
env:
PR_NUMBER: ${{ github.event.number }}
run: |
pip install requests --quiet
python $GITHUB_WORKSPACE/.github/helper/documentation.py $PR_NUMBER

12
.github/workflows/labeller.yml vendored Normal file
View file

@ -0,0 +1,12 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened, reopened]
jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

View file

@ -1,31 +1,86 @@
name: Linters
on:
pull_request: { }
pull_request:
workflow_dispatch:
push:
branches: [ develop ]
permissions:
contents: read
concurrency:
group: commitcheck-frappe-${{ github.event.number }}
cancel-in-progress: true
jobs:
linters:
name: Frappe Linter
commit-lint:
name: 'Semantic Commits'
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v3
with:
python-version: 3.8
fetch-depth: 200
- uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
- name: Install and Run Pre-commit
uses: pre-commit/action@v2.0.3
- name: Check commit titles
run: |
npm install @commitlint/cli @commitlint/config-conventional
npx commitlint --verbose --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }}
docs-required:
name: 'Documentation Required'
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: 'Setup Environment'
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v3
- name: Validate Docs
env:
PR_NUMBER: ${{ github.event.number }}
run: |
pip install requests --quiet
python $GITHUB_WORKSPACE/.github/helper/documentation.py $PR_NUMBER
linter:
name: 'Frappe Linter'
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: pre-commit/action@v3.0.0
- name: Download Semgrep rules
run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules
- uses: returntocorp/semgrep-action@v1
env:
SEMGREP_TIMEOUT: 120
- name: Run Semgrep rules
run: |
pip install semgrep==0.97.0
semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness
deps-vulnerable-check:
name: 'Vulnerable Dependency Check'
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
config: >-
r/python.lang.correctness
./frappe-semgrep-rules/rules
python-version: '3.10'
- uses: actions/checkout@v3
- run: |
pip install pip-audit
pip-audit ${GITHUB_WORKSPACE}

View file

@ -1,8 +1,11 @@
name: 'Frappe Assets'
name: 'Release'
on:
release:
types: [ created ]
types: [released]
permissions:
contents: read
env:
GITHUB_TOKEN: ${{ github.token }}
@ -13,20 +16,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: 'frappe'
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
python-version: '12.x'
- uses: actions/setup-python@v2
node-version: 16
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Set up bench and build assets
run: |
npm install -g yarn
pip3 install -U frappe-bench
bench init frappe-bench --no-procfile --no-backups --skip-assets --skip-redis-config-generation --python $(which python) --frappe-path $GITHUB_WORKSPACE/frappe
bench -v init frappe-bench --no-procfile --no-backups --skip-assets --skip-redis-config-generation --python $(which python) --frappe-path $GITHUB_WORKSPACE/frappe
cd frappe-bench && bench build
- name: Package assets
@ -36,7 +41,7 @@ jobs:
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.2.0
uses: bruceadams/get-release@v1.2.3
- name: Upload built Assets to Release
uses: actions/upload-release-asset@v1.0.2
@ -45,3 +50,16 @@ jobs:
asset_path: build/assets.tar.gz
asset_name: assets.tar.gz
asset_content_type: application/octet-stream
docker-release:
name: 'Trigger Docker build on release'
runs-on: ubuntu-latest
permissions:
contents: none
container:
image: alpine:latest
steps:
- name: curl
run: |
apk add curl bash
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.CI_PAT }}" https://api.github.com/repos/frappe/frappe_docker/actions/workflows/build_stable.yml/dispatches -d '{"ref":"main"}'

View file

@ -1,42 +1,42 @@
name: Patch
on: [pull_request, workflow_dispatch]
name: Server (MariaDB)
on:
pull_request:
workflow_dispatch:
concurrency:
group: patch-mariadb-develop-${{ github.event.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: Patch
runs-on: ubuntu-latest
timeout-minutes: 60
name: Patch Test
services:
mysql:
image: mariadb:10.3
mariadb:
image: mariadb:10.6
env:
MYSQL_ALLOW_EMPTY_PASSWORD: YES
MARIADB_ROOT_PASSWORD: travis
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
check-latest: true
- name: Check for valid Python & Merge Conflicts
run: |
python -m compileall -f "${GITHUB_WORKSPACE}"
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
then echo "Found merge conflicts"
exit 1
fi
- name: Check if build should be run
id: check-build
@ -47,23 +47,36 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
REPO_NAME: ${{ github.repository }}
- name: Setup Python
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: "gabrielfalcao/pyenv-action@v10"
with:
versions: 3.10:latest, 3.7:latest
- name: Setup Node
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
- name: Add to Hosts
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
- name: Cache pip
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Cache node modules
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
@ -79,7 +92,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
id: yarn-cache
with:
@ -90,18 +103,16 @@ jobs:
- name: Install Dependencies
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
run: |
bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
pip install frappe-bench
pyenv global $(pyenv versions | grep '3.10')
bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
TYPE: server
- name: Install
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
DB: mariadb
TYPE: server
- name: Run Patch Tests
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
@ -114,18 +125,23 @@ jobs:
cd apps/frappe/
git remote set-url upstream https://github.com/frappe/frappe.git
pyenv global $(pyenv versions | grep '3.7')
for version in $(seq 12 13)
do
echo "Updating to v$version"
branch_name="version-$version-hotfix"
git fetch --depth 1 upstream $branch_name:$branch_name
git checkout -q -f $branch_name
pip install -q -r requirements.txt
pip install -U frappe-bench
rm -rf ~/frappe-bench/env
bench -v setup env
bench --site test_site migrate
done
echo "Updating to last commit"
git checkout -q -f "$GITHUB_SHA"
bench setup requirements --python
pyenv global $(pyenv versions | grep '3.10')
rm -rf ~/frappe-bench/env
bench -v setup env
bench --site test_site migrate

View file

@ -1,6 +1,7 @@
name: 'Frappe Assets'
on:
workflow_dispatch:
push:
branches: [ develop ]
@ -10,20 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: 'frappe'
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 14
- uses: actions/setup-python@v2
node-version: 16
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Set up bench and build assets
run: |
npm install -g yarn
pip3 install -U frappe-bench
bench init frappe-bench --no-procfile --no-backups --skip-assets --skip-redis-config-generation --python $(which python) --frappe-path $GITHUB_WORKSPACE/frappe
bench -v init frappe-bench --no-procfile --no-backups --skip-assets --skip-redis-config-generation --python $(which python) --frappe-path $GITHUB_WORKSPACE/frappe
cd frappe-bench && bench build
- name: Package assets

View file

@ -1,4 +1,4 @@
name: Server
name: Server (MariaDB)
on:
pull_request:
@ -11,8 +11,12 @@ concurrency:
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 60
@ -21,25 +25,31 @@ jobs:
matrix:
container: [1, 2]
name: Python Unit Tests (MariaDB)
services:
mysql:
image: mariadb:10.3
mariadb:
image: mariadb:10.6
env:
MYSQL_ALLOW_EMPTY_PASSWORD: YES
MARIADB_ROOT_PASSWORD: travis
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Check for valid Python & Merge Conflicts
run: |
python -m compileall -f "${GITHUB_WORKSPACE}"
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
then echo "Found merge conflicts"
exit 1
fi
- name: Check if build should be run
id: check-build
@ -50,10 +60,10 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
REPO_NAME: ${{ github.repository }}
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
with:
node-version: 14
node-version: 16
check-latest: true
- name: Add to Hosts
@ -64,17 +74,17 @@ jobs:
- name: Cache pip
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Cache node modules
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
@ -90,7 +100,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
id: yarn-cache
with:
@ -101,18 +111,14 @@ jobs:
- name: Install Dependencies
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
run: |
bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
TYPE: server
- name: Install
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
DB: mariadb
TYPE: server
- name: Run Tests
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
@ -123,7 +129,7 @@ jobs:
- name: Upload coverage data
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
name: MariaDB
fail_ci_if_error: true

View file

@ -1,4 +1,4 @@
name: Server
name: Server (Postgres)
on:
pull_request:
@ -10,8 +10,12 @@ concurrency:
group: server-postgres-develop-${{ github.event.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 60
@ -20,8 +24,6 @@ jobs:
matrix:
container: [1, 2]
name: Python Unit Tests (Postgres)
services:
postgres:
image: postgres:12.4
@ -37,12 +39,20 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Check for valid Python & Merge Conflicts
run: |
python -m compileall -f "${GITHUB_WORKSPACE}"
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
then echo "Found merge conflicts"
exit 1
fi
- name: Check if build should be run
id: check-build
@ -53,10 +63,10 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
REPO_NAME: ${{ github.repository }}
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
with:
node-version: '14'
node-version: '16'
check-latest: true
- name: Add to Hosts
@ -67,17 +77,17 @@ jobs:
- name: Cache pip
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Cache node modules
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
@ -93,7 +103,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
id: yarn-cache
with:
@ -104,18 +114,14 @@ jobs:
- name: Install Dependencies
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
run: |
bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
TYPE: server
- name: Install
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
DB: postgres
TYPE: server
- name: Run Tests
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
@ -126,7 +132,7 @@ jobs:
- name: Upload coverage data
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
name: Postgres
fail_ci_if_error: true

View file

@ -10,6 +10,9 @@ concurrency:
group: ui-develop-${{ github.event.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
@ -18,27 +21,35 @@ jobs:
strategy:
fail-fast: false
matrix:
containers: [1, 2]
containers: [1, 2, 3]
name: UI Tests (Cypress)
services:
mysql:
image: mariadb:10.3
mariadb:
image: mariadb:10.6
env:
MYSQL_ALLOW_EMPTY_PASSWORD: YES
MARIADB_ROOT_PASSWORD: travis
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Check for valid Python & Merge Conflicts
run: |
python -m compileall -f "${GITHUB_WORKSPACE}"
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
then echo "Found merge conflicts"
exit 1
fi
- name: Check if build should be run
id: check-build
@ -49,10 +60,10 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
REPO_NAME: ${{ github.repository }}
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
with:
node-version: 14
node-version: 16
check-latest: true
- name: Add to Hosts
@ -63,17 +74,17 @@ jobs:
- name: Cache pip
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Cache node modules
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
@ -89,7 +100,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
id: yarn-cache
with:
@ -100,7 +111,7 @@ jobs:
- name: Cache cypress binary
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache
key: ${{ runner.os }}-cypress-
@ -110,18 +121,14 @@ jobs:
- name: Install Dependencies
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
run: |
bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
TYPE: ui
- name: Install
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
env:
DB: mariadb
TYPE: ui
- name: Instrument Source Code
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
@ -155,7 +162,7 @@ jobs:
- name: Upload Coverage Data
if: ${{ steps.check-build.outputs.build == 'strawberry' && steps.check_coverage.outputs.files_exists == 'true' }}
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
name: Cypress
fail_ci_if_error: true
@ -165,10 +172,14 @@ jobs:
- name: Upload Server Coverage Data
if: ${{ steps.check-build.outputs.build-server == 'strawberry' }}
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
name: MariaDB
fail_ci_if_error: true
files: /home/runner/frappe-bench/sites/coverage.xml
verbose: true
flags: server
- name: Show bench console if tests failed
if: ${{ failure() }}
run: cat ~/frappe-bench/bench_start.log

1
.gitignore vendored
View file

@ -36,7 +36,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/

View file

@ -6,6 +6,8 @@ pull_request_rules:
- author!=surajshetty3416
- author!=gavindsouza
- author!=deepeshgarg007
- author!=ankush
- author!=mergify[bot]
- or:
- base=version-13
- base=version-12
@ -13,19 +15,20 @@ pull_request_rules:
close:
comment:
message: |
@{{author}}, thanks for the contribution, but we do not accept pull requests on a stable branch. Please raise PR on an appropriate hotfix branch.
@{{author}}, thanks for the contribution, but we do not accept pull requests on a stable branch. Please raise PR on an appropriate hotfix branch.
https://github.com/frappe/erpnext/wiki/Pull-Request-Checklist#which-branch
- name: Automatic merge on CI success and review
conditions:
- status-success=Sider
- status-success=Semantic Pull Request
- status-success=Check Commit Titles
- status-success=Python Unit Tests (MariaDB) (1)
- status-success=Python Unit Tests (MariaDB) (2)
- status-success=Python Unit Tests (Postgres) (1)
- status-success=Python Unit Tests (Postgres) (2)
- status-success=UI Tests (Cypress) (1)
- status-success=UI Tests (Cypress) (2)
- status-success=UI Tests (Cypress) (3)
- status-success=security/snyk (frappe)
- label!=dont-merge
- label!=squash
@ -42,6 +45,7 @@ pull_request_rules:
- status-success=Python Unit Tests (Postgres) (2)
- status-success=UI Tests (Cypress) (1)
- status-success=UI Tests (Cypress) (2)
- status-success=UI Tests (Cypress) (3)
- status-success=security/snyk (frappe)
- label!=dont-merge
- label=squash
@ -53,3 +57,63 @@ pull_request_rules:
{{ title }} (#{{ number }})
{{ body }}
- name: backport to develop
conditions:
- label="backport develop"
actions:
backport:
branches:
- develop
assignees:
- "{{ author }}"
- name: backport to version-13-hotfix
conditions:
- label="backport version-13-hotfix"
actions:
backport:
branches:
- version-13-hotfix
assignees:
- "{{ author }}"
- name: backport to version-14-hotfix
conditions:
- label="backport version-14-hotfix"
actions:
backport:
branches:
- version-14-hotfix
assignees:
- "{{ author }}"
- name: backport to develop
conditions:
- label="backport develop"
actions:
backport:
branches:
- develop
assignees:
- "{{ author }}"
- name: backport to version-13-pre-release
conditions:
- label="backport version-13-pre-release"
actions:
backport:
branches:
- version-13-pre-release
assignees:
- "{{ author }}"
- name: backport to version-12-hotfix
conditions:
- label="backport version-12-hotfix"
actions:
backport:
branches:
- version-12-hotfix
assignees:
- "{{ author }}"

View file

@ -5,7 +5,7 @@ fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: trailing-whitespace
files: "frappe.*"
@ -15,6 +15,16 @@ repos:
args: ['--branch', 'develop']
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
hooks:
- id: pyupgrade
args: ['--py310-plus']
- repo: https://github.com/adityahase/black
rev: 9cb0a69f4d0030cdf687eddf314468b39ed54119
@ -22,11 +32,34 @@ repos:
- id: black
additional_dependencies: ['click==8.0.4']
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
types_or: [javascript]
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
frappe/public/dist/.*|
.*node_modules.*|
.*boilerplate.*|
frappe/www/website_script.js|
frappe/templates/includes/.*|
frappe/public/js/lib/.*
)$
- repo: https://github.com/timothycrosley/isort
rev: 5.9.1
hooks:
- id: isort
exclude: ".*setup.py$"
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: ['flake8-bugbear',]
args: ['--config', '.github/helper/flake8.conf']
ci:
autoupdate_schedule: weekly

View file

@ -1,2 +0,0 @@
disable=access-member-before-definition
disable=no-member

21
.releaserc Normal file
View file

@ -0,0 +1,21 @@
{
"branches": ["develop", {"name": "version-14-beta", "channel": "beta", "prerelease": true}],
"plugins": [
"@semantic-release/commit-analyzer", {
"preset": "angular"
},
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec", {
"prepareCmd": 'sed -ir "s/[0-9]*\.[0-9]*\.[0-9]*/${nextRelease.version}/" frappe/__init__.py'
}
],
[
"@semantic-release/git", {
"assets": ["frappe/__init__.py"],
"message": "chore(release): Bumped to Version ${nextRelease.version}\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}

View file

@ -12,7 +12,7 @@ data_import* @netchampfaris
core/ @surajshetty3416
database @gavindsouza
model @gavindsouza
requirements.txt @gavindsouza
pyproject.toml @gavindsouza
query_builder/ @gavindsouza
commands/ @gavindsouza
workspace @shariquerik

View file

@ -1,4 +0,0 @@
BASEDIR := $(realpath .)
clean:
find $(BASEDIR) | grep -E "__pycache__|\.pyc" | xargs rm -rf

View file

@ -1,16 +1,16 @@
<div align="center">
<h1>
<br>
<a href="https://frappeframework.com">
<img src=".github/frappe-framework-logo.svg" height="50">
</a>
</h1>
<h3>
a web framework with <a href="https://www.youtube.com/watch?v=LOjk3m0wTwg">"batteries included"</a>
</h3>
<h5>
it's pronounced - <em>fra-pay</em>
</h5>
<h1>
<br>
<a href="https://frappeframework.com">
<img src=".github/frappe-framework-logo.svg" height="50">
</a>
</h1>
<h3>
a web framework with <a href="https://www.youtube.com/watch?v=LOjk3m0wTwg">"batteries included"</a>
</h3>
<h5>
it's pronounced - <em>fra-pay</em>
</h5>
</div>
<div align="center">
@ -27,20 +27,24 @@
<img src='https://www.codetriage.com/frappe/frappe/badges/users.svg'>
</a>
<a href="https://codecov.io/gh/frappe/frappe">
<img src="https://codecov.io/gh/frappe/frappe/branch/develop/graph/badge.svg?token=XoTa679hIj"/>
<img src="https://codecov.io/gh/frappe/frappe/branch/develop/graph/badge.svg?token=XoTa679hIj"/>
</a>
</div>
Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for [ERPNext](https://erpnext.com)
<div align="center">
<a href="https://frappecloud.com/deploy?apps=frappe&source=frappe_readme">
<div align="center" style="max-height: 40px;">
<a href="https://frappecloud.com/frappe/signup">
<img src=".github/try-on-f-cloud-button.svg" height="40">
</a>
<a href="https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/gavindsouza/install-scripts/main/frappe/pwd.yml">
<img src="https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png" alt="Try in PWD" height="37"/>
</a>
</div>
> Login for the PWD site: (username: Administrator, password: admin)
## Table of Contents
* [Installation](#installation)
* [Contributing](#contributing)
@ -52,7 +56,7 @@ Full-stack web application framework that uses Python and MariaDB on the server
* [Install via Docker](https://github.com/frappe/frappe_docker)
* [Install via Frappe Bench](https://github.com/frappe/bench)
* [Offical Documentation](https://frappeframework.com/docs/user/en/installation)
* [Managed Hosting on Frappe Cloud](https://frappecloud.com/deploy?apps=frappe&source=frappe_readme)
* [Managed Hosting on Frappe Cloud](https://frappecloud.com/frappe/signup)
## Contributing

View file

@ -1,50 +1,31 @@
## Frappe framework includes these public works
## 3rd-Party Software Report
### Javascript / CSS
The following 3rd-party software packages may be used by or distributed with <https://github.com/frappe/frappe>.
- Bootstrap: MIT License, (c) Twitter Inc, https://getbootstrap.com
- JQuery: MIT License, (c) JQuery Foundation, http://jquery.org/license
- JQuery UI: MIT License / GPL 2, (c) JQuery Foundation, https://jqueryui.com/about
- JQuery UI Bootstrap Theme: MIT / GPL 2, (c) Addy Osmani, http://addyosmani.github.com/jquery-ui-bootstrap
- QUnit: MIT License, (c) JQuery Foundation, http://jquery.org/license
- jquery.event.drag, MIT License, (c) 2010 Three Dub Media - http://threedubmedia.com
- JQuery Cookie Plugin, MIT / GPL 2, (c) 2011, Klaus Hartl
- JQuery Time Picker, MIT License, (c) 2013 Trent Richardson, http://trentrichardson.com/examples/timepicker
- JQuery Hotkeys Plugin, MIT License, (c) 2010, John Resig
- prettydate.js, MIT License, (c) 2011, John Resig
- JQuery Resize Event, MIT License, (c) 2010 "Cowboy" Ben Alman
- excanvas.js, Apache License Version 2.0, (c) 2006 Google Inc
- showdown.js - Javascript Markdown, BSD-style Open Source License, (c) 2007 John Fraser
- Beautify HTML - MIT License, (c) 2007-2013 Einar Lielmanis and contributors.
- JQuery Gantt - MIT License, http://taitems.github.com/jQuery.Gantt/
- SlickGrid - MIT License, https://github.com/mleibman/SlickGrid
- MomentJS - MIT License, https://github.com/moment/moment
- JSColor - LGPL, (c) Jan Odvarko, http://jscolor.com
- FullCalendar - MIT License, (c) 2013 Adam Shaw, http://fullcalendar.io/license/
- Sortable - MIT License (c) 2013-2015 Lebedev Konstantin http://rubaxa.github.io/Sortable/
### Python
- minify.js - MIT License, (c) 2002 Douglas Crockford
- Bootstrap: MIT License, (c) Twitter Inc, <https://getbootstrap.com>
- JQuery: MIT License, (c) JQuery Foundation, <http://jquery.org/license>
- FullCalendar - MIT License, (c) 2013 Adam Shaw, <http://fullcalendar.io/license/>
- JSignature - MIT License, (c) 2012 Willow Systems Corp <http://willow-systems.com>, (c) 2010 Brinley Ang <http://www.unbolt.net>
- PhotoSwipe - MIT License, (c) 2014-2015 Dmitry Semenov, <http://dimsemenov.com>
- Leaflet - (c) 2010-2016, Vladimir Agafonkin, (c) 2010-2011, CloudMade
- Leaflet.Locate - (c) 2016 Dominik Moritz
- Leaflet.draw - (c) 2012-2017, Jacob Toye, Jon West, Smartrak
- Leaflet.EasyButton - MIT License, (C) 2014 Daniel Montague
### Icon Fonts
- Font Awesome - http://fontawesome.io/
- Font License: SIL OFL 1.1 (http://scripts.sil.org/OFL)
- Code License: MIT (http://choosealicense.com/licenses/mit/)
- Octicons (c) GitHub Inc, https://octicons.github.com/
- Font License: SIL OFL 1.1 (http://scripts.sil.org/OFL)
- Code License: MIT (http://choosealicense.com/licenses/mit/)
- Ionicons - MIT License, http://ionicons.com/
- Font Awesome - <http://fontawesome.io/>
- Font License: SIL OFL 1.1 (<http://scripts.sil.org/OFL>)
- Code License: MIT (<http://choosealicense.com/licenses/mit/>)
- Octicons (c) GitHub Inc, <https://octicons.github.com/>
- Font License: SIL OFL 1.1 (<http://scripts.sil.org/OFL>)
- Code License: MIT (<http://choosealicense.com/licenses/mit/>)
- Inter - SIL Open Font License, 1.1 (c) 2020 Rasmus Andersson (<https://github.com/rsms/inter>)
### IP Address Database
- GeoIP: (c) 2014 MaxMind, http://dev.maxmind.com/geoip/geoip2/downloadable/
### Wallpaper
- Version 5 Wallpaper: http://magdeleine.co/photo-nick-west-n-139/ (Public Domain)
- GeoIP: (c) 2014 MaxMind, <http://dev.maxmind.com/geoip/geoip2/downloadable/>
---
Last updated: 1st Jan 2015
Last updated: 4th July 2022

25
commitlint.config.js Normal file
View file

@ -0,0 +1,25 @@
module.exports = {
parserPreset: "conventional-changelog-conventionalcommits",
rules: {
"subject-empty": [2, "never"],
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"],
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
],
],
},
};

View file

@ -13,8 +13,8 @@ export default {
fieldtype: "Data",
in_list_view: 1,
label: "Title",
unique: 1
}
unique: 1,
},
],
links: [],
istable: 1,
@ -24,7 +24,7 @@ export default {
naming_rule: "By fieldname",
owner: "Administrator",
permissions: [],
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
};
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -12,38 +12,38 @@ export default {
fieldname: "data",
fieldtype: "Data",
in_list_view: 1,
label: "Data"
label: "Data",
},
{
fieldname: "barcode",
fieldtype: "Barcode",
in_list_view: 1,
label: "Barcode"
label: "Barcode",
},
{
fieldname: "check",
fieldtype: "Check",
in_list_view: 1,
label: "Check"
label: "Check",
},
{
fieldname: "rating",
fieldtype: "Rating",
in_list_view: 1,
label: "Rating"
label: "Rating",
},
{
fieldname: "duration",
fieldtype: "Duration",
in_list_view: 1,
label: "Duration"
label: "Duration",
},
{
fieldname: "date",
fieldtype: "Date",
in_list_view: 1,
label: "Date"
}
label: "Date",
},
],
links: [],
istable: 1,
@ -53,7 +53,7 @@ export default {
naming_rule: "By fieldname",
owner: "Administrator",
permissions: [],
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
};
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -1,37 +1,37 @@
export default {
name: 'Custom Submittable DocType',
name: "Custom Submittable DocType",
custom: 1,
actions: [],
is_submittable: 1,
creation: '2019-12-10 06:29:07.215072',
doctype: 'DocType',
creation: "2019-12-10 06:29:07.215072",
doctype: "DocType",
editable_grid: 1,
engine: 'InnoDB',
engine: "InnoDB",
fields: [
{
fieldname: 'enabled',
fieldtype: 'Check',
label: 'Enabled',
fieldname: "enabled",
fieldtype: "Check",
label: "Enabled",
allow_on_submit: 1,
reqd: 1
reqd: 1,
},
{
fieldname: 'title',
fieldtype: 'Data',
label: 'title',
reqd: 1
fieldname: "title",
fieldtype: "Data",
label: "title",
reqd: 1,
},
{
fieldname: 'description',
fieldtype: 'Text Editor',
label: 'Description'
}
fieldname: "description",
fieldtype: "Text Editor",
label: "Description",
},
],
links: [],
modified: '2019-12-10 14:40:53.127615',
modified_by: 'Administrator',
module: 'Custom',
owner: 'Administrator',
modified: "2019-12-10 14:40:53.127615",
modified_by: "Administrator",
module: "Custom",
owner: "Administrator",
permissions: [
{
create: 1,
@ -39,15 +39,15 @@ export default {
email: 1,
print: 1,
read: 1,
role: 'System Manager',
role: "System Manager",
share: 1,
write: 1,
submit: 1,
cancel: 1
}
cancel: 1,
},
],
quick_entry: 1,
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
};
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -1,51 +1,51 @@
export default {
name: 'Validation Test',
name: "Validation Test",
custom: 1,
actions: [],
creation: '2019-03-15 06:29:07.215072',
doctype: 'DocType',
creation: "2019-03-15 06:29:07.215072",
doctype: "DocType",
editable_grid: 1,
engine: 'InnoDB',
engine: "InnoDB",
fields: [
{
fieldname: 'email',
fieldtype: 'Data',
label: 'Email',
options: 'Email'
fieldname: "email",
fieldtype: "Data",
label: "Email",
options: "Email",
},
{
fieldname: 'URL',
fieldtype: 'Data',
label: 'URL',
options: 'URL'
fieldname: "URL",
fieldtype: "Data",
label: "URL",
options: "URL",
},
{
fieldname: 'Phone',
fieldtype: 'Data',
label: 'Phone',
options: 'Phone'
fieldname: "Phone",
fieldtype: "Data",
label: "Phone",
options: "Phone",
},
{
fieldname: 'person_name',
fieldtype: 'Data',
label: 'Person Name',
options: 'Name'
fieldname: "person_name",
fieldtype: "Data",
label: "Person Name",
options: "Name",
},
{
fieldname: 'read_only_url',
fieldtype: 'Data',
label: 'Read Only URL',
options: 'URL',
read_only: '1',
default: 'https://frappe.io'
}
fieldname: "read_only_url",
fieldtype: "Data",
label: "Read Only URL",
options: "URL",
read_only: "1",
default: "https://frappe.io",
},
],
issingle: 1,
links: [],
modified: '2021-04-19 14:40:53.127615',
modified_by: 'Administrator',
module: 'Custom',
owner: 'Administrator',
modified: "2021-04-19 14:40:53.127615",
modified_by: "Administrator",
module: "Custom",
owner: "Administrator",
permissions: [
{
create: 1,
@ -53,13 +53,13 @@ export default {
email: 1,
print: 1,
read: 1,
role: 'System Manager',
role: "System Manager",
share: 1,
write: 1
}
write: 1,
},
],
quick_entry: 1,
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -1,34 +1,34 @@
export default {
name: 'DateTime Test',
name: "DateTime Test",
custom: 1,
actions: [],
creation: '2019-03-15 06:29:07.215072',
doctype: 'DocType',
creation: "2019-03-15 06:29:07.215072",
doctype: "DocType",
editable_grid: 1,
engine: 'InnoDB',
engine: "InnoDB",
fields: [
{
fieldname: 'date',
fieldtype: 'Date',
label: 'Date'
fieldname: "date",
fieldtype: "Date",
label: "Date",
},
{
fieldname: 'time',
fieldtype: 'Time',
label: 'Time'
fieldname: "time",
fieldtype: "Time",
label: "Time",
},
{
fieldname: 'datetime',
fieldtype: 'Datetime',
label: 'Datetime'
}
fieldname: "datetime",
fieldtype: "Datetime",
label: "Datetime",
},
],
issingle: 1,
links: [],
modified: '2019-12-09 14:40:53.127615',
modified_by: 'Administrator',
module: 'Custom',
owner: 'Administrator',
modified: "2019-12-09 14:40:53.127615",
modified_by: "Administrator",
module: "Custom",
owner: "Administrator",
permissions: [
{
create: 1,
@ -36,13 +36,13 @@ export default {
email: 1,
print: 1,
read: 1,
role: 'System Manager',
role: "System Manager",
share: 1,
write: 1
}
write: 1,
},
],
quick_entry: 1,
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -10,18 +10,18 @@ export default {
engine: "InnoDB",
fields: [
{
"fieldname": "title",
"fieldtype": "Data",
"label": "Title",
"unique": 1
}
fieldname: "title",
fieldtype: "Data",
label: "Title",
unique: 1,
},
],
links: [
{
"group": "Child Doctype",
"link_doctype": "Doctype With Child Table",
"link_fieldname": "title"
}
group: "Child Doctype",
link_doctype: "Doctype With Child Table",
link_fieldname: "title",
},
],
modified: "2022-02-10 12:03:12.603763",
modified_by: "Administrator",
@ -34,12 +34,12 @@ export default {
email: 1,
print: 1,
read: 1,
role: 'System Manager',
role: "System Manager",
share: 1,
write: 1
}
write: 1,
},
],
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
};
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -12,21 +12,21 @@ export default {
fieldname: "title",
fieldtype: "Data",
label: "Title",
unique: 1
unique: 1,
},
{
fieldname: "child_table",
fieldtype: "Table",
label: "Child Table",
options: "Child Table Doctype",
reqd: 1
reqd: 1,
},
{
fieldname: "child_table_1",
fieldtype: "Table",
label: "Child Table 1",
options: "Child Table Doctype 1"
}
options: "Child Table Doctype 1",
},
],
links: [],
modified: "2022-02-10 12:03:12.603763",
@ -41,12 +41,12 @@ export default {
email: 1,
print: 1,
read: 1,
role: 'System Manager',
role: "System Manager",
share: 1,
write: 1
}
write: 1,
},
],
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -0,0 +1,46 @@
export default {
name: "Doctype With Phone",
actions: [],
custom: 1,
is_submittable: 1,
autoname: "field:title",
creation: "2022-03-30 06:29:07.215072",
doctype: "DocType",
engine: "InnoDB",
fields: [
{
fieldname: "title",
fieldtype: "Data",
label: "title",
unique: 1,
},
{
fieldname: "phone",
fieldtype: "Phone",
label: "Phone",
},
],
links: [],
modified: "2019-03-30 14:40:53.127615",
modified_by: "Administrator",
naming_rule: "By fieldname",
module: "Custom",
owner: "Administrator",
permissions: [
{
create: 1,
delete: 1,
email: 1,
print: 1,
read: 1,
role: "System Manager",
share: 1,
write: 1,
submit: 1,
cancel: 1,
},
],
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -1,39 +1,39 @@
export default {
name: 'Form With Tab Break',
name: "Form With Tab Break",
custom: 1,
actions: [],
doctype: 'DocType',
engine: 'InnoDB',
doctype: "DocType",
engine: "InnoDB",
fields: [
{
fieldname: 'username',
fieldtype: 'Data',
label: 'Name',
options: 'Name'
fieldname: "username",
fieldtype: "Data",
label: "Name",
options: "Name",
},
{
fieldname: 'tab',
fieldtype: 'Tab Break',
label: 'Tab 2',
fieldname: "tab",
fieldtype: "Tab Break",
label: "Tab 2",
},
{
fieldname: 'Phone',
fieldtype: 'Data',
label: 'Phone',
options: 'Phone',
reqd: 1
fieldname: "Phone",
fieldtype: "Data",
label: "Phone",
options: "Phone",
reqd: 1,
},
],
links: [
{
"group": "Profile",
"link_doctype": "Contact",
"link_fieldname": "user"
group: "Profile",
link_doctype: "Contact",
link_fieldname: "user",
},
],
modified_by: 'Administrator',
module: 'Custom',
owner: 'Administrator',
modified_by: "Administrator",
module: "Custom",
owner: "Administrator",
permissions: [
{
create: 1,
@ -41,14 +41,14 @@ export default {
email: 1,
print: 1,
read: 1,
role: 'System Manager',
role: "System Manager",
share: 1,
write: 1
}
write: 1,
},
],
quick_entry: 1,
autoname: "format: Test-{####}",
sort_field: 'modified',
sort_order: 'ASC',
track_changes: 1
sort_field: "modified",
sort_order: "ASC",
track_changes: 1,
};

View file

@ -1,42 +1,43 @@
context('API Resources', () => {
context("API Resources", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
it('Creates two Comments', () => {
cy.insert_doc('Comment', { comment_type: 'Comment', content: "hello" });
cy.insert_doc('Comment', { comment_type: 'Comment', content: "world" });
it("Creates two Comments", () => {
cy.insert_doc("Comment", { comment_type: "Comment", content: "hello" });
cy.insert_doc("Comment", { comment_type: "Comment", content: "world" });
});
it('Lists the Comments', () => {
cy.get_list('Comment')
.its('data')
.then(data => expect(data.length).to.be.at.least(2));
it("Lists the Comments", () => {
cy.get_list("Comment")
.its("data")
.then((data) => expect(data.length).to.be.at.least(2));
cy.get_list('Comment', ['name', 'content'], [['content', '=', 'hello']])
.then(body => {
expect(body).to.have.property('data');
expect(body.data).to.have.lengthOf(1);
expect(body.data[0]).to.have.property('content');
expect(body.data[0]).to.have.property('name');
});
cy.get_list("Comment", ["name", "content"], [["content", "=", "hello"]]).then((body) => {
expect(body).to.have.property("data");
expect(body.data).to.have.lengthOf(1);
expect(body.data[0]).to.have.property("content");
expect(body.data[0]).to.have.property("name");
});
});
it('Gets each Comment', () => {
cy.get_list('Comment').then(body => body.data.forEach(comment => {
cy.get_doc('Comment', comment.name);
}));
it("Gets each Comment", () => {
cy.get_list("Comment").then((body) =>
body.data.forEach((comment) => {
cy.get_doc("Comment", comment.name);
})
);
});
it('Removes the Comments', () => {
cy.get_list('Comment').then(body => {
it("Removes the Comments", () => {
cy.get_list("Comment").then((body) => {
let comment_names = [];
body.data.map(comment => comment_names.push(comment.name));
body.data.map((comment) => comment_names.push(comment.name));
comment_names = [...new Set(comment_names)]; // remove duplicates
comment_names.forEach((comment_name) => {
cy.remove_doc('Comment', comment_name);
cy.remove_doc("Comment", comment_name);
});
});
});

View file

@ -1,47 +1,57 @@
context('Awesome Bar', () => {
context("Awesome Bar", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
beforeEach(() => {
cy.get('.navbar .navbar-home').click();
cy.findByPlaceholderText('Search or type a command (Ctrl + G)').clear();
cy.get(".navbar .navbar-home").click();
cy.findByPlaceholderText("Search or type a command (Ctrl + G)").clear();
});
it('navigates to doctype list', () => {
cy.findByPlaceholderText('Search or type a command (Ctrl + G)').type('todo', { delay: 700 });
cy.get('.awesomplete').findByRole('listbox').should('be.visible');
cy.findByPlaceholderText('Search or type a command (Ctrl + G)').type('{enter}', { delay: 700 });
it("navigates to doctype list", () => {
cy.findByPlaceholderText("Search or type a command (Ctrl + G)").type("todo", {
delay: 700,
});
cy.get(".awesomplete").findByRole("listbox").should("be.visible");
cy.findByPlaceholderText("Search or type a command (Ctrl + G)").type("{enter}", {
delay: 700,
});
cy.get('.title-text').should('contain', 'To Do');
cy.get(".title-text").should("contain", "To Do");
cy.location('pathname').should('eq', '/app/todo');
cy.location("pathname").should("eq", "/app/todo");
});
it('find text in doctype list', () => {
cy.findByPlaceholderText('Search or type a command (Ctrl + G)')
.type('test in todo{enter}', { delay: 700 });
it("find text in doctype list", () => {
cy.findByPlaceholderText("Search or type a command (Ctrl + G)").type(
"test in todo{enter}",
{ delay: 700 }
);
cy.get('.title-text').should('contain', 'To Do');
cy.get(".title-text").should("contain", "To Do");
cy.findByPlaceholderText('Name')
.should('have.value', '%test%');
cy.findByPlaceholderText("ID").should("have.value", "%test%");
cy.clear_filters();
});
it('navigates to new form', () => {
cy.findByPlaceholderText('Search or type a command (Ctrl + G)')
.type('new blog post{enter}', { delay: 700 });
it("navigates to new form", () => {
cy.findByPlaceholderText("Search or type a command (Ctrl + G)").type(
"new blog post{enter}",
{ delay: 700 }
);
cy.get('.title-text:visible').should('have.text', 'New Blog Post');
cy.get(".title-text:visible").should("have.text", "New Blog Post");
});
it('calculates math expressions', () => {
cy.findByPlaceholderText('Search or type a command (Ctrl + G)')
.type('55 + 32{downarrow}{enter}', { delay: 700 });
it("calculates math expressions", () => {
cy.findByPlaceholderText("Search or type a command (Ctrl + G)").type(
"55 + 32{downarrow}{enter}",
{ delay: 700 }
);
cy.get('.modal-title').should('contain', 'Result');
cy.get('.msgprint').should('contain', '55 + 32 = 87');
cy.get(".modal-title").should("contain", "Result");
cy.get(".msgprint").should("contain", "55 + 32 = 87");
});
});

View file

@ -1,90 +1,95 @@
context('Attach Control', () => {
context("Attach Control", () => {
before(() => {
cy.login();
cy.visit('/app/doctype');
return cy.window().its('frappe').then(frappe => {
return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', {
name: 'Test Attach Control',
fields: [
{
"label": "Attach File or Image",
"fieldname": "attach",
"fieldtype": "Attach",
"in_list_view": 1,
},
]
cy.visit("/app/doctype");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.create_doctype", {
name: "Test Attach Control",
fields: [
{
label: "Attach File or Image",
fieldname: "attach",
fieldtype: "Attach",
in_list_view: 1,
},
],
});
});
});
});
it('Checking functionality for "Link" button in the "Attach" fieldtype', () => {
//Navigating to the new form for the newly created doctype
cy.new_form('Test Attach Control');
cy.new_form("Test Attach Control");
//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole('button', {name: 'Attach'}).click();
cy.findByRole("button", { name: "Attach" }).click();
//Clicking on "Link" button to attach a file using the "Link" button
cy.findByRole('button', {name: 'Link'}).click();
cy.findByPlaceholderText('Attach a web link').type('https://wallpaperplay.com/walls/full/8/2/b/72402.jpg');
cy.findByRole("button", { name: "Link" }).click();
cy.findByPlaceholderText("Attach a web link").type(
"https://wallpaperplay.com/walls/full/8/2/b/72402.jpg"
);
//Clicking on the Upload button to upload the file
cy.intercept("POST", "/api/method/upload_file").as("upload_image");
cy.get('.modal-footer').findByRole("button", {name: "Upload"}).click({delay: 500});
cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
cy.wait("@upload_image");
cy.findByRole('button', {name: 'Save'}).click();
cy.findByRole("button", { name: "Save" }).click();
//Checking if the URL of the attached image is getting displayed in the field of the newly created doctype
cy.get('.attached-file > .ellipsis > .attached-file-link')
.should('have.attr', 'href')
.and('equal', 'https://wallpaperplay.com/walls/full/8/2/b/72402.jpg');
cy.get(".attached-file > .ellipsis > .attached-file-link")
.should("have.attr", "href")
.and("equal", "https://wallpaperplay.com/walls/full/8/2/b/72402.jpg");
//Clicking on the "Clear" button
cy.get('[data-action="clear_attachment"]').click();
//Checking if clicking on the clear button clears the field of the doctype form and again displays the attach button
cy.get('.control-input > .btn-sm').should('contain', 'Attach');
cy.get(".control-input > .btn-sm").should("contain", "Attach");
//Deleting the doc
cy.go_to_list('Test Attach Control');
cy.get('.list-row-checkbox').eq(0).click();
cy.get('.actions-btn-group > .btn').contains('Actions').click();
cy.go_to_list("Test Attach Control");
cy.get(".list-row-checkbox").eq(0).click();
cy.get(".actions-btn-group > .btn").contains("Actions").click();
cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
cy.click_modal_primary_button('Yes');
cy.click_modal_primary_button("Yes");
});
it('Checking functionality for "Library" button in the "Attach" fieldtype', () => {
//Navigating to the new form for the newly created doctype
cy.new_form('Test Attach Control');
cy.new_form("Test Attach Control");
//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole('button', {name: 'Attach'}).click();
cy.findByRole("button", { name: "Attach" }).click();
//Clicking on "Library" button to attach a file using the "Library" button
cy.findByRole('button', {name: 'Library'}).click();
cy.contains('72402.jpg').click();
cy.findByRole("button", { name: "Library" }).click();
cy.contains("72402.jpg").click();
//Clicking on the Upload button to upload the file
cy.intercept("POST", "/api/method/upload_file").as("upload_image");
cy.get('.modal-footer').findByRole("button", {name: "Upload"}).click({delay: 500});
cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
cy.wait("@upload_image");
cy.findByRole('button', {name: 'Save'}).click();
cy.findByRole("button", { name: "Save" }).click();
//Checking if the URL of the attached image is getting displayed in the field of the newly created doctype
cy.get('.attached-file > .ellipsis > .attached-file-link')
.should('have.attr', 'href')
.and('equal', 'https://wallpaperplay.com/walls/full/8/2/b/72402.jpg');
cy.get(".attached-file > .ellipsis > .attached-file-link")
.should("have.attr", "href")
.and("equal", "https://wallpaperplay.com/walls/full/8/2/b/72402.jpg");
//Clicking on the "Clear" button
cy.get('[data-action="clear_attachment"]').click();
//Checking if clicking on the clear button clears the field of the doctype form and again displays the attach button
cy.get('.control-input > .btn-sm').should('contain', 'Attach');
cy.get(".control-input > .btn-sm").should("contain", "Attach");
//Deleting the doc
cy.go_to_list('Test Attach Control');
cy.get('.list-row-checkbox').eq(0).click();
cy.get('.actions-btn-group > .btn').contains('Actions').click();
cy.go_to_list("Test Attach Control");
cy.get(".list-row-checkbox").eq(0).click();
cy.get(".actions-btn-group > .btn").contains("Actions").click();
cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
cy.click_modal_primary_button('Yes');
cy.click_modal_primary_button("Yes");
});
});
});

View file

@ -1,57 +1,64 @@
context('Control Autocomplete', () => {
context("Control Autocomplete", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
function get_dialog_with_autocomplete(options) {
cy.visit('/app/website');
cy.visit("/app/website");
return cy.dialog({
title: 'Autocomplete',
title: "Autocomplete",
fields: [
{
'label': 'Select an option',
'fieldname': 'autocomplete',
'fieldtype': 'Autocomplete',
'options': options || ['Option 1', 'Option 2', 'Option 3'],
}
]
label: "Select an option",
fieldname: "autocomplete",
fieldtype: "Autocomplete",
options: options || ["Option 1", "Option 2", "Option 3"],
},
],
});
}
it('should set the valid value', () => {
get_dialog_with_autocomplete().as('dialog');
it("should set the valid value", () => {
get_dialog_with_autocomplete().as("dialog");
cy.get('.frappe-control[data-fieldname=autocomplete] input').focus().as('input');
cy.get(".frappe-control[data-fieldname=autocomplete] input").focus().as("input");
cy.wait(1000);
cy.get('@input').type('2', { delay: 300 });
cy.get('.frappe-control[data-fieldname=autocomplete]').findByRole('listbox').should('be.visible');
cy.get('.frappe-control[data-fieldname=autocomplete] input').type('{enter}', { delay: 300 });
cy.get('.frappe-control[data-fieldname=autocomplete] input').blur();
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('autocomplete');
expect(value).to.eq('Option 2');
cy.get("@input").type("2", { delay: 300 });
cy.get(".frappe-control[data-fieldname=autocomplete]")
.findByRole("listbox")
.should("be.visible");
cy.get(".frappe-control[data-fieldname=autocomplete] input").type("{enter}", {
delay: 300,
});
cy.get(".frappe-control[data-fieldname=autocomplete] input").blur();
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("autocomplete");
expect(value).to.eq("Option 2");
dialog.clear();
});
});
it('should set the valid value with different label', () => {
it("should set the valid value with different label", () => {
const options_with_label = [
{ label: "Option 1", value: "option_1" },
{ label: "Option 2", value: "option_2" }
{ label: "Option 2", value: "option_2" },
];
get_dialog_with_autocomplete(options_with_label).as('dialog');
get_dialog_with_autocomplete(options_with_label).as("dialog");
cy.get('.frappe-control[data-fieldname=autocomplete] input').focus().as('input');
cy.get('.frappe-control[data-fieldname=autocomplete]').findByRole('listbox').should('be.visible');
cy.get('@input').type('2', { delay: 300 });
cy.get('.frappe-control[data-fieldname=autocomplete] input').type('{enter}', { delay: 300 });
cy.get('.frappe-control[data-fieldname=autocomplete] input').blur();
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('autocomplete');
expect(value).to.eq('option_2');
cy.get(".frappe-control[data-fieldname=autocomplete] input").focus().as("input");
cy.get(".frappe-control[data-fieldname=autocomplete]")
.findByRole("listbox")
.should("be.visible");
cy.get("@input").type("2", { delay: 300 });
cy.get(".frappe-control[data-fieldname=autocomplete] input").type("{enter}", {
delay: 300,
});
cy.get(".frappe-control[data-fieldname=autocomplete] input").blur();
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("autocomplete");
expect(value).to.eq("option_2");
dialog.clear();
});
});
});

View file

@ -1,53 +1,57 @@
context('Control Barcode', () => {
context("Control Barcode", () => {
beforeEach(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
function get_dialog_with_barcode() {
return cy.dialog({
title: 'Barcode',
title: "Barcode",
fields: [
{
label: 'Barcode',
fieldname: 'barcode',
fieldtype: 'Barcode'
}
]
label: "Barcode",
fieldname: "barcode",
fieldtype: "Barcode",
},
],
});
}
it('should generate barcode on setting a value', () => {
get_dialog_with_barcode().as('dialog');
it("should generate barcode on setting a value", () => {
get_dialog_with_barcode().as("dialog");
cy.get('.frappe-control[data-fieldname=barcode]').findByRole('textbox')
.type('123456789')
cy.focused().blur();
cy.get(".frappe-control[data-fieldname=barcode]")
.findByRole("textbox")
.type("123456789")
.blur();
cy.get('.frappe-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]')
.should('exist');
cy.get(
'.frappe-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]'
).should("exist");
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('barcode');
expect(value).to.contain('<svg');
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("barcode");
expect(value).to.contain("<svg");
expect(value).to.contain('data-barcode-value="123456789"');
});
});
it('should reset when input is cleared', () => {
get_dialog_with_barcode().as('dialog');
it("should reset when input is cleared", () => {
get_dialog_with_barcode().as("dialog");
cy.get('.frappe-control[data-fieldname=barcode]').findByRole('textbox')
.type('123456789')
cy.focused().blur();
cy.get(".frappe-control[data-fieldname=barcode]")
.findByRole("textbox")
.type("123456789")
.blur();
cy.get('.frappe-control[data-fieldname=barcode]').findByRole('textbox')
.clear()
.blur();
cy.get('.frappe-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]')
.should('not.exist');
cy.get(".frappe-control[data-fieldname=barcode]").findByRole("textbox").clear().blur();
cy.get(
'.frappe-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]'
).should("not.exist");
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('barcode');
expect(value).to.equal('');
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("barcode");
expect(value).to.equal("");
});
});
});

View file

@ -0,0 +1,80 @@
context("Control Color", () => {
before(() => {
cy.login();
cy.visit("/app/website");
});
function get_dialog_with_color() {
return cy.dialog({
title: "Color",
fields: [
{
label: "Color",
fieldname: "color",
fieldtype: "Color",
},
],
});
}
it("Verifying if the color control is selecting correct", () => {
get_dialog_with_color().as("dialog");
cy.findByPlaceholderText("Choose a color").click();
///Selecting a color from the color palette
cy.get('[style="background-color: rgb(79, 157, 217);"]').click();
//Checking if the css attribute is correct
cy.get(".color-map").should("have.css", "color", "rgb(79, 157, 217)");
cy.get(".hue-map").should("have.css", "color", "rgb(0, 145, 255)");
//Checking if the correct color is being selected
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("color");
expect(value).to.equal("#4F9DD9");
});
//Selecting a color
cy.get('[style="background-color: rgb(203, 41, 41);"]').click();
//Checking if the correct css is being selected
cy.get(".color-map").should("have.css", "color", "rgb(203, 41, 41)");
cy.get(".hue-map").should("have.css", "color", "rgb(255, 0, 0)");
//Checking if the correct color is being selected
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("color");
expect(value).to.equal("#CB2929");
});
//Selecting color from the palette
cy.get(".color-map > .color-selector").click(65, 87, { force: true });
cy.get(".color-map").should("have.css", "color", "rgb(56, 0, 0)");
//Checking if the expected color is selected and getting displayed
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("color");
expect(value).to.equal("#380000");
});
//Selecting the color from the hue map
cy.get(".hue-map > .hue-selector").click(35, -1, { force: true });
cy.get(".color-map").should("have.css", "color", "rgb(56, 45, 0)");
cy.get(".hue-map").should("have.css", "color", "rgb(255, 204, 0)");
cy.get(".color-map > .color-selector").click(55, 12, { force: true });
cy.get(".color-map").should("have.css", "color", "rgb(46, 37, 0)");
//Checking if the correct color is being displayed
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("color");
expect(value).to.equal("#2e2500");
});
//Clearing the field and checking if the field contains the placeholder "Choose a color"
cy.get(".input-with-feedback").click({ force: true });
cy.get_field("color", "Color").type("{selectall}").clear();
cy.get_field("color", "Color")
.invoke("attr", "placeholder")
.should("contain", "Choose a color");
});
});

View file

@ -0,0 +1,145 @@
context("Data Control", () => {
before(() => {
cy.login();
cy.visit("/app/doctype");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.create_doctype", {
name: "Test Data Control",
fields: [
{
label: "Name",
fieldname: "name1",
fieldtype: "Data",
options: "Name",
in_list_view: 1,
reqd: 1,
},
{
label: "Email-ID",
fieldname: "email",
fieldtype: "Data",
options: "Email",
in_list_view: 1,
reqd: 1,
},
{
label: "Phone No.",
fieldname: "phone",
fieldtype: "Data",
options: "Phone",
in_list_view: 1,
reqd: 1,
},
],
});
});
});
it("check custom formatters", () => {
cy.visit(`/app/doctype/User`);
cy.get(
'[data-fieldname="fields"] .grid-row[data-idx="2"] [data-fieldname="fieldtype"] .static-area'
).should("have.text", "🔵 Section Break");
});
it('Verifying data control by inputting different patterns for "Name" field', () => {
cy.new_form("Test Data Control");
//Checking the URL for the new form of the doctype
cy.location("pathname").should("eq", "/app/test-data-control/new-test-data-control-1");
cy.get(".title-text").should("have.text", "New Test Data Control");
cy.get('.frappe-control[data-fieldname="name1"]')
.find("label")
.should("have.class", "reqd");
cy.get('.frappe-control[data-fieldname="email"]')
.find("label")
.should("have.class", "reqd");
cy.get('.frappe-control[data-fieldname="phone"]')
.find("label")
.should("have.class", "reqd");
//Checking if the status is "Not Saved" initially
cy.get(".indicator-pill").should("have.text", "Not Saved");
//Inputting data in the field
cy.fill_field("name1", "@@###", "Data");
cy.fill_field("email", "test@example.com", "Data");
cy.fill_field("phone", "9834280031", "Data");
//Checking if the border color of the field changes to red
cy.get('.frappe-control[data-fieldname="name1"]').should("have.class", "has-error");
cy.save();
//Checking for the error message
cy.get(".modal-title").should("have.text", "Message");
cy.get(".msgprint").should("have.text", "@@### is not a valid Name");
cy.hide_dialog();
cy.get_field("name1", "Data").clear({ force: true });
cy.fill_field("name1", "Komal{}/!", "Data");
cy.get('.frappe-control[data-fieldname="name1"]').should("have.class", "has-error");
cy.save();
cy.get(".modal-title").should("have.text", "Message");
cy.get(".msgprint").should("have.text", "Komal{}/! is not a valid Name");
cy.hide_dialog();
});
it('Verifying data control by inputting different patterns for "Email" field', () => {
cy.get_field("name1", "Data").clear({ force: true });
cy.fill_field("name1", "Komal", "Data");
cy.get_field("email", "Data").clear({ force: true });
cy.fill_field("email", "komal", "Data");
cy.get('.frappe-control[data-fieldname="email"]').should("have.class", "has-error");
cy.save();
cy.get(".modal-title").should("have.text", "Message");
cy.get(".msgprint").should("have.text", "komal is not a valid Email Address");
cy.hide_dialog();
cy.get_field("email", "Data").clear({ force: true });
cy.fill_field("email", "komal@test", "Data");
cy.get('.frappe-control[data-fieldname="email"]').should("have.class", "has-error");
cy.save();
cy.get(".modal-title").should("have.text", "Message");
cy.get(".msgprint").should("have.text", "komal@test is not a valid Email Address");
cy.hide_dialog();
});
it('Verifying data control by inputting different patterns for "Phone" field', () => {
cy.get_field("email", "Data").clear({ force: true });
cy.fill_field("email", "komal@test.com", "Data");
cy.get_field("phone", "Data").clear({ force: true });
cy.fill_field("phone", "komal", "Data");
cy.get('.frappe-control[data-fieldname="phone"]').should("have.class", "has-error");
cy.findByRole("button", { name: "Save" }).click({ force: true });
cy.get(".modal-title").should("have.text", "Message");
cy.get(".msgprint").should("have.text", "komal is not a valid Phone Number");
cy.hide_dialog();
});
it("Inputting correct data and saving the doc", () => {
//Inputting the data as expected and saving the document
cy.get_field("name1", "Data").clear({ force: true });
cy.get_field("email", "Data").clear({ force: true });
cy.get_field("phone", "Data").clear({ force: true });
cy.fill_field("name1", "Komal", "Data");
cy.fill_field("email", "komal@test.com", "Data");
cy.fill_field("phone", "9432380001", "Data");
cy.findByRole("button", { name: "Save" }).click({ force: true });
//Checking if the fields contains the data which has been filled in
cy.location("pathname").should("not.be", "/app/test-data-control/new-test-data-control-1");
cy.get_field("name1").should("have.value", "Komal");
cy.get_field("email").should("have.value", "komal@test.com");
cy.get_field("phone").should("have.value", "9432380001");
});
it("Deleting the doc", () => {
//Deleting the inserted document
cy.go_to_list("Test Data Control");
cy.get(".list-row-checkbox").eq(0).click({ force: true });
cy.get(".actions-btn-group > .btn").contains("Actions").click();
cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
cy.click_modal_primary_button("Yes");
});
});

View file

@ -1,71 +1,89 @@
context('Date Control', () => {
context("Date Control", () => {
before(() => {
cy.login();
cy.visit('/app/doctype');
return cy.window().its('frappe').then(frappe => {
return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', {
name: 'Test Date Control',
fields: [
{
"label": "Date",
"fieldname": "date",
"fieldtype": "Date",
"in_list_view": 1
},
]
});
});
cy.visit("/app");
});
it('Selecting a date from the datepicker', () => {
cy.new_form('Test Date Control');
cy.get_field('date', 'Date').click();
cy.get('.datepicker--nav-title').click();
cy.get('.datepicker--nav-title').click({force: true});
function get_dialog(date_field_options) {
return cy.dialog({
title: "Date",
fields: [
{
label: "Date",
fieldname: "date",
fieldtype: "Date",
in_list_view: 1,
...date_field_options,
},
],
});
}
it("Selecting a date from the datepicker", () => {
cy.clear_dialogs();
cy.clear_datepickers();
get_dialog().as("dialog");
cy.get_field("date", "Date").click();
cy.get(".datepicker--nav-title").click();
cy.get(".datepicker--nav-title").click({ force: true });
//Inputing values in the date field
cy.get('.datepicker--years > .datepicker--cells > .datepicker--cell[data-year=2020]').click();
cy.get('.datepicker--months > .datepicker--cells > .datepicker--cell[data-month=0]').click();
cy.get('.datepicker--days > .datepicker--cells > .datepicker--cell[data-date=15]').click();
cy.get(
".datepicker--years > .datepicker--cells > .datepicker--cell[data-year=2020]"
).click();
cy.get(
".datepicker--months > .datepicker--cells > .datepicker--cell[data-month=0]"
).click();
cy.get(".datepicker--days > .datepicker--cells > .datepicker--cell[data-date=15]").click();
//Verifying if the selected date is displayed in the date field
cy.get_field('date', 'Date').should('have.value', '01-15-2020');
// Verify if the selected date is set the date field
cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-01-15");
});
it('Checking next and previous button', () => {
cy.get_field('date', 'Date').click();
it("Checking next and previous button", () => {
cy.clear_dialogs();
cy.clear_datepickers();
get_dialog({ default: "2020-01-15" }).as("dialog");
cy.get_field("date", "Date").click();
//Clicking on the next button in the datepicker
cy.get('.datepicker--nav-action[data-action=next]').click();
cy.get(".datepicker--nav-action[data-action=next]").click();
//Selecting a date from the datepicker
cy.get('.datepicker--cell[data-date=15]').click({force: true});
cy.get(".datepicker--cell[data-date=15]").click({ force: true });
//Verifying if the selected date has been displayed in the date field
cy.get_field('date', 'Date').should('have.value', '02-15-2020');
cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-02-15");
cy.wait(500);
cy.get_field('date', 'Date').click();
cy.get_field("date", "Date").click();
//Clicking on the previous button in the datepicker
cy.get('.datepicker--nav-action[data-action=prev]').click();
cy.get(".datepicker--nav-action[data-action=prev]").click();
//Selecting a date from the datepicker
cy.get('.datepicker--cell[data-date=15]').click({force: true});
cy.get(".datepicker--cell[data-date=15]").click({ force: true });
//Verifying if the selected date has been displayed in the date field
cy.get_field('date', 'Date').should('have.value', '01-15-2020');
cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-01-15");
});
it('Clicking on "Today" button gives todays date', () => {
cy.get_field('date', 'Date').click();
cy.clear_dialogs();
cy.clear_datepickers();
get_dialog().as("dialog");
cy.get_field("date", "Date").click();
//Clicking on "Today" button
cy.get('.datepicker--button').click();
//Picking up the todays date
const todays_date = Cypress.moment().format('MM-DD-YYYY');
cy.get(".datepicker--button").click();
//Verifying if clicking on "Today" button matches today's date
cy.get_field('date', 'Date').should('have.value', todays_date);
cy.window().then((win) => {
expect(win.cur_dialog.fields_dict.date.value).to.be.equal(
win.frappe.datetime.get_today()
);
});
});
});
});

View file

@ -0,0 +1,48 @@
context("Date Range Control", () => {
before(() => {
cy.login();
cy.visit("/app");
});
function get_dialog() {
return cy.dialog({
title: "Date Range",
fields: [
{
label: "Date Range",
fieldname: "date_range",
fieldtype: "Date Range",
},
],
});
}
it("Selecting a date range from the datepicker", () => {
cy.clear_dialogs();
cy.clear_datepickers();
get_dialog().as("dialog");
cy.get_field("date_range", "Date Range").click();
cy.get(".datepicker--nav-title").click();
cy.get(".datepicker--nav-title").click({ force: true });
//Inputing date range values in the date range field
cy.get(
".datepicker--years > .datepicker--cells > .datepicker--cell[data-year=2020]"
).click();
cy.get(
".datepicker--months > .datepicker--cells > .datepicker--cell[data-month=0]"
).click();
cy.get(".datepicker--cell[data-date=1]:first").click({ force: true });
cy.get(".datepicker--cell[data-date=15]:first").click({ force: true });
// Verify if the selected date range values is set in the date range field
cy.window()
.its("cur_dialog")
.then((dialog) => {
let date_range = dialog.get_value("date_range");
expect(date_range[0]).to.equal("2020-01-01");
expect(date_range[1]).to.equal("2020-01-15");
});
});
});

View file

@ -1,46 +1,46 @@
context('Control Duration', () => {
context("Control Duration", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
function get_dialog_with_duration(hide_days = 0, hide_seconds = 0) {
return cy.dialog({
title: 'Duration',
fields: [{
'fieldname': 'duration',
'fieldtype': 'Duration',
'hide_days': hide_days,
'hide_seconds': hide_seconds
}]
title: "Duration",
fields: [
{
fieldname: "duration",
fieldtype: "Duration",
hide_days: hide_days,
hide_seconds: hide_seconds,
},
],
});
}
it('should set duration', () => {
get_dialog_with_duration().as('dialog');
cy.get('.frappe-control[data-fieldname=duration] input')
.first()
.click();
cy.get('.duration-input[data-duration=days]')
it("should set duration", () => {
get_dialog_with_duration().as("dialog");
cy.get(".frappe-control[data-fieldname=duration] input").first().click();
cy.get(".duration-input[data-duration=days]")
.type(45, { force: true })
.blur({ force: true });
cy.get('.duration-input[data-duration=minutes]')
.type(30)
.blur({ force: true });
cy.get('.frappe-control[data-fieldname=duration] input').first().should('have.value', '45d 30m');
cy.get('.frappe-control[data-fieldname=duration] input').first().blur();
cy.get('.duration-picker').should('not.be.visible');
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('duration');
cy.get(".duration-input[data-duration=minutes]").type(30).blur({ force: true });
cy.get(".frappe-control[data-fieldname=duration] input")
.first()
.should("have.value", "45d 30m");
cy.get(".frappe-control[data-fieldname=duration] input").first().blur();
cy.get(".duration-picker").should("not.be.visible");
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("duration");
expect(value).to.equal(3889800);
cy.hide_dialog();
});
});
it('should hide days or seconds according to duration options', () => {
get_dialog_with_duration(1, 1).as('dialog');
cy.get('.frappe-control[data-fieldname=duration] input').first();
cy.get('.duration-input[data-duration=days]').should('not.be.visible');
cy.get('.duration-input[data-duration=seconds]').should('not.be.visible');
it("should hide days or seconds according to duration options", () => {
get_dialog_with_duration(1, 1).as("dialog");
cy.get(".frappe-control[data-fieldname=duration] input").first();
cy.get(".duration-input[data-duration=days]").should("not.be.visible");
cy.get(".duration-input[data-duration=seconds]").should("not.be.visible");
});
});
});

View file

@ -1,128 +1,159 @@
context('Dynamic Link', () => {
context("Dynamic Link", () => {
before(() => {
cy.login();
cy.visit('/app/doctype');
return cy.window().its('frappe').then(frappe => {
return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', {
name: 'Test Dynamic Link',
fields: [
{
"label": "Document Type",
"fieldname": "doc_type",
"fieldtype": "Link",
"options": "DocType",
"in_list_view": 1,
"in_standard_filter": 1,
},
{
"label": "Document ID",
"fieldname": "doc_id",
"fieldtype": "Dynamic Link",
"options": "doc_type",
"in_list_view": 1,
"in_standard_filter": 1,
},
]
cy.visit("/app/doctype");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.create_doctype", {
name: "Test Dynamic Link",
fields: [
{
label: "Document Type",
fieldname: "doc_type",
fieldtype: "Link",
options: "DocType",
in_list_view: 1,
in_standard_filter: 1,
},
{
label: "Document ID",
fieldname: "doc_id",
fieldtype: "Dynamic Link",
options: "doc_type",
in_list_view: 1,
in_standard_filter: 1,
},
],
});
});
});
});
function get_dialog_with_dynamic_link() {
return cy.dialog({
title: 'Dynamic Link',
fields: [{
"label": "Document Type",
"fieldname": "doc_type",
"fieldtype": "Link",
"options": "DocType",
"in_list_view": 1,
},
{
"label": "Document ID",
"fieldname": "doc_id",
"fieldtype": "Dynamic Link",
"options": "doc_type",
"in_list_view": 1,
}]
title: "Dynamic Link",
fields: [
{
label: "Document Type",
fieldname: "doc_type",
fieldtype: "Link",
options: "DocType",
in_list_view: 1,
},
{
label: "Document ID",
fieldname: "doc_id",
fieldtype: "Dynamic Link",
options: "doc_type",
in_list_view: 1,
},
],
});
}
function get_dialog_with_dynamic_link_option() {
return cy.dialog({
title: 'Dynamic Link',
fields: [{
"label": "Document Type",
"fieldname": "doc_type",
"fieldtype": "Link",
"options": "DocType",
"in_list_view": 1,
},
{
"label": "Document ID",
"fieldname": "doc_id",
"fieldtype": "Dynamic Link",
"get_options": () => {
return "User";
title: "Dynamic Link",
fields: [
{
label: "Document Type",
fieldname: "doc_type",
fieldtype: "Link",
options: "DocType",
in_list_view: 1,
},
"in_list_view": 1,
}]
{
label: "Document ID",
fieldname: "doc_id",
fieldtype: "Dynamic Link",
get_options: () => {
return "User";
},
in_list_view: 1,
},
],
});
}
it('Creating a dynamic link by passing option as function and verifying it in a dialog', () => {
get_dialog_with_dynamic_link_option().as('dialog');
cy.get_field('doc_type').clear();
cy.fill_field('doc_type', 'User', 'Link');
cy.get_field('doc_id').click();
it("Creating a dynamic link by passing option as function and verifying it in a dialog", () => {
get_dialog_with_dynamic_link_option().as("dialog");
cy.get_field("doc_type").clear();
cy.fill_field("doc_type", "User", "Link");
cy.get_field("doc_id").click();
//Checking if the listbox have length greater than 0
cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
cy.get('.btn-modal-close').click({force: true});
cy.get('[data-fieldname="doc_id"]')
.find(".awesomplete")
.find("li")
.its("length")
.should("be.gte", 0);
cy.get(".btn-modal-close").click({ force: true });
});
it('Creating a dynamic link and verifying it in a dialog', () => {
get_dialog_with_dynamic_link().as('dialog');
cy.get_field('doc_type').clear();
cy.fill_field('doc_type', 'User', 'Link');
cy.get_field('doc_id').click();
it("Creating a dynamic link and verifying it in a dialog", () => {
get_dialog_with_dynamic_link().as("dialog");
cy.get_field("doc_type").clear();
cy.fill_field("doc_type", "User", "Link");
cy.get_field("doc_id").click();
//Checking if the listbox have length greater than 0
cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
cy.get('.btn-modal-close').click({force: true, multiple: true});
cy.get('[data-fieldname="doc_id"]')
.find(".awesomplete")
.find("li")
.its("length")
.should("be.gte", 0);
cy.get(".btn-modal-close").click({ force: true, multiple: true });
});
it('Creating a dynamic link and verifying it', () => {
cy.visit('/app/test-dynamic-link');
it("Creating a dynamic link and verifying it", () => {
cy.visit("/app/test-dynamic-link");
//Clicking on the Document ID field
cy.get_field('doc_type').clear();
cy.get_field("doc_type").clear();
//Entering User in the Doctype field
cy.fill_field('doc_type', 'User', 'Link', {delay: 500});
cy.get_field('doc_id').click();
cy.fill_field("doc_type", "User", "Link", { delay: 500 });
cy.get_field("doc_id").click();
//Checking if the listbox have length greater than 0
cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
cy.get('[data-fieldname="doc_id"]')
.find(".awesomplete")
.find("li")
.its("length")
.should("be.gte", 0);
//Opening a new form for dynamic link doctype
cy.new_form('Test Dynamic Link');
cy.get_field('doc_type').clear();
cy.new_form("Test Dynamic Link");
cy.get_field("doc_type").clear();
//Entering User in the Doctype field
cy.fill_field('doc_type', 'User', 'Link', {delay: 500});
cy.get_field('doc_id').click();
cy.fill_field("doc_type", "User", "Link", { delay: 500 });
cy.get_field("doc_id").click();
//Checking if the listbox have length greater than 0
cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
cy.get_field('doc_type').clear();
cy.get('[data-fieldname="doc_id"]')
.find(".awesomplete")
.find("li")
.its("length")
.should("be.gte", 0);
cy.get_field("doc_type").clear();
//Entering System Settings in the Doctype field
cy.fill_field('doc_type', 'System Settings', 'Link', {delay: 500});
cy.get_field('doc_id').click();
cy.intercept("/api/method/frappe.desk.search.search_link").as("search_query");
cy.fill_field("doc_type", "System Settings", "Link", { delay: 500 });
cy.wait("@search_query");
cy.get(`[data-fieldname="doc_type"] ul:visible li:first-child`).click({
scrollBehavior: false,
});
cy.get_field("doc_id").click();
//Checking if the system throws error
cy.get('.modal-title').should('have.text', 'Error');
cy.get('.msgprint').should('have.text', 'System Settings is not a valid DocType for Dynamic Link');
cy.get(".modal-title").should("have.text", "Error");
cy.get(".msgprint").should(
"have.text",
"System Settings is not a valid DocType for Dynamic Link"
);
});
});
});

View file

@ -11,9 +11,9 @@ context("Control Float", () => {
{
fieldname: "float_number",
fieldtype: "Float",
Label: "Float"
}
]
Label: "Float",
},
],
});
}
@ -21,27 +21,21 @@ context("Control Float", () => {
get_dialog_with_float().as("dialog");
let data = get_data();
data.forEach(x => {
data.forEach((x) => {
cy.window()
.its("frappe")
.then(frappe => {
.then((frappe) => {
frappe.boot.sysdefaults.number_format = x.number_format;
});
x.values.forEach(d => {
x.values.forEach((d) => {
cy.get_field("float_number", "Float").clear();
cy.fill_field("float_number", d.input, "Float").blur();
cy.get_field("float_number", "Float").should(
"have.value",
d.blur_expected
);
cy.get_field("float_number", "Float").should("have.value", d.blur_expected);
cy.get_field("float_number", "Float").focus();
cy.get_field("float_number", "Float").blur();
cy.get_field("float_number", "Float").focus();
cy.get_field("float_number", "Float").should(
"have.value",
d.focus_expected
);
cy.get_field("float_number", "Float").should("have.value", d.focus_expected);
});
});
});
@ -54,19 +48,19 @@ context("Control Float", () => {
{
input: "364.87,334",
blur_expected: "36.487,334",
focus_expected: "36487.334"
focus_expected: "36487.334",
},
{
input: "36487,334",
blur_expected: "36.487,334",
focus_expected: "36487.334"
focus_expected: "36487.334",
},
{
input: "100",
blur_expected: "100,000",
focus_expected: "100"
}
]
focus_expected: "100",
},
],
},
{
number_format: "#,###.##",
@ -74,20 +68,20 @@ context("Control Float", () => {
{
input: "364,87.334",
blur_expected: "36,487.334",
focus_expected: "36487.334"
focus_expected: "36487.334",
},
{
input: "36487.334",
blur_expected: "36,487.334",
focus_expected: "36487.334"
focus_expected: "36487.334",
},
{
input: "100",
blur_expected: "100.000",
focus_expected: "100"
}
]
}
focus_expected: "100",
},
],
},
];
}
});

View file

@ -1,50 +1,55 @@
context('Control Icon', () => {
context("Control Icon", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
function get_dialog_with_icon() {
return cy.dialog({
title: 'Icon',
fields: [{
label: 'Icon',
fieldname: 'icon',
fieldtype: 'Icon'
}]
title: "Icon",
fields: [
{
label: "Icon",
fieldname: "icon",
fieldtype: "Icon",
},
],
});
}
it('should set icon', () => {
get_dialog_with_icon().as('dialog');
cy.get('.frappe-control[data-fieldname=icon]').findByRole('textbox').click();
it("should set icon", () => {
get_dialog_with_icon().as("dialog");
cy.get(".frappe-control[data-fieldname=icon]").findByRole("textbox").click();
cy.get('.icon-picker .icon-wrapper[id=heart-active]').first().click();
cy.get('.frappe-control[data-fieldname=icon]').findByRole('textbox').should('have.value', 'heart-active');
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('icon');
expect(value).to.equal('heart-active');
cy.get(".icon-picker .icon-wrapper[id=heart-active]").first().click();
cy.get(".frappe-control[data-fieldname=icon]")
.findByRole("textbox")
.should("have.value", "heart-active");
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("icon");
expect(value).to.equal("heart-active");
});
cy.get('.icon-picker .icon-wrapper[id=heart]').first().click();
cy.get('.frappe-control[data-fieldname=icon]').findByRole('textbox').should('have.value', 'heart');
cy.get('@dialog').then(dialog => {
let value = dialog.get_value('icon');
expect(value).to.equal('heart');
cy.get(".icon-picker .icon-wrapper[id=heart]").first().click();
cy.get(".frappe-control[data-fieldname=icon]")
.findByRole("textbox")
.should("have.value", "heart");
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("icon");
expect(value).to.equal("heart");
});
});
it('search for icon and clear search input', () => {
let search_text = 'ed';
cy.get('.icon-picker').findByRole('searchbox').click().type(search_text);
cy.get('.icon-section .icon-wrapper:not(.hidden)').then(i => {
cy.get(`.icon-section .icon-wrapper[id*='${search_text}']`).then(icons => {
it("search for icon and clear search input", () => {
let search_text = "ed";
cy.get(".icon-picker").findByRole("searchbox").click().type(search_text);
cy.get(".icon-section .icon-wrapper:not(.hidden)").then((i) => {
cy.get(`.icon-section .icon-wrapper[id*='${search_text}']`).then((icons) => {
expect(i.length).to.equal(icons.length);
});
});
cy.get('.icon-picker').findByRole('searchbox').clear().blur();
cy.get('.icon-section .icon-wrapper').should('not.have.class', 'hidden');
cy.get(".icon-picker").findByRole("searchbox").clear().blur();
cy.get(".icon-section .icon-wrapper").should("not.have.class", "hidden");
});
});
});

View file

@ -1,61 +1,101 @@
context('Control Link', () => {
context("Control Link", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
beforeEach(() => {
cy.visit('/app/website');
cy.visit("/app/website");
cy.create_records({
doctype: 'ToDo',
description: 'this is a test todo for link'
}).as('todos');
doctype: "ToDo",
description: "this is a test todo for link",
}).as("todos");
});
function get_dialog_with_link() {
return cy.dialog({
title: 'Link',
title: "Link",
fields: [
{
'label': 'Select ToDo',
'fieldname': 'link',
'fieldtype': 'Link',
'options': 'ToDo'
}
]
label: "Select ToDo",
fieldname: "link",
fieldtype: "Link",
options: "ToDo",
},
],
});
}
it('should set the valid value', () => {
get_dialog_with_link().as('dialog');
function get_dialog_with_user_link() {
return cy.dialog({
title: "Link",
fields: [
{
label: "Select User",
fieldname: "link",
fieldtype: "Link",
options: "User",
},
],
});
}
cy.intercept('POST', '/api/method/frappe.desk.search.search_link').as('search_link');
it("should set the valid value", () => {
get_dialog_with_link().as("dialog");
cy.get('.frappe-control[data-fieldname=link] input').focus().as('input');
cy.wait('@search_link');
cy.get('@input').type('todo for link', { delay: 200 });
cy.wait('@search_link');
cy.get('.frappe-control[data-fieldname=link]').findByRole('listbox').should('be.visible');
cy.get('.frappe-control[data-fieldname=link] input').type('{enter}', { delay: 100 });
cy.get('.frappe-control[data-fieldname=link] input').blur();
cy.get('@dialog').then(dialog => {
cy.get('@todos').then(todos => {
let value = dialog.get_value('link');
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "User",
property: "translate_link_fields",
property_type: "Check",
doctype_or_field: "DocType",
value: "0",
},
true
);
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "ToDo",
property: "show_title_field_in_link",
property_type: "Check",
doctype_or_field: "DocType",
value: "0",
},
true
);
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.get(".frappe-control[data-fieldname=link] input").focus().as("input");
cy.wait("@search_link");
cy.get("@input").type("todo for link", { delay: 200 });
cy.wait("@search_link");
cy.get(".frappe-control[data-fieldname=link]").findByRole("listbox").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
cy.get("@dialog").then((dialog) => {
cy.get("@todos").then((todos) => {
let value = dialog.get_value("link");
expect(value).to.eq(todos[0]);
});
});
});
it('should unset invalid value', () => {
get_dialog_with_link().as('dialog');
it("should unset invalid value", () => {
get_dialog_with_link().as("dialog");
cy.intercept('POST', '/api/method/frappe.client.validate_link').as('validate_link');
cy.intercept("POST", "/api/method/frappe.client.validate_link").as("validate_link");
cy.get('.frappe-control[data-fieldname=link] input')
.type('invalid value', { delay: 100 })
cy.get(".frappe-control[data-fieldname=link] input")
.type("invalid value", { delay: 100 })
.blur();
cy.wait('@validate_link');
cy.get('.frappe-control[data-fieldname=link] input').should('have.value', '');
cy.wait("@validate_link");
cy.get(".frappe-control[data-fieldname=link] input").should("have.value", "");
});
it("should be possible set empty value explicitly", () => {
@ -63,155 +103,325 @@ context('Control Link', () => {
cy.intercept("POST", "/api/method/frappe.client.validate_link").as("validate_link");
cy.get(".frappe-control[data-fieldname=link] input")
.type(" ", { delay: 100 })
.blur();
cy.get(".frappe-control[data-fieldname=link] input").type(" ", { delay: 100 }).blur();
cy.wait("@validate_link");
cy.get(".frappe-control[data-fieldname=link] input").should("have.value", "");
cy.window()
.its("cur_dialog")
.then((dialog) => {
expect(dialog.get_value("link")).to.equal('');
expect(dialog.get_value("link")).to.equal("");
});
});
it('should route to form on arrow click', () => {
get_dialog_with_link().as('dialog');
it("should route to form on arrow click", () => {
get_dialog_with_link().as("dialog");
cy.intercept('POST', '/api/method/frappe.client.validate_link').as('validate_link');
cy.intercept('POST', '/api/method/frappe.desk.search.search_link').as('search_link');
cy.intercept("POST", "/api/method/frappe.client.validate_link").as("validate_link");
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.get('@todos').then(todos => {
cy.get('.frappe-control[data-fieldname=link] input').as('input');
cy.get('@input').focus();
cy.wait('@search_link');
cy.get('@input').type(todos[0]).blur();
cy.wait('@validate_link');
cy.get('@input').focus();
cy.findByTitle('Open Link')
.should('be.visible')
.click();
cy.location('pathname').should('eq', `/app/todo/${todos[0]}`);
cy.get("@todos").then((todos) => {
cy.get(".frappe-control[data-fieldname=link] input").as("input");
cy.get("@input").focus();
cy.wait("@search_link");
cy.get("@input").type(todos[0]).blur();
cy.wait("@validate_link");
cy.get("@input").focus();
cy.wait(500); // wait for arrow to show
cy.get(".frappe-control[data-fieldname=link] .btn-open").should("be.visible").click();
cy.location("pathname").should("eq", `/app/todo/${todos[0]}`);
});
});
it('show title field in link', () => {
get_dialog_with_link().as('dialog');
it("show title field in link", () => {
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "User",
property: "translate_link_fields",
property_type: "Check",
doctype_or_field: "DocType",
value: "0",
},
true
);
cy.insert_doc("Property Setter", {
"doctype": "Property Setter",
"doc_type": "ToDo",
"property": "show_title_field_in_link",
"property_type": "Check",
"doctype_or_field": "DocType",
"value": "1"
}, true);
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "ToDo",
property: "show_title_field_in_link",
property_type: "Check",
doctype_or_field: "DocType",
value: "1",
},
true
);
cy.window().its('frappe').then(frappe => {
if (!frappe.boot) {
frappe.boot = {
link_title_doctypes: ['ToDo']
};
} else {
frappe.boot.link_title_doctypes = ['ToDo'];
}
});
cy.clear_cache();
cy.wait(500);
cy.intercept('POST', '/api/method/frappe.desk.search.search_link').as('search_link');
get_dialog_with_link().as("dialog");
cy.window()
.its("frappe")
.then((frappe) => {
if (!frappe.boot) {
frappe.boot = {
link_title_doctypes: ["ToDo"],
};
} else {
frappe.boot.link_title_doctypes = ["ToDo"];
}
});
cy.get('.frappe-control[data-fieldname=link] input').focus().as('input');
cy.wait('@search_link');
cy.get('@input').type('todo for link');
cy.wait('@search_link');
cy.get('.frappe-control[data-fieldname=link] ul').should('be.visible');
cy.get('.frappe-control[data-fieldname=link] input').type('{enter}', { delay: 100 });
cy.get('.frappe-control[data-fieldname=link] input').blur();
cy.get('@dialog').then(dialog => {
cy.get('@todos').then(todos => {
let field = dialog.get_field('link');
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.get(".frappe-control[data-fieldname=link] input").focus().as("input");
cy.wait("@search_link");
cy.get("@input").type("todo for link");
cy.wait("@search_link");
cy.get(".frappe-control[data-fieldname=link] ul").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
cy.get("@dialog").then((dialog) => {
cy.get("@todos").then((todos) => {
let field = dialog.get_field("link");
let value = field.get_value();
let label = field.get_label_value();
expect(value).to.eq(todos[0]);
expect(label).to.eq('this is a test todo for link');
cy.remove_doc("Property Setter", "ToDo-main-show_title_field_in_link");
expect(label).to.eq("this is a test todo for link");
});
});
});
it('should update dependant fields (via fetch_from)', () => {
cy.get('@todos').then(todos => {
it("should update dependant fields (via fetch_from)", () => {
cy.get("@todos").then((todos) => {
cy.visit(`/app/todo/${todos[0]}`);
cy.intercept('POST', '/api/method/frappe.client.validate_link').as('validate_link');
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.intercept("POST", "/api/method/frappe.client.validate_link").as("validate_link");
cy.get('.frappe-control[data-fieldname=assigned_by] input').focus().as('input');
cy.get('@input').type('Administrator', {delay: 100}).blur();
cy.wait('@validate_link');
cy.get('.frappe-control[data-fieldname=assigned_by_full_name] .control-value').should(
'contain', 'Administrator'
cy.get(".frappe-control[data-fieldname=assigned_by] input").focus().as("input");
cy.get("@input").type("Administrator", { delay: 100 }).blur();
cy.wait("@validate_link");
cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should(
"contain",
"Administrator"
);
cy.window()
.its("cur_frm.doc.assigned_by")
.should("eq", "Administrator");
cy.window().its("cur_frm.doc.assigned_by").should("eq", "Administrator");
// invalid input
cy.get('@input').clear().type('invalid input', {delay: 100}).blur();
cy.get('.frappe-control[data-fieldname=assigned_by_full_name] .control-value').should(
'contain', ''
cy.get("@input").clear().type("invalid input", { delay: 100 }).blur();
cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should(
"contain",
""
);
cy.window()
.its("cur_frm.doc.assigned_by")
.should("eq", null);
cy.window().its("cur_frm.doc.assigned_by").should("eq", null);
// set valid value again
cy.get('@input').clear().type('Administrator', {delay: 100}).blur();
cy.wait('@validate_link');
cy.get("@input").clear().focus();
cy.wait("@search_link");
cy.get("@input").type("Administrator", { delay: 100 }).blur();
cy.wait("@validate_link");
cy.window()
.its("cur_frm.doc.assigned_by")
.should("eq", "Administrator");
cy.window().its("cur_frm.doc.assigned_by").should("eq", "Administrator");
// clear input
cy.get('@input').clear().blur();
cy.get('.frappe-control[data-fieldname=assigned_by_full_name] .control-value').should(
'contain', ''
cy.get("@input").clear().blur();
cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should(
"contain",
""
);
cy.window()
.its("cur_frm.doc.assigned_by")
.should("eq", "");
cy.window().its("cur_frm.doc.assigned_by").should("eq", "");
});
});
it("should set default values", () => {
cy.insert_doc("Property Setter", {
"doctype_or_field": "DocField",
"doc_type": "ToDo",
"field_name": "assigned_by",
"property": "default",
"property_type": "Text",
"value": "Administrator"
}, true);
cy.insert_doc(
"Property Setter",
{
doctype_or_field: "DocField",
doc_type: "ToDo",
field_name: "assigned_by",
property: "default",
property_type: "Text",
value: "Administrator",
},
true
);
cy.reload();
cy.new_form("ToDo");
cy.fill_field("description", "new", "Text Editor");
cy.intercept("POST", "/api/method/frappe.desk.form.save.savedocs").as("save_form");
cy.findByRole("button", {name: "Save"}).click();
cy.findByRole("button", { name: "Save" }).click();
cy.wait("@save_form");
cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should(
"contain", "Administrator"
"contain",
"Administrator"
);
// if user clears default value explicitly, system should not reset default again
cy.get_field("assigned_by").clear().blur();
cy.intercept("POST", "/api/method/frappe.desk.form.save.savedocs").as("save_form");
cy.findByRole("button", {name: "Save"}).click();
cy.findByRole("button", { name: "Save" }).click();
cy.wait("@save_form");
cy.get_field("assigned_by").should("have.value", "");
cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should(
"contain", ""
"contain",
""
);
});
it("show translated text for link with show_title_field_in_link enabled", () => {
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "ToDo",
property: "translate_link_fields",
property_type: "Check",
doctype_or_field: "DocType",
value: "1",
},
true
);
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "ToDo",
property: "show_title_field_in_link",
property_type: "Check",
doctype_or_field: "DocType",
value: "1",
},
true
);
cy.window()
.its("frappe")
.then((frappe) => {
cy.insert_doc("Translation", {
doctype: "Translation",
language: frappe.boot.lang,
source_text: "this is a test todo for link",
translated_text: "this is a translated test todo for link",
});
});
cy.clear_cache();
cy.wait(500);
cy.window()
.its("frappe")
.then((frappe) => {
if (!frappe.boot) {
frappe.boot = {
link_title_doctypes: ["ToDo"],
translatable_doctypes: ["ToDo"],
};
} else {
frappe.boot.link_title_doctypes = ["ToDo"];
frappe.boot.translatable_doctypes = ["ToDo"];
}
});
get_dialog_with_link().as("dialog");
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.get(".frappe-control[data-fieldname=link] input").focus().as("input");
cy.wait("@search_link");
cy.get("@input").type("todo for link", { delay: 100 });
cy.wait("@search_link");
cy.get(".frappe-control[data-fieldname=link] ul").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
cy.get("@dialog").then((dialog) => {
cy.get("@todos").then((todos) => {
let field = dialog.get_field("link");
let value = field.get_value();
let label = field.get_label_value();
expect(value).to.eq(todos[0]);
expect(label).to.eq("this is a translated test todo for link");
});
});
});
it("show translated text for link with show_title_field_in_link disabled", () => {
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "User",
property: "translate_link_fields",
property_type: "Check",
doctype_or_field: "DocType",
value: "1",
},
true
);
cy.insert_doc(
"Property Setter",
{
doctype: "Property Setter",
doc_type: "ToDo",
property: "show_title_field_in_link",
property_type: "Check",
doctype_or_field: "DocType",
value: "0",
},
true
);
cy.window()
.its("frappe")
.then((frappe) => {
cy.insert_doc("Translation", {
doctype: "Translation",
language: frappe.boot.lang,
source_text: "test@erpnext.com",
translated_text: "translatedtest@erpnext.com",
});
});
cy.clear_cache();
cy.wait(500);
cy.window()
.its("frappe")
.then((frappe) => {
if (!frappe.boot) {
frappe.boot = {
translatable_doctypes: ["User"],
};
} else {
frappe.boot.translatable_doctypes = ["User"];
}
});
get_dialog_with_user_link().as("dialog");
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.get(".frappe-control[data-fieldname=link] input").focus().as("input");
cy.wait("@search_link");
cy.get("@input").type("test@erpnext.com", { delay: 100 });
cy.wait("@search_link");
cy.get(".frappe-control[data-fieldname=link] ul").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
cy.get("@dialog").then((dialog) => {
let field = dialog.get_field("link");
let value = field.get_value();
let label = field.get_label_value();
expect(value).to.eq("test@erpnext.com");
expect(label).to.eq("translatedtest@erpnext.com");
});
});
});

View file

@ -0,0 +1,19 @@
context("Control Markdown Editor", () => {
before(() => {
cy.login();
cy.visit("/app");
});
it("should allow inserting images by drag and drop", () => {
cy.visit("/app/web-page/new");
cy.fill_field("content_type", "Markdown", "Select");
cy.get_field("main_section_md", "Markdown Editor").attachFile("sample_image.jpg", {
subjectType: "drag-n-drop",
});
cy.click_modal_primary_button("Upload");
cy.get_field("main_section_md", "Markdown Editor").should(
"contain",
"![](/private/files/sample_image"
);
});
});

View file

@ -0,0 +1,92 @@
import doctype_with_phone from "../fixtures/doctype_with_phone";
context("Control Phone", () => {
before(() => {
cy.login();
cy.visit("/app/website");
});
function get_dialog_with_phone() {
return cy.dialog({
title: "Phone",
fields: [
{
fieldname: "phone",
fieldtype: "Phone",
},
],
});
}
it("should set flag and data", () => {
get_dialog_with_phone().as("dialog");
cy.get(".selected-phone").click();
cy.get(".phone-picker .phone-wrapper[id='afghanistan']").click();
cy.get(".selected-phone").click();
cy.get(".phone-picker .phone-wrapper[id='india']").click();
cy.get(".selected-phone .country").should("have.text", "+91");
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
let phone_number = "9312672712";
cy.get(".selected-phone > img").click().first();
cy.get_field("phone").first().click({ multiple: true });
cy.get(".frappe-control[data-fieldname=phone]")
.findByRole("textbox")
.first()
.type(phone_number, { force: true });
cy.get_field("phone").first().should("have.value", phone_number);
cy.get_field("phone").first().blur({ force: true });
cy.wait(100);
cy.get("@dialog").then((dialog) => {
let value = dialog.get_value("phone");
expect(value).to.equal("+91-" + phone_number);
});
});
it("case insensitive search for country and clear search", () => {
let search_text = "india";
cy.get(".selected-phone").click().first();
cy.get(".phone-picker").findByRole("searchbox").click().type(search_text);
cy.get(".phone-section .phone-wrapper:not(.hidden)").then((i) => {
cy.get(`.phone-section .phone-wrapper[id*="${search_text.toLowerCase()}"]`).then(
(countries) => {
expect(i.length).to.equal(countries.length);
}
);
});
cy.get(".phone-picker").findByRole("searchbox").clear().blur();
cy.get(".phone-section .phone-wrapper").should("not.have.class", "hidden");
});
it("existing document should render phone field with data", () => {
cy.visit("/app/doctype");
cy.insert_doc("DocType", doctype_with_phone, true);
cy.clear_cache();
// Creating custom doctype
cy.insert_doc("DocType", doctype_with_phone, true);
cy.visit("/app/doctype-with-phone");
cy.click_listview_primary_button("Add Doctype With Phone");
// create a record
cy.fill_field("title", "Test Phone 1");
cy.fill_field("phone", "+91-9823341234");
cy.get_field("phone").should("have.value", "9823341234");
cy.click_doc_primary_button("Save");
cy.get_doc("Doctype With Phone", "Test Phone 1").then((doc) => {
let value = doc.data.phone;
expect(value).to.equal("+91-9823341234");
});
// open the doc from list view
cy.go_to_list("Doctype With Phone");
cy.clear_cache();
cy.click_listview_row_item(0);
cy.title().should("eq", "Test Phone 1");
cy.get(".selected-phone .country").should("have.text", "+91");
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
cy.get_field("phone").should("have.value", "9823341234");
});
});

View file

@ -1,56 +1,54 @@
context('Control Rating', () => {
context("Control Rating", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
function get_dialog_with_rating() {
return cy.dialog({
title: 'Rating',
fields: [{
'fieldname': 'rate',
'fieldtype': 'Rating',
'options': 7
}]
title: "Rating",
fields: [
{
fieldname: "rate",
fieldtype: "Rating",
options: 7,
},
],
});
}
it('click on the star rating to record value', () => {
get_dialog_with_rating().as('dialog');
it("click on the star rating to record value", () => {
get_dialog_with_rating().as("dialog");
cy.get('div.rating')
.children('svg')
.find('.right-half')
cy.get("div.rating")
.children("svg")
.find(".right-half")
.first()
.click()
.should('have.class', 'star-click');
cy.get('@dialog').then(dialog => {
var value = dialog.get_value('rate');
expect(value).to.equal(1/7);
.should("have.class", "star-click");
cy.get("@dialog").then((dialog) => {
var value = dialog.get_value("rate");
expect(value).to.equal(1 / 7);
dialog.hide();
});
});
it('hover on the star', () => {
it("hover on the star", () => {
get_dialog_with_rating();
cy.get('div.rating')
.children('svg')
.find('.right-half')
cy.get("div.rating")
.children("svg")
.find(".right-half")
.first()
.invoke('trigger', 'mouseenter')
.should('have.class', 'star-hover')
.invoke('trigger', 'mouseleave')
.should('not.have.class', 'star-hover');
.invoke("trigger", "mouseenter")
.should("have.class", "star-hover")
.invoke("trigger", "mouseleave")
.should("not.have.class", "star-hover");
});
it('check number of stars in rating', () => {
it("check number of stars in rating", () => {
get_dialog_with_rating();
cy.get('div.rating')
.first()
.children('svg')
.should('have.length', 7);
cy.get("div.rating").first().children("svg").should("have.length", 7);
});
});

View file

@ -1,37 +1,40 @@
context('Control Select', () => {
context("Control Select", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
function get_dialog_with_select() {
return cy.dialog({
title: 'Select',
fields: [{
'fieldname': 'select_control',
'fieldtype': 'Select',
'placeholder': 'Select an Option',
'options': ['', 'Option 1', 'Option 2', 'Option 2'],
}]
title: "Select",
fields: [
{
fieldname: "select_control",
fieldtype: "Select",
placeholder: "Select an Option",
options: ["", "Option 1", "Option 2", "Option 2"],
},
],
});
}
it('toggles placholder on clicking an option', () => {
get_dialog_with_select().as('dialog');
it("toggles placholder on clicking an option", () => {
get_dialog_with_select().as("dialog");
cy.get('.frappe-control[data-fieldname=select_control] .control-input').as('control');
cy.get('.frappe-control[data-fieldname=select_control] .control-input select').as('select');
cy.get('@control').get('.select-icon').should('exist');
cy.get('@control').get('.placeholder').should('have.css', 'display', 'block');
cy.get('@select').select('Option 1');
cy.findByDisplayValue('Option 1').should('exist');
cy.get('@control').get('.placeholder').should('have.css', 'display', 'none');
cy.get('@select').invoke('val', '');
cy.findByDisplayValue('Option 1').should('not.exist');
cy.get('@control').get('.placeholder').should('have.css', 'display', 'block');
cy.get(".frappe-control[data-fieldname=select_control] .control-input").as("control");
cy.get(".frappe-control[data-fieldname=select_control] .control-input select").as(
"select"
);
cy.get("@control").get(".select-icon").should("exist");
cy.get("@control").get(".placeholder").should("have.css", "display", "block");
cy.get("@select").select("Option 1");
cy.findByDisplayValue("Option 1").should("exist");
cy.get("@control").get(".placeholder").should("have.css", "display", "none");
cy.get("@select").invoke("val", "");
cy.findByDisplayValue("Option 1").should("not.exist");
cy.get("@control").get(".placeholder").should("have.css", "display", "block");
cy.get('@dialog').then(dialog => {
cy.get("@dialog").then((dialog) => {
dialog.hide();
});
});

View file

@ -0,0 +1,57 @@
const test_button_names = [
"Metallica",
"Pink Floyd",
"Porcupine Tree (the GOAT)",
"AC / DC",
`Electronic Dance "music"`,
"l'imperatrice",
];
const add_button = (label, group = "TestGroup") => {
cy.window()
.its("cur_frm")
.then((frm) => {
frm.add_custom_button(label, () => {}, group);
});
};
const check_button_count = (label, group = "TestGroup") => {
// Verify main buttons
cy.findByRole("button", { name: group }).click();
cy.get(`[data-label="${encodeURIComponent(label)}"]`)
.should("have.length", 1)
.should("be.visible");
// Verify dropdown buttons in mobile view
cy.viewport(420, 900);
const dropdown_btn_label = `${group} > ${label}`;
cy.get(".menu-btn-group > .btn").click();
cy.get(`[data-label="${encodeURIComponent(dropdown_btn_label)}"]`)
.should("have.length", 1)
.should("be.visible");
//reset viewport
cy.viewport(Cypress.config("viewportWidth"), Cypress.config("viewportHeight"));
};
describe(
"Custom group button behaviour on desk",
{ scrollBehavior: false }, // speeds up the test
() => {
before(() => {
cy.login();
cy.visit(`/app/note/new`);
});
test_button_names.forEach((button_name) => {
it(`Custom button works with name '${button_name}'`, () => {
add_button(button_name);
check_button_count(button_name);
// duplicate button shouldn't be added
add_button(button_name);
check_button_count(button_name);
});
});
}
);

View file

@ -0,0 +1,23 @@
context("Customize Form", () => {
before(() => {
cy.login();
cy.visit("/app/customize-form");
});
it("Changing to naming rule should update autoname", () => {
cy.fill_field("doc_type", "ToDo", "Link").blur();
cy.click_form_section("Naming");
const naming_rule_default_autoname_map = {
"Set by user": "prompt",
"By fieldname": "field:",
'By "Naming Series" field': "naming_series:",
Expression: "format:",
"Expression (old style)": "",
Random: "hash",
"By script": "",
};
Cypress._.forOwn(naming_rule_default_autoname_map, (value, naming_rule) => {
cy.fill_field("naming_rule", naming_rule, "Select");
cy.get_field("autoname", "Data").should("have.value", value);
});
});
});

View file

@ -1,22 +1,22 @@
context('Dashboard Chart', () => {
context("Dashboard Chart", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
it('Check filter populate for child table doctype', () => {
cy.visit('/app/dashboard-chart/new-dashboard-chart-1');
cy.get('[data-fieldname="parent_document_type"]').should('have.css', 'display', 'none');
it("Check filter populate for child table doctype", () => {
cy.visit("/app/dashboard-chart/new-dashboard-chart-1");
cy.get('[data-fieldname="parent_document_type"]').should("have.css", "display", "none");
cy.get_field('document_type', 'Link');
cy.fill_field('document_type', 'Workspace Link', 'Link').focus().blur();
cy.get_field('document_type', 'Link').should('have.value', 'Workspace Link');
cy.get_field("document_type", "Link");
cy.fill_field("document_type", "Workspace Link", "Link").focus().blur();
cy.get_field("document_type", "Link").should("have.value", "Workspace Link");
cy.fill_field('chart_name', 'Test Chart', 'Data');
cy.fill_field("chart_name", "Test Chart", "Data");
cy.get('[data-fieldname="filters_json"]').click().wait(200);
cy.get('.modal-body .filter-action-buttons .add-filter').click();
cy.get('.modal-body .fieldname-select-area').click();
cy.get('.modal-actions .btn-modal-close').click();
cy.get(".modal-body .filter-action-buttons .add-filter").click();
cy.get(".modal-body .fieldname-select-area").click();
cy.get(".modal-actions .btn-modal-close").click();
});
});
});

View file

@ -1,91 +1,94 @@
import doctype_with_child_table from '../fixtures/doctype_with_child_table';
import child_table_doctype from '../fixtures/child_table_doctype';
import child_table_doctype_1 from '../fixtures/child_table_doctype_1';
import doctype_to_link from '../fixtures/doctype_to_link';
import doctype_with_child_table from "../fixtures/doctype_with_child_table";
import child_table_doctype from "../fixtures/child_table_doctype";
import child_table_doctype_1 from "../fixtures/child_table_doctype_1";
import doctype_to_link from "../fixtures/doctype_to_link";
const doctype_to_link_name = doctype_to_link.name;
const child_table_doctype_name = child_table_doctype.name;
context('Dashboard links', () => {
context("Dashboard links", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.insert_doc('DocType', child_table_doctype, true);
cy.insert_doc('DocType', child_table_doctype_1, true);
cy.insert_doc('DocType', doctype_with_child_table, true);
cy.insert_doc('DocType', doctype_to_link, true);
return cy.window().its('frappe').then(frappe => {
return frappe.xcall("frappe.tests.ui_test_helpers.update_child_table", {
name: child_table_doctype_name
cy.insert_doc("DocType", child_table_doctype, true);
cy.insert_doc("DocType", child_table_doctype_1, true);
cy.insert_doc("DocType", doctype_with_child_table, true);
cy.insert_doc("DocType", doctype_to_link, true);
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.update_child_table", {
name: child_table_doctype_name,
});
});
});
});
it('Adding a new contact, checking for the counter on the dashboard and deleting the created contact', () => {
cy.visit('/app/contact');
it("Adding a new contact, checking for the counter on the dashboard and deleting the created contact", () => {
cy.visit("/app/contact");
cy.clear_filters();
cy.visit('/app/user');
cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click({ force: true });
cy.visit("/app/user");
cy.get(".list-row-col > .level-item > .ellipsis").eq(0).click({ force: true });
//To check if initially the dashboard contains only the "Contact" link and there is no counter
cy.get('[data-doctype="Contact"]').should('contain', 'Contact');
cy.get('[data-doctype="Contact"]').should("contain", "Contact");
//Adding a new contact
cy.get('.document-link-badge[data-doctype="Contact"]').click();
cy.wait(300);
cy.findByRole('button', {name: 'Add Contact'}).should('be.visible');
cy.findByRole('button', {name: 'Add Contact'}).click();
cy.get('[data-doctype="Contact"][data-fieldname="first_name"]').type('Admin');
cy.findByRole('button', {name: 'Save'}).click();
cy.visit('/app/user');
cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click({ force: true });
cy.findByRole("button", { name: "Add Contact" }).should("be.visible");
cy.findByRole("button", { name: "Add Contact" }).click();
cy.get('[data-doctype="Contact"][data-fieldname="first_name"]').type("Admin");
cy.findByRole("button", { name: "Save" }).click();
cy.visit("/app/user");
cy.get(".list-row-col > .level-item > .ellipsis").eq(0).click({ force: true });
//To check if the counter for contact doc is "1" after adding the contact
cy.get('[data-doctype="Contact"] > .count').should('contain', '1');
cy.get('[data-doctype="Contact"]').contains('Contact').click();
cy.get('[data-doctype="Contact"] > .count').should("contain", "1");
cy.get('[data-doctype="Contact"]').contains("Contact").click();
//Deleting the newly created contact
cy.visit('/app/contact');
cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click({ force: true });
cy.findByRole('button', {name: 'Actions'}).click();
cy.visit("/app/contact");
cy.get(".list-subject > .select-like > .list-row-checkbox").eq(0).click({ force: true });
cy.findByRole("button", { name: "Actions" }).click();
cy.get('.actions-btn-group [data-label="Delete"]').click();
cy.findByRole('button', {name: 'Yes'}).click({delay: 700});
cy.findByRole("button", { name: "Yes" }).click({ delay: 700 });
//To check if the counter from the "Contact" doc link is removed
cy.wait(700);
cy.visit('/app/user');
cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click({ force: true });
cy.get('[data-doctype="Contact"]').should('contain', 'Contact');
cy.visit("/app/user");
cy.get(".list-row-col > .level-item > .ellipsis").eq(0).click({ force: true });
cy.get('[data-doctype="Contact"]').should("contain", "Contact");
});
it('Report link in dashboard', () => {
cy.visit('/app/user');
cy.visit('/app/user/Administrator');
cy.get('[data-doctype="Contact"]').should('contain', 'Contact');
cy.findByText('Connections');
it("Report link in dashboard", () => {
cy.visit("/app/user");
cy.visit("/app/user/Administrator");
cy.get('[data-doctype="Contact"]').should("contain", "Contact");
cy.findByText("Connections");
cy.window()
.its('cur_frm')
.then(cur_frm => {
.its("cur_frm")
.then((cur_frm) => {
cur_frm.dashboard.data.reports = [
{
'label': 'Reports',
'items': ['Website Analytics']
}
label: "Reports",
items: ["Website Analytics"],
},
];
cur_frm.dashboard.render_report_links();
cy.get('[data-report="Website Analytics"]').contains('Website Analytics').click();
cy.findByText('Website Analytics');
cy.get('[data-report="Website Analytics"]').contains("Website Analytics").click();
cy.findByText("Website Analytics");
});
});
it('check if child table is populated with linked field on creation from dashboard link', () => {
it("check if child table is populated with linked field on creation from dashboard link", () => {
cy.new_form(doctype_to_link_name);
cy.fill_field("title", "Test Linking");
cy.findByRole("button", {name: "Save"}).click();
cy.findByRole("button", { name: "Save" }).click();
cy.get('.document-link .btn-new').click();
cy.get('.frappe-control[data-fieldname="child_table"] .rows .data-row .col[data-fieldname="doctype_to_link"]')
.should('contain.text', 'Test Linking');
cy.get(".document-link .btn-new").click();
cy.get(
'.frappe-control[data-fieldname="child_table"] .rows .data-row .col[data-fieldname="doctype_to_link"]'
).should("contain.text", "Test Linking");
});
});

View file

@ -1,43 +1,45 @@
import data_field_validation_doctype from '../fixtures/data_field_validation_doctype';
import data_field_validation_doctype from "../fixtures/data_field_validation_doctype";
const doctype_name = data_field_validation_doctype.name;
context('Data Field Input Validation in New Form', () => {
context("Data Field Input Validation in New Form", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.insert_doc('DocType', data_field_validation_doctype, true);
cy.visit("/app/website");
return cy.insert_doc("DocType", data_field_validation_doctype, true);
});
function validateField(fieldname, invalid_value, valid_value) {
// Invalid, should have has-error class
cy.get_field(fieldname).clear().type(invalid_value).blur();
cy.get(`.frappe-control[data-fieldname="${fieldname}"]`).should('have.class', 'has-error');
cy.get(`.frappe-control[data-fieldname="${fieldname}"]`).should("have.class", "has-error");
// Valid value, should not have has-error class
cy.get_field(fieldname).clear().type(valid_value);
cy.get(`.frappe-control[data-fieldname="${fieldname}"]`).should('not.have.class', 'has-error');
cy.get(`.frappe-control[data-fieldname="${fieldname}"]`).should(
"not.have.class",
"has-error"
);
}
describe('Data Field Options', () => {
it('should validate email address', () => {
describe("Data Field Options", () => {
it("should validate email address", () => {
cy.new_form(doctype_name);
validateField('email', 'captian', 'hello@test.com');
validateField("email", "captian", "hello@test.com");
});
it('should validate URL', () => {
validateField('url', 'jkl', 'https://frappe.io');
validateField('url', 'abcd.com', 'http://google.com/home');
validateField('url', '&&http://google.uae', 'gopher://frappe.io');
validateField('url', 'ftt2:://google.in?q=news', 'ftps2://frappe.io/__/#home');
validateField('url', 'ftt2://', 'ntps://localhost'); // For intranet URLs
it("should validate URL", () => {
validateField("url", "jkl", "https://frappe.io");
validateField("url", "abcd.com", "http://google.com/home");
validateField("url", "&&http://google.uae", "gopher://frappe.io");
validateField("url", "ftt2:://google.in?q=news", "ftps2://frappe.io/__/#home");
validateField("url", "ftt2://", "ntps://localhost"); // For intranet URLs
});
it('should validate phone number', () => {
validateField('phone', 'america', '89787878');
it("should validate phone number", () => {
validateField("phone", "america", "89787878");
});
it('should validate name', () => {
validateField('person_name', ' 777Hello', 'James Bond');
it("should validate name", () => {
validateField("person_name", " 777Hello", "James Bond");
});
});
});
});

View file

@ -1,53 +1,52 @@
import datetime_doctype from '../fixtures/datetime_doctype';
import datetime_doctype from "../fixtures/datetime_doctype";
const doctype_name = datetime_doctype.name;
context('Control Date, Time and DateTime', () => {
context("Control Date, Time and DateTime", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.insert_doc('DocType', datetime_doctype, true);
cy.visit("/app/website");
return cy.insert_doc("DocType", datetime_doctype, true);
});
describe('Date formats', () => {
describe("Date formats", () => {
let date_formats = [
{
date_format: 'dd-mm-yyyy',
date_format: "dd-mm-yyyy",
part: 2,
length: 4,
separator: '-'
separator: "-",
},
{
date_format: 'mm/dd/yyyy',
date_format: "mm/dd/yyyy",
part: 0,
length: 2,
separator: '/'
}
separator: "/",
},
];
date_formats.forEach(d => {
it('test date format ' + d.date_format, () => {
cy.set_value('System Settings', 'System Settings', {
date_format: d.date_format
date_formats.forEach((d) => {
it("test date format " + d.date_format, () => {
cy.set_value("System Settings", "System Settings", {
date_format: d.date_format,
});
cy.window()
.its('frappe')
.then(frappe => {
.its("frappe")
.then((frappe) => {
// update sys_defaults value to avoid a reload
frappe.sys_defaults.date_format = d.date_format;
});
cy.new_form(doctype_name);
cy.get('.form-control[data-fieldname=date]').focus();
cy.get('.datepickers-container .datepicker.active')
.should('be.visible');
cy.get(".form-control[data-fieldname=date]").focus();
cy.get(".datepickers-container .datepicker.active").should("be.visible");
cy.get(
'.datepickers-container .datepicker.active .datepicker--cell-day.-current-'
".datepickers-container .datepicker.active .datepicker--cell-day.-current-"
).click({ force: true });
cy.window()
.its('cur_frm')
.then(cur_frm => {
let formatted_value = cur_frm.get_field('date').input.value;
.its("cur_frm")
.then((cur_frm) => {
let formatted_value = cur_frm.get_field("date").input.value;
let parts = formatted_value.split(d.separator);
expect(parts[d.part].length).to.equal(d.length);
});
@ -55,74 +54,72 @@ context('Control Date, Time and DateTime', () => {
});
});
describe('Time formats', () => {
describe("Time formats", () => {
let time_formats = [
{
time_format: 'HH:mm:ss',
value: ' 11:00:12',
match_value: '11:00:12'
time_format: "HH:mm:ss",
value: " 11:00:12",
match_value: "11:00:12",
},
{
time_format: 'HH:mm',
value: ' 11:00:12',
match_value: '11:00'
}
time_format: "HH:mm",
value: " 11:00:12",
match_value: "11:00",
},
];
time_formats.forEach(d => {
it('test time format ' + d.time_format, () => {
cy.set_value('System Settings', 'System Settings', {
time_format: d.time_format
time_formats.forEach((d) => {
it("test time format " + d.time_format, () => {
cy.set_value("System Settings", "System Settings", {
time_format: d.time_format,
});
cy.window()
.its('frappe')
.then(frappe => {
.its("frappe")
.then((frappe) => {
frappe.sys_defaults.time_format = d.time_format;
});
cy.new_form(doctype_name);
cy.fill_field('time', d.value, 'Time').blur();
cy.get_field('time').should('have.value', d.match_value);
cy.fill_field("time", d.value, "Time").blur();
cy.get_field("time").should("have.value", d.match_value);
});
});
});
describe('DateTime formats', () => {
describe("DateTime formats", () => {
let datetime_formats = [
{
date_format: 'dd.mm.yyyy',
time_format: 'HH:mm:ss',
value: ' 02.12.2019 11:00:12',
doc_value: '2019-12-02 00:30:12', // system timezone (America/New_York)
input_value: '02.12.2019 11:00:12' // admin timezone (Asia/Kolkata)
date_format: "dd.mm.yyyy",
time_format: "HH:mm:ss",
value: " 02.12.2019 11:00:12",
doc_value: "2019-12-02 00:30:12", // system timezone (America/New_York)
input_value: "02.12.2019 11:00:12", // admin timezone (Asia/Kolkata)
},
{
date_format: 'mm-dd-yyyy',
time_format: 'HH:mm',
value: ' 12-02-2019 11:00:00',
doc_value: '2019-12-02 00:30:00', // system timezone (America/New_York)
input_value: '12-02-2019 11:00' // admin timezone (Asia/Kolkata)
}
date_format: "mm-dd-yyyy",
time_format: "HH:mm",
value: " 12-02-2019 11:00:00",
doc_value: "2019-12-02 00:30:00", // system timezone (America/New_York)
input_value: "12-02-2019 11:00", // admin timezone (Asia/Kolkata)
},
];
datetime_formats.forEach(d => {
datetime_formats.forEach((d) => {
it(`test datetime format ${d.date_format} ${d.time_format}`, () => {
cy.set_value('System Settings', 'System Settings', {
cy.set_value("System Settings", "System Settings", {
date_format: d.date_format,
time_format: d.time_format
time_format: d.time_format,
});
cy.window()
.its('frappe')
.then(frappe => {
.its("frappe")
.then((frappe) => {
frappe.sys_defaults.date_format = d.date_format;
frappe.sys_defaults.time_format = d.time_format;
});
cy.new_form(doctype_name);
cy.fill_field('datetime', d.value, 'Datetime').blur();
cy.get_field('datetime').should('have.value', d.input_value);
cy.fill_field("datetime", d.value, "Datetime").blur();
cy.get_field("datetime").should("have.value", d.input_value);
cy.window()
.its('cur_frm.doc.datetime')
.should('eq', d.doc_value);
cy.window().its("cur_frm.doc.datetime").should("eq", d.doc_value);
});
});
});

View file

@ -16,4 +16,4 @@
// cy.get('.indicator-pill').should('contain', 'Open').should('have.class', 'red');
// });
// });
// });
// });

View file

@ -1,135 +1,152 @@
context('Depends On', () => {
context("Depends On", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.window().its('frappe').then(frappe => {
return frappe.xcall('frappe.tests.ui_test_helpers.create_child_doctype', {
name: 'Child Test Depends On',
fields: [
{
"label": "Child Test Field",
"fieldname": "child_test_field",
"fieldtype": "Data",
"in_list_view": 1,
},
{
"label": "Child Dependant Field",
"fieldname": "child_dependant_field",
"fieldtype": "Data",
"in_list_view": 1,
},
{
"label": "Child Display Dependant Field",
"fieldname": "child_display_dependant_field",
"fieldtype": "Data",
"in_list_view": 1,
},
]
cy.visit("/app/website");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.create_child_doctype", {
name: "Child Test Depends On",
fields: [
{
label: "Child Test Field",
fieldname: "child_test_field",
fieldtype: "Data",
in_list_view: 1,
},
{
label: "Child Dependant Field",
fieldname: "child_dependant_field",
fieldtype: "Data",
in_list_view: 1,
},
{
label: "Child Display Dependant Field",
fieldname: "child_display_dependant_field",
fieldtype: "Data",
in_list_view: 1,
},
],
});
})
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.create_doctype", {
name: "Test Depends On",
fields: [
{
label: "Test Field",
fieldname: "test_field",
fieldtype: "Data",
},
{
label: "Dependant Field",
fieldname: "dependant_field",
fieldtype: "Data",
mandatory_depends_on: "eval:doc.test_field=='Some Value'",
read_only_depends_on: "eval:doc.test_field=='Some Other Value'",
},
{
label: "Display Dependant Field",
fieldname: "display_dependant_field",
fieldtype: "Data",
depends_on: "eval:doc.test_field=='Value'",
},
{
label: "Child Test Depends On Field",
fieldname: "child_test_depends_on_field",
fieldtype: "Table",
read_only_depends_on: "eval:doc.test_field=='Some Other Value'",
options: "Child Test Depends On",
},
{
label: "Dependent Tab",
fieldname: "dependent_tab",
fieldtype: "Tab Break",
depends_on: "eval:doc.test_field=='Show Tab'",
},
{
fieldname: "tab_section",
fieldtype: "Section Break",
},
{
label: "Field in Tab",
fieldname: "field_in_tab",
fieldtype: "Data",
},
],
});
});
}).then(frappe => {
return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', {
name: 'Test Depends On',
fields: [
{
"label": "Test Field",
"fieldname": "test_field",
"fieldtype": "Data",
},
{
"label": "Dependant Field",
"fieldname": "dependant_field",
"fieldtype": "Data",
"mandatory_depends_on": "eval:doc.test_field=='Some Value'",
"read_only_depends_on": "eval:doc.test_field=='Some Other Value'",
},
{
"label": "Display Dependant Field",
"fieldname": "display_dependant_field",
"fieldtype": "Data",
'depends_on': "eval:doc.test_field=='Value'"
},
{
"label": "Child Test Depends On Field",
"fieldname": "child_test_depends_on_field",
"fieldtype": "Table",
'read_only_depends_on': "eval:doc.test_field=='Some Other Value'",
'options': "Child Test Depends On"
},
{
"label": "Dependent Tab",
"fieldname": "dependent_tab",
"fieldtype": "Tab Break",
"depends_on": "eval:doc.test_field=='Show Tab'"
},
{
"fieldname": "tab_section",
"fieldtype": "Section Break",
},
{
"label": "Field in Tab",
"fieldname": "field_in_tab",
"fieldtype": "Data",
}
]
});
});
});
it('should show the tab on other setting field value', () => {
cy.new_form('Test Depends On');
cy.fill_field('test_field', 'Show Tab');
cy.get('body').click();
cy.findByRole("tab", {name: "Dependent Tab"}).should('be.visible');
it("should show the tab on other setting field value", () => {
cy.new_form("Test Depends On");
cy.fill_field("test_field", "Show Tab");
cy.get("body").click();
cy.findByRole("tab", { name: "Dependent Tab" }).should("be.visible");
});
it('should set the field as mandatory depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.fill_field('test_field', 'Some Value');
cy.findByRole('button', {name: 'Save'}).click();
cy.get('.msgprint-dialog .modal-title').contains('Missing Fields').should('be.visible');
it("should set the field as mandatory depending on other fields value", () => {
cy.new_form("Test Depends On");
cy.fill_field("test_field", "Some Value");
cy.findByRole("button", { name: "Save" }).click();
cy.get(".msgprint-dialog .modal-title").contains("Missing Fields").should("be.visible");
cy.hide_dialog();
cy.fill_field('test_field', 'Random value');
cy.findByRole('button', {name: 'Save'}).click();
cy.get('.msgprint-dialog .modal-title').contains('Missing Fields').should('not.be.visible');
cy.fill_field("test_field", "Random value");
cy.findByRole("button", { name: "Save" }).click();
cy.get(".msgprint-dialog .modal-title")
.contains("Missing Fields")
.should("not.be.visible");
});
it('should set the field as read only depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.fill_field('dependant_field', 'Some Value');
cy.fill_field('test_field', 'Some Other Value');
cy.get('body').click();
cy.get('.control-input [data-fieldname="dependant_field"]').should('be.disabled');
cy.fill_field('test_field', 'Random Value');
cy.get('body').click();
cy.get('.control-input [data-fieldname="dependant_field"]').should('not.be.disabled');
it("should set the field as read only depending on other fields value", () => {
cy.new_form("Test Depends On");
cy.fill_field("dependant_field", "Some Value");
cy.fill_field("test_field", "Some Other Value");
cy.get("body").click();
cy.get('.control-input [data-fieldname="dependant_field"]').should("be.disabled");
cy.fill_field("test_field", "Random Value");
cy.get("body").click();
cy.get('.control-input [data-fieldname="dependant_field"]').should("not.be.disabled");
});
it('should set the table and its fields as read only depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.fill_field('dependant_field', 'Some Value');
it("should set the table and its fields as read only depending on other fields value", () => {
cy.new_form("Test Depends On");
cy.fill_field("dependant_field", "Some Value");
//cy.fill_field('test_field', 'Some Other Value');
cy.get('.frappe-control[data-fieldname="child_test_depends_on_field"]').as('table');
cy.get('@table').findByRole('button', {name: 'Add Row'}).click();
cy.get('@table').find('[data-idx="1"]').as('row1');
cy.get('@row1').find('.btn-open-row').click();
cy.get('@row1').find('.form-in-grid').as('row1-form_in_grid');
cy.get('.frappe-control[data-fieldname="child_test_depends_on_field"]').as("table");
cy.get("@table").findByRole("button", { name: "Add Row" }).click();
cy.get("@table").find('[data-idx="1"]').as("row1");
cy.get("@row1").find(".btn-open-row").click();
cy.get("@row1").find(".form-in-grid").as("row1-form_in_grid");
//cy.get('@row1-form_in_grid').find('')
cy.fill_table_field('child_test_depends_on_field', '1', 'child_test_field', 'Some Value');
cy.fill_table_field('child_test_depends_on_field', '1', 'child_dependant_field', 'Some Other Value');
cy.fill_table_field("child_test_depends_on_field", "1", "child_test_field", "Some Value");
cy.fill_table_field(
"child_test_depends_on_field",
"1",
"child_dependant_field",
"Some Other Value"
);
cy.get('@row1-form_in_grid').find('.grid-collapse-row').click();
cy.get("@row1-form_in_grid").find(".grid-collapse-row").click();
// set the table to read-only
cy.fill_field('test_field', 'Some Other Value');
cy.fill_field("test_field", "Some Other Value");
// grid row form fields should be read-only
cy.get('@row1').find('.btn-open-row').click();
cy.get("@row1").find(".btn-open-row").click();
cy.get('@row1-form_in_grid').find('.control-input [data-fieldname="child_test_field"]').should('be.disabled');
cy.get('@row1-form_in_grid').find('.control-input [data-fieldname="child_dependant_field"]').should('be.disabled');
cy.get("@row1-form_in_grid")
.find('.control-input [data-fieldname="child_test_field"]')
.should("be.disabled");
cy.get("@row1-form_in_grid")
.find('.control-input [data-fieldname="child_dependant_field"]')
.should("be.disabled");
});
it('should display the field depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.get('.control-input [data-fieldname="display_dependant_field"]').should('not.be.visible');
it("should display the field depending on other fields value", () => {
cy.new_form("Test Depends On");
cy.get('.control-input [data-fieldname="display_dependant_field"]').should(
"not.be.visible"
);
cy.get('.control-input [data-fieldname="test_field"]').clear();
cy.fill_field('test_field', 'Value');
cy.get('body').click();
cy.get('.control-input [data-fieldname="display_dependant_field"]').should('be.visible');
cy.fill_field("test_field", "Value");
cy.get("body").click();
cy.get('.control-input [data-fieldname="display_dependant_field"]').should("be.visible");
});
});

View file

@ -1,79 +1,101 @@
context('Discussions', () => {
context("Discussions", () => {
before(() => {
cy.login();
cy.visit('/app');
return cy.window().its('frappe').then(frappe => {
return frappe.call('frappe.tests.ui_test_helpers.create_data_for_discussions');
});
cy.visit("/app");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.call("frappe.tests.ui_test_helpers.create_data_for_discussions");
});
});
const reply_through_modal = () => {
cy.visit('/test-page-discussions');
cy.visit("/test-page-discussions");
// Open the modal
cy.get('.reply').click();
cy.get(".reply").click();
cy.wait(500);
cy.get('.discussion-modal').should('be.visible');
cy.get(".discussion-modal").should("be.visible");
// Enter title
cy.get('.modal .topic-title').type('Discussion from tests')
.should('have.value', 'Discussion from tests');
cy.get(".modal .topic-title")
.type("Discussion from tests")
.should("have.value", "Discussion from tests");
// Enter comment
cy.get('.modal .comment-field')
.type('This is a discussion from the cypress ui tests.')
.should('have.value', 'This is a discussion from the cypress ui tests.');
cy.get(".modal .comment-field")
.type("This is a discussion from the cypress ui tests.")
.should("have.value", "This is a discussion from the cypress ui tests.");
// Submit
cy.get('.modal .submit-discussion').click();
cy.get(".modal .submit-discussion").click();
cy.wait(2000);
// Check if discussion is added to page and content is visible
cy.get('.sidebar-parent:first .discussion-topic-title').should('have.text', 'Discussion from tests');
cy.get('.discussion-on-page:visible').should('have.class', 'show');
cy.get('.discussion-on-page:visible .reply-card .reply-text')
.should('have.text', 'This is a discussion from the cypress ui tests.\n');
cy.get(".sidebar-parent:first .discussion-topic-title").should(
"have.text",
"Discussion from tests"
);
cy.get(".discussion-on-page:visible").should("have.class", "show");
cy.get(".discussion-on-page:visible .reply-card .reply-text").should(
"have.text",
"This is a discussion from the cypress ui tests.\n"
);
};
const reply_through_comment_box = () => {
cy.get('.discussion-form:visible .comment-field')
.type('This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page.')
.should('have.value', 'This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page.');
cy.get(".discussion-form:visible .comment-field")
.type(
"This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page."
)
.should(
"have.value",
"This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page."
);
cy.get('.discussion-form:visible .submit-discussion').click();
cy.get(".discussion-form:visible .submit-discussion").click();
cy.wait(3000);
cy.get('.discussion-on-page:visible').should('have.class', 'show');
cy.get('.discussion-on-page:visible').children(".reply-card").eq(1).find(".reply-text")
.should('have.text', 'This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page.\n');
cy.get(".discussion-on-page:visible").should("have.class", "show");
cy.get(".discussion-on-page:visible")
.children(".reply-card")
.eq(1)
.find(".reply-text")
.should(
"have.text",
"This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page.\n"
);
};
const cancel_and_clear_comment_box = () => {
cy.get('.discussion-form:visible .comment-field')
.type('This is a discussion from the cypress ui tests.')
.should('have.value', 'This is a discussion from the cypress ui tests.');
cy.get(".discussion-form:visible .comment-field")
.type("This is a discussion from the cypress ui tests.")
.should("have.value", "This is a discussion from the cypress ui tests.");
cy.get('.discussion-form:visible .cancel-comment').click();
cy.get('.discussion-form:visible .comment-field').should('have.value', '');
cy.get(".discussion-form:visible .cancel-comment").click();
cy.get(".discussion-form:visible .comment-field").should("have.value", "");
};
const single_thread_discussion = () => {
cy.visit('/test-single-thread');
cy.get('.discussions-sidebar').should('have.length', 0);
cy.get('.reply').should('have.length', 0);
cy.visit("/test-single-thread");
cy.get(".discussions-sidebar").should("have.length", 0);
cy.get(".reply").should("have.length", 0);
cy.get('.discussion-form:visible .comment-field')
.type('This comment is being made on a single thread discussion.')
.should('have.value', 'This comment is being made on a single thread discussion.');
cy.get(".discussion-form:visible .comment-field")
.type("This comment is being made on a single thread discussion.")
.should("have.value", "This comment is being made on a single thread discussion.");
cy.get('.discussion-form:visible .submit-discussion').click();
cy.get(".discussion-form:visible .submit-discussion").click();
cy.wait(3000);
cy.get('.discussion-on-page').children(".reply-card").eq(-1).find(".reply-text")
.should('have.text', 'This comment is being made on a single thread discussion.\n');
cy.get(".discussion-on-page")
.children(".reply-card")
.eq(-1)
.find(".reply-text")
.should("have.text", "This comment is being made on a single thread discussion.\n");
};
it('reply through modal', reply_through_modal);
it('reply through comment box', reply_through_comment_box);
it('cancel and clear comment box', cancel_and_clear_comment_box);
it('single thread discussion', single_thread_discussion);
it("reply through modal", reply_through_modal);
it("reply through comment box", reply_through_comment_box);
it("cancel and clear comment box", cancel_and_clear_comment_box);
it("single thread discussion", single_thread_discussion);
});

View file

@ -1,78 +1,82 @@
context('FileUploader', () => {
context("FileUploader", () => {
before(() => {
cy.login();
cy.visit('/app');
cy.visit("/app");
});
function open_upload_dialog() {
cy.window().its('frappe').then(frappe => {
new frappe.ui.FileUploader();
});
cy.window()
.its("frappe")
.then((frappe) => {
new frappe.ui.FileUploader();
});
}
it('upload dialog api works', () => {
it("upload dialog api works", () => {
open_upload_dialog();
cy.get_open_dialog().should('contain', 'Drag and drop files');
cy.get_open_dialog().should("contain", "Drag and drop files");
cy.hide_dialog();
});
it('should accept dropped files', () => {
it("should accept dropped files", () => {
open_upload_dialog();
cy.get_open_dialog().find('.file-upload-area').attachFile('example.json', {
subjectType: 'drag-n-drop',
cy.get_open_dialog().find(".file-upload-area").attachFile("example.json", {
subjectType: "drag-n-drop",
});
cy.get_open_dialog().find('.file-name').should('contain', 'example.json');
cy.intercept('POST', '/api/method/upload_file').as('upload_file');
cy.get_open_dialog().findByRole('button', {name: 'Upload'}).click();
cy.wait('@upload_file').its('response.statusCode').should('eq', 200);
cy.get('.modal:visible').should('not.exist');
cy.get_open_dialog().find(".file-name").should("contain", "example.json");
cy.intercept("POST", "/api/method/upload_file").as("upload_file");
cy.get_open_dialog().findByRole("button", { name: "Upload" }).click();
cy.wait("@upload_file").its("response.statusCode").should("eq", 200);
cy.get(".modal:visible").should("not.exist");
});
it('should accept uploaded files', () => {
it("should accept uploaded files", () => {
open_upload_dialog();
cy.get_open_dialog().findByRole('button', {name: 'Library'}).click();
cy.findByPlaceholderText('Search by filename or extension').type('example.json');
cy.get_open_dialog().findAllByText('example.json').first().click();
cy.intercept('POST', '/api/method/upload_file').as('upload_file');
cy.get_open_dialog().findByRole('button', {name: 'Upload'}).click();
cy.wait('@upload_file').its('response.body.message')
.should('have.property', 'file_name', 'example.json');
cy.get('.modal:visible').should('not.exist');
cy.get_open_dialog().findByRole("button", { name: "Library" }).click();
cy.findByPlaceholderText("Search by filename or extension").type("example.json");
cy.get_open_dialog().findAllByText("example.json").first().click();
cy.intercept("POST", "/api/method/upload_file").as("upload_file");
cy.get_open_dialog().findByRole("button", { name: "Upload" }).click();
cy.wait("@upload_file")
.its("response.body.message")
.should("have.property", "file_name", "example.json");
cy.get(".modal:visible").should("not.exist");
});
it('should accept web links', () => {
it("should accept web links", () => {
open_upload_dialog();
cy.get_open_dialog().findByRole('button', {name: 'Link'}).click();
cy.get_open_dialog().findByRole("button", { name: "Link" }).click();
cy.get_open_dialog()
.findByPlaceholderText('Attach a web link')
.type('https://github.com', { delay: 100, force: true });
cy.intercept('POST', '/api/method/upload_file').as('upload_file');
cy.get_open_dialog().findByRole('button', {name: 'Upload'}).click();
cy.wait('@upload_file').its('response.body.message')
.should('have.property', 'file_url', 'https://github.com');
cy.get('.modal:visible').should('not.exist');
.findByPlaceholderText("Attach a web link")
.type("https://github.com", { delay: 100, force: true });
cy.intercept("POST", "/api/method/upload_file").as("upload_file");
cy.get_open_dialog().findByRole("button", { name: "Upload" }).click();
cy.wait("@upload_file")
.its("response.body.message")
.should("have.property", "file_url", "https://github.com");
cy.get(".modal:visible").should("not.exist");
});
it('should allow cropping and optimization for valid images', () => {
it("should allow cropping and optimization for valid images", () => {
open_upload_dialog();
cy.get_open_dialog().find('.file-upload-area').attachFile('sample_image.jpg', {
subjectType: 'drag-n-drop',
cy.get_open_dialog().find(".file-upload-area").attachFile("sample_image.jpg", {
subjectType: "drag-n-drop",
});
cy.get_open_dialog().findAllByText('sample_image.jpg').should('exist');
cy.get_open_dialog().find('.btn-crop').first().click();
cy.get_open_dialog().findByRole('button', {name: 'Crop'}).click();
cy.get_open_dialog().findAllByRole('checkbox', {name: 'Optimize'}).should('exist');
cy.get_open_dialog().findAllByLabelText('Optimize').first().click();
cy.get_open_dialog().findAllByText("sample_image.jpg").should("exist");
cy.get_open_dialog().find(".btn-crop").first().click();
cy.get_open_dialog().findByRole("button", { name: "Crop" }).click();
cy.get_open_dialog().findAllByRole("checkbox", { name: "Optimize" }).should("exist");
cy.get_open_dialog().findAllByLabelText("Optimize").first().click();
cy.intercept('POST', '/api/method/upload_file').as('upload_file');
cy.get_open_dialog().findByRole('button', {name: 'Upload'}).click();
cy.wait('@upload_file').its('response.statusCode').should('eq', 200);
cy.get('.modal:visible').should('not.exist');
cy.intercept("POST", "/api/method/upload_file").as("upload_file");
cy.get_open_dialog().findByRole("button", { name: "Upload" }).click();
cy.wait("@upload_file").its("response.statusCode").should("eq", 200);
cy.get(".modal:visible").should("not.exist");
});
});

View file

@ -4,42 +4,48 @@ context("First Day of the Week", () => {
});
beforeEach(() => {
cy.visit('/app/system-settings');
cy.findByText('Date and Number Format').click();
cy.visit("/app/system-settings");
cy.findByText("Date and Number Format").click();
});
it("Date control starts with same day as selected in System Settings", () => {
cy.intercept('POST', '/api/method/frappe.core.doctype.system_settings.system_settings.load').as("load_settings");
cy.fill_field('first_day_of_the_week', 'Tuesday', 'Select');
cy.findByRole('button', {name: 'Save'}).click();
cy.intercept(
"POST",
"/api/method/frappe.core.doctype.system_settings.system_settings.load"
).as("load_settings");
cy.fill_field("first_day_of_the_week", "Tuesday", "Select");
cy.findByRole("button", { name: "Save" }).click();
cy.wait("@load_settings");
cy.dialog({
title: 'Date',
title: "Date",
fields: [
{
label: 'Date',
fieldname: 'date',
fieldtype: 'Date'
}
]
label: "Date",
fieldname: "date",
fieldtype: "Date",
},
],
});
cy.get_field('date').click();
cy.get('.datepicker--day-name').eq(0).should('have.text', 'Tu');
cy.get_field("date").click();
cy.get(".datepicker--day-name").eq(0).should("have.text", "Tu");
});
it("Calendar view starts with same day as selected in System Settings", () => {
cy.intercept('POST', '/api/method/frappe.core.doctype.system_settings.system_settings.load').as("load_settings");
cy.fill_field('first_day_of_the_week', 'Monday', 'Select');
cy.findByRole('button', {name: 'Save'}).click();
cy.intercept(
"POST",
"/api/method/frappe.core.doctype.system_settings.system_settings.load"
).as("load_settings");
cy.fill_field("first_day_of_the_week", "Monday", "Select");
cy.findByRole("button", { name: "Save" }).click();
cy.wait("@load_settings");
cy.visit("app/todo/view/calendar/default");
cy.get('.fc-day-header > span').eq(0).should('have.text', 'Mon');
cy.get(".fc-day-header > span").eq(0).should("have.text", "Mon");
});
after(() => {
cy.visit('/app/system-settings');
cy.findByText('Date and Number Format').click();
cy.fill_field('first_day_of_the_week', 'Sunday', 'Select');
cy.findByRole('button', {name: 'Save'}).click();
cy.visit("/app/system-settings");
cy.findByText("Date and Number Format").click();
cy.fill_field("first_day_of_the_week", "Sunday", "Select");
cy.findByRole("button", { name: "Save" }).click();
});
});
});

View file

@ -1,79 +1,85 @@
context('Folder Navigation', () => {
context("Folder Navigation", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.visit('/app/file');
cy.visit("/app/file");
});
it('Adding Folders', () => {
it("Adding Folders", () => {
//Adding filter to go into the home folder
cy.get('.filter-selector > .btn').findByText('1 filter').click();
cy.findByRole('button', {name: 'Clear Filters'}).click();
cy.get('.filter-action-buttons > .text-muted').findByText('+ Add a Filter').click();
cy.get('.fieldname-select-area > .awesomplete > .form-control').type('Fol{enter}');
cy.get('.filter-field > .form-group > .link-field > .awesomplete > .input-with-feedback').type('Home{enter}');
cy.get('.filter-action-buttons > div > .btn-primary').findByText('Apply Filters').click();
cy.get(".filter-selector > .btn").findByText("1 filter").click();
cy.findByRole("button", { name: "Clear Filters" }).click();
cy.get(".filter-action-buttons > .text-muted").findByText("+ Add a Filter").click();
cy.get(".fieldname-select-area > .awesomplete > .form-control").type("Fol{enter}");
cy.get(
".filter-field > .form-group > .link-field > .awesomplete > .input-with-feedback"
).type("Home{enter}");
cy.get(".filter-action-buttons > div > .btn-primary").findByText("Apply Filters").click();
//Adding folder (Test Folder)
cy.get('.menu-btn-group > .btn').click();
cy.get('.menu-btn-group [data-label="New Folder"]').click();
cy.get('form > [data-fieldname="value"]').type('Test Folder');
cy.findByRole('button', {name: 'Create'}).click();
cy.click_menu_button("New Folder");
cy.fill_field("value", "Test Folder");
cy.click_modal_primary_button("Create");
});
it('Navigating the nested folders, checking if the URL formed is correct, checking if the added content in the child folder is correct', () => {
it("Navigating the nested folders, checking if the URL formed is correct, checking if the added content in the child folder is correct", () => {
//Navigating inside the Attachments folder
cy.get('[title="Attachments"] > span').click();
//To check if the URL formed after visiting the attachments folder is correct
cy.location('pathname').should('eq', '/app/file/view/home/Attachments');
cy.visit('/app/file/view/home/Attachments');
cy.location("pathname").should("eq", "/app/file/view/home/Attachments");
cy.visit("/app/file/view/home/Attachments");
//Adding folder inside the attachments folder
cy.get('.menu-btn-group > .btn').click();
cy.get('.menu-btn-group [data-label="New Folder"]').click();
cy.get('form > [data-fieldname="value"]').type('Test Folder');
cy.findByRole('button', {name: 'Create'}).click();
cy.click_menu_button("New Folder");
cy.fill_field("value", "Test Folder");
cy.click_modal_primary_button("Create");
//Navigating inside the added folder in the Attachments folder
cy.get('[title="Test Folder"] > span').click();
//To check if the URL is correct after visiting the Test Folder
cy.location('pathname').should('eq', '/app/file/view/home/Attachments/Test%20Folder');
cy.visit('/app/file/view/home/Attachments/Test%20Folder');
cy.location("pathname").should("eq", "/app/file/view/home/Attachments/Test%20Folder");
cy.visit("/app/file/view/home/Attachments/Test%20Folder");
//Adding a file inside the Test Folder
cy.findByRole('button', {name: 'Add File'}).eq(0).click({force: true});
cy.get('.file-uploader').findByText('Link').click();
cy.get('.input-group > .form-control').type('https://wallpaperplay.com/walls/full/8/2/b/72402.jpg');
cy.findByRole('button', {name: 'Upload'}).click();
cy.findByRole("button", { name: "Add File" }).eq(0).click({ force: true });
cy.get(".file-uploader").findByText("Link").click();
cy.get(".input-group > .form-control").type(
"https://wallpaperplay.com/walls/full/8/2/b/72402.jpg"
);
cy.click_modal_primary_button("Upload");
//To check if the added file is present in the Test Folder
cy.get('span.level-item > span').should('contain', 'Test Folder');
cy.get('.list-row-container').eq(0).should('contain.text', '72402.jpg');
cy.get('.list-row-checkbox').eq(0).click();
cy.get("span.level-item > span").should("contain", "Test Folder");
cy.get(".list-row-container").eq(0).should("contain.text", "72402.jpg");
cy.get(".list-row-checkbox").eq(0).click();
cy.intercept({
method: "POST",
url: "api/method/frappe.desk.reportview.delete_items",
}).as("file_deleted");
//Deleting the added file from the Test folder
cy.findByRole('button', {name: 'Actions'}).click();
cy.get('.actions-btn-group [data-label="Delete"]').click();
cy.wait(700);
cy.findByRole('button', {name: 'Yes'}).click();
cy.wait(700);
cy.click_action_button("Delete");
cy.click_modal_primary_button("Yes");
cy.wait("@file_deleted");
//Deleting the Test Folder
cy.visit('/app/file/view/home/Attachments');
cy.get('.list-row-checkbox').eq(0).click();
cy.findByRole('button', {name: 'Actions'}).click();
cy.get('.actions-btn-group [data-label="Delete"]').click();
cy.findByRole('button', {name: 'Yes'}).click();
cy.visit("/app/file/view/home/Attachments");
cy.get(".list-row-checkbox").eq(0).click();
cy.click_action_button("Delete");
cy.click_modal_primary_button("Yes");
cy.wait("@file_deleted");
});
it('Deleting Test Folder from the home', () => {
//Deleting the Test Folder added in the home directory
cy.visit('/app/file/view/home');
cy.get('.level-left > .list-subject > .file-select >.list-row-checkbox').eq(0).click({force: true, delay: 500});
cy.findByRole('button', {name: 'Actions'}).click();
cy.get('.actions-btn-group [data-label="Delete"]').click();
cy.findByRole('button', {name: 'Yes'}).click();
it("Deleting Test Folder from the home", () => {
//Deleting the Test Folder added in the home directory
cy.visit("/app/file/view/home");
cy.get(".level-left > .list-subject > .file-select >.list-row-checkbox")
.eq(0)
.click({ force: true, delay: 500 });
cy.click_action_button("Delete");
cy.click_modal_primary_button("Yes");
});
});
});

View file

@ -1,81 +1,170 @@
context('Form', () => {
context("Form", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.window().its('frappe').then(frappe => {
return frappe.call("frappe.tests.ui_test_helpers.create_contact_records");
});
cy.visit("/app/website");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.call("frappe.tests.ui_test_helpers.create_contact_records");
});
});
it('create a new form', () => {
cy.visit('/app/todo/new');
cy.get_field('description', 'Text Editor').type('this is a test todo', {force: true}).wait(200);
cy.get('.page-title').should('contain', 'Not Saved');
it("create a new form", () => {
cy.visit("/app/todo/new");
cy.get_field("description", "Text Editor")
.type("this is a test todo", { force: true })
.wait(200);
cy.get(".page-title").should("contain", "Not Saved");
cy.intercept({
method: 'POST',
url: 'api/method/frappe.desk.form.save.savedocs'
}).as('form_save');
cy.get('.primary-action').click();
cy.wait('@form_save').its('response.statusCode').should('eq', 200);
method: "POST",
url: "api/method/frappe.desk.form.save.savedocs",
}).as("form_save");
cy.get(".primary-action").click();
cy.wait("@form_save").its("response.statusCode").should("eq", 200);
cy.visit('/app/todo');
cy.get('.page-head').findByTitle('To Do').should('exist');
cy.get('.list-row').should('contain', 'this is a test todo');
cy.go_to_list("ToDo");
cy.clear_filters();
cy.get(".page-head").findByTitle("To Do").should("exist");
cy.get(".list-row").should("contain", "this is a test todo");
});
it('navigates between documents with child table list filters applied', () => {
cy.visit('/app/contact');
it("navigates between documents with child table list filters applied", () => {
cy.visit("/app/contact");
cy.clear_filters();
cy.get('.standard-filter-section [data-fieldname="name"] input').type('Test Form Contact 3').blur();
cy.click_listview_row_item(0);
cy.get('.standard-filter-section [data-fieldname="name"] input')
.type("Test Form Contact 3")
.blur();
cy.click_listview_row_item_with_text("Test Form Contact 3");
cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist');
cy.get('.prev-doc').should('be.visible').click();
cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible');
cy.get("#page-Contact .page-head").findByTitle("Test Form Contact 3").should("exist");
cy.get(".prev-doc").should("be.visible").click();
cy.get(".msgprint-dialog .modal-body").contains("No further records").should("be.visible");
cy.hide_dialog();
cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist');
cy.get('.next-doc').should('be.visible').click();
cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible');
cy.get("#page-Contact .page-head").findByTitle("Test Form Contact 3").should("exist");
cy.get(".next-doc").should("be.visible").click();
cy.get(".msgprint-dialog .modal-body").contains("No further records").should("be.visible");
cy.hide_dialog();
cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist');
cy.get("#page-Contact .page-head").findByTitle("Test Form Contact 3").should("exist");
// clear filters
cy.visit('/app/contact');
cy.visit("/app/contact");
cy.clear_filters();
});
it('validates behaviour of Data options validations in child table', () => {
it("validates behaviour of Data options validations in child table", () => {
// test email validations for set_invalid controller
let website_input = 'website.in';
let valid_email = 'user@email.com';
let expectBackgroundColor = 'rgb(255, 245, 245)';
let website_input = "website.in";
let valid_email = "user@email.com";
let expectBackgroundColor = "rgb(255, 245, 245)";
cy.visit('/app/contact/new');
cy.get('.frappe-control[data-fieldname="email_ids"]').as('table');
cy.get('@table').find('button.grid-add-row').click();
cy.get('@table').find('button.grid-add-row').click();
cy.get('@table').find('[data-idx="1"]').as('row1');
cy.get('@table').find('[data-idx="2"]').as('row2');
cy.get('@row1').click();
cy.get('@row1').find('input.input-with-feedback.form-control').as('email_input1');
cy.visit("/app/contact/new");
cy.get('.frappe-control[data-fieldname="email_ids"]').as("table");
cy.get("@table").find("button.grid-add-row").click();
cy.get("@table").find("button.grid-add-row").click();
cy.get("@table").find('[data-idx="1"]').as("row1");
cy.get("@table").find('[data-idx="2"]').as("row2");
cy.get("@row1").click();
cy.get("@row1").find("input.input-with-feedback.form-control").as("email_input1");
cy.get('@email_input1').type(website_input, { waitForAnimations: false });
cy.fill_field('company_name', 'Test Company');
cy.get("@email_input1").type(website_input, { waitForAnimations: false });
cy.fill_field("company_name", "Test Company");
cy.get('@row2').click();
cy.get('@row2').find('input.input-with-feedback.form-control').as('email_input2');
cy.get('@email_input2').type(valid_email, { waitForAnimations: false });
cy.get("@row2").click();
cy.get("@row2").find("input.input-with-feedback.form-control").as("email_input2");
cy.get("@email_input2").type(valid_email, { waitForAnimations: false });
cy.get('@row1').click();
cy.get('@email_input1').should($div => {
cy.get("@row1").click();
cy.get("@email_input1").should(($div) => {
const style = window.getComputedStyle($div[0]);
expect(style.backgroundColor).to.equal(expectBackgroundColor);
});
cy.get('@email_input1').should('have.class', 'invalid');
cy.get("@email_input1").should("have.class", "invalid");
cy.get('@row2').click();
cy.get('@email_input2').should('not.have.class', 'invalid');
cy.get("@row2").click();
cy.get("@email_input2").should("not.have.class", "invalid");
});
it("Shows version conflict warning", { scrollBehavior: false }, () => {
cy.visit("/app/todo");
cy.insert_doc("ToDo", { description: "old" }).then((doc) => {
cy.visit(`/app/todo/${doc.name}`);
// make form dirty
cy.fill_field("status", "Cancelled", "Select");
// update doc using api - simulating parallel change by another user
cy.update_doc("ToDo", doc.name, { status: "Closed" }).then(() => {
cy.findByRole("button", { name: "Refresh" }).click();
cy.get_field("status", "Select").should("have.value", "Closed");
});
});
});
it("let user undo/redo field value changes", { scrollBehavior: false }, () => {
const jump_to_field = (field_label) => {
cy.get("body")
.type("{esc}") // lose focus if any
.type("{ctrl+j}") // jump to field
.type(field_label)
.wait(500)
.type("{enter}")
.wait(200)
.type("{enter}")
.wait(500);
};
const type_value = (value) => {
cy.focused().clear().type(value).type("{esc}");
};
const undo = () => cy.get("body").type("{esc}").type("{ctrl+z}").wait(500);
const redo = () => cy.get("body").type("{esc}").type("{ctrl+y}").wait(500);
cy.new_form("User");
jump_to_field("Email");
type_value("admin@example.com");
jump_to_field("Username");
type_value("admin42");
jump_to_field("Birth Date");
type_value("12-31-01");
jump_to_field("Send Welcome Email");
cy.focused().uncheck();
// make a mistake
jump_to_field("Username");
type_value("admin24");
// undo behaviour
undo();
cy.get_field("username").should("have.value", "admin42");
// redo behaviour
redo();
cy.get_field("username").should("have.value", "admin24");
// undo everything & redo everything, ensure same values at the end
undo();
undo();
undo();
undo();
undo();
redo();
redo();
redo();
redo();
redo();
cy.get_field("username").should("have.value", "admin24");
cy.get_field("email").should("have.value", "admin@example.com");
cy.get_field("birth_date").should("have.value", "12-31-2001"); // parsed value
cy.get_field("send_welcome_email").should("not.be.checked");
});
});

View file

@ -1,31 +1,30 @@
import doctype_with_tab_break from '../fixtures/doctype_with_tab_break';
import doctype_with_tab_break from "../fixtures/doctype_with_tab_break";
const doctype_name = doctype_with_tab_break.name;
context("Form Tab Break", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.insert_doc('DocType', doctype_with_tab_break, true);
cy.visit("/app/website");
return cy.insert_doc("DocType", doctype_with_tab_break, true);
});
it("Should switch tab and open correct tabs on validation error", () => {
cy.new_form(doctype_name);
// test tab switch
cy.findByRole("tab", {name: "Tab 2"}).click();
cy.findByRole("tab", { name: "Tab 2" }).click();
cy.findByText("Phone");
cy.findByRole("tab", {name: "Details"}).click();
cy.findByRole("tab", { name: "Details" }).click();
cy.findByText("Name");
// form should switch to the tab with un-filled mandatory field
cy.fill_field("username", "Test");
cy.findByRole("button", {name: "Save"}).click();
cy.findByRole("button", { name: "Save" }).click();
cy.findByText("Missing Fields");
cy.hide_dialog();
cy.findByText("Phone");
cy.fill_field("phone", "12345678");
cy.findByRole("button", {name: "Save"}).click();
cy.findByRole("button", { name: "Save" }).click();
// After save, first tab should have dashboard
cy.get(".form-tabs > .nav-item").eq(0).click();
cy.findByText("Connections");
});
});
});

View file

@ -1,88 +1,94 @@
context('Form Tour', () => {
context.skip("Form Tour", () => {
before(() => {
cy.login();
cy.visit('/app/form-tour');
return cy.window().its('frappe').then(frappe => {
return frappe.call("frappe.tests.ui_test_helpers.create_form_tour");
});
cy.visit("/app");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.call("frappe.tests.ui_test_helpers.create_form_tour");
});
});
const open_test_form_tour = () => {
cy.visit('/app/form-tour/Test Form Tour');
cy.findByRole('button', {name: 'Show Tour'}).should('be.visible').as('show_tour');
cy.get('@show_tour').click();
cy.visit("/app/form-tour/Test Form Tour");
cy.findByRole("button", { name: "Show Tour" }).should("be.visible").as("show_tour");
cy.get("@show_tour").click();
cy.wait(500);
cy.url().should('include', '/app/contact');
cy.url().should("include", "/app/contact");
};
it('jump to a form tour', open_test_form_tour);
it("jump to a form tour", open_test_form_tour);
it('navigates a form tour', () => {
it("navigates a form tour", () => {
open_test_form_tour();
cy.get('.frappe-driver').should('be.visible');
cy.get('.frappe-control[data-fieldname="first_name"]').as('first_name');
cy.get('@first_name').should('have.class', 'driver-highlighted-element');
cy.get('.frappe-driver').findByRole('button', {name: 'Next'}).as('next_btn');
cy.get(".frappe-driver").should("be.visible");
cy.get('.frappe-control[data-fieldname="first_name"]').as("first_name");
cy.get("@first_name").should("have.class", "driver-highlighted-element");
cy.get(".frappe-driver").findByRole("button", { name: "Next" }).as("next_btn");
// next btn shouldn't move to next step, if first name is not entered
cy.get('@next_btn').click();
cy.get("@next_btn").click();
cy.wait(500);
cy.get('@first_name').should('have.class', 'driver-highlighted-element');
cy.get("@first_name").should("have.class", "driver-highlighted-element");
// after filling the field, next step should be highlighted
cy.fill_field('first_name', 'Test Name', 'Data');
cy.fill_field("first_name", "Test Name", "Data");
cy.wait(500);
cy.get('@next_btn').click();
cy.get("@next_btn").click();
cy.wait(500);
// assert field is highlighted
cy.get('.frappe-control[data-fieldname="last_name"]').as('last_name');
cy.get('@last_name').should('have.class', 'driver-highlighted-element');
cy.get('.frappe-control[data-fieldname="last_name"]').as("last_name");
cy.get("@last_name").should("have.class", "driver-highlighted-element");
// after filling the field, next step should be highlighted
cy.fill_field('last_name', 'Test Last Name', 'Data');
cy.fill_field("last_name", "Test Last Name", "Data");
cy.wait(500);
cy.get('@next_btn').click();
cy.get("@next_btn").click();
cy.wait(500);
// assert field is highlighted
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('phone_nos');
cy.get('@phone_nos').should('have.class', 'driver-highlighted-element');
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("phone_nos");
cy.get("@phone_nos").should("have.class", "driver-highlighted-element");
// move to next step
cy.wait(500);
cy.get('@next_btn').click();
cy.get("@next_btn").click();
cy.wait(500);
// assert add row btn is highlighted
cy.get('@phone_nos').find('.grid-add-row').as('add_row');
cy.get('@add_row').should('have.class', 'driver-highlighted-element');
cy.get("@phone_nos").find(".grid-add-row").as("add_row");
cy.get("@add_row").should("have.class", "driver-highlighted-element");
// add a row & move to next step
cy.wait(500);
cy.get('@add_row').click();
cy.get("@add_row").click();
cy.wait(500);
// assert table field is highlighted
cy.get('.grid-row-open .frappe-control[data-fieldname="phone"]').as('phone');
cy.get('@phone').should('have.class', 'driver-highlighted-element');
cy.get('.grid-row-open .frappe-control[data-fieldname="phone"]').as("phone");
cy.get("@phone").should("have.class", "driver-highlighted-element");
// enter value in a table field
let field = cy.fill_table_field('phone_nos', '1', 'phone', '1234567890');
let field = cy.fill_table_field("phone_nos", "1", "phone", "1234567890");
field.blur();
// move to collapse row step
cy.wait(500);
cy.get('.driver-popover-title').contains('Test Title 4').siblings().get('@next_btn').click();
cy.get(".driver-popover-title")
.contains("Test Title 4")
.siblings()
.get("@next_btn")
.click();
cy.wait(500);
// collapse row
cy.get('.grid-row-open .grid-collapse-row').click();
cy.get(".grid-row-open .grid-collapse-row").click();
cy.wait(500);
// assert save btn is highlighted
cy.get('.primary-action').should('have.class', 'driver-highlighted-element');
cy.get(".primary-action").should("have.class", "driver-highlighted-element");
cy.wait(500);
cy.get('.frappe-driver').findByRole('button', {name: 'Save'}).should('be.visible');
cy.get(".frappe-driver").findByRole("button", { name: "Save" }).should("be.visible");
});
});

View file

@ -1,92 +1,114 @@
context('Grid', () => {
context("Grid", () => {
beforeEach(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
before(() => {
cy.login();
cy.visit('/app/website');
return cy.window().its('frappe').then(frappe => {
return frappe.call("frappe.tests.ui_test_helpers.create_contact_phone_nos_records");
});
cy.visit("/app/website");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.call(
"frappe.tests.ui_test_helpers.create_contact_phone_nos_records"
);
});
});
it('update docfield property using update_docfield_property', () => {
cy.visit('/app/contact/Test Contact');
cy.window().its("cur_frm").then(frm => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
let field = frm.get_field("phone_nos");
field.grid.update_docfield_property("is_primary_phone", "hidden", true);
it("update docfield property using update_docfield_property", () => {
cy.visit("/app/contact/Test Contact");
cy.window()
.its("cur_frm")
.then((frm) => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
let field = frm.get_field("phone_nos");
field.grid.update_docfield_property("is_primary_phone", "hidden", true);
cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_phone"]').should("be.hidden");
cy.get('@table-form').find('.grid-footer-toolbar').click();
cy.get("@table").find('[data-idx="1"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get("@table-form")
.find('.frappe-control[data-fieldname="is_primary_phone"]')
.should("be.hidden");
cy.get("@table-form").find(".grid-footer-toolbar").click();
cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_phone"]').should("be.hidden");
cy.get('@table-form').find('.grid-footer-toolbar').click();
});
cy.get("@table").find('[data-idx="2"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get("@table-form")
.find('.frappe-control[data-fieldname="is_primary_phone"]')
.should("be.hidden");
cy.get("@table-form").find(".grid-footer-toolbar").click();
});
});
it('update docfield property using toggle_display', () => {
cy.visit('/app/contact/Test Contact');
cy.window().its("cur_frm").then(frm => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
let field = frm.get_field("phone_nos");
field.grid.toggle_display("is_primary_mobile_no", false);
it("update docfield property using toggle_display", () => {
cy.visit("/app/contact/Test Contact");
cy.window()
.its("cur_frm")
.then((frm) => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
let field = frm.get_field("phone_nos");
field.grid.toggle_display("is_primary_mobile_no", false);
cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_mobile_no"]').should("be.hidden");
cy.get('@table-form').find('.grid-footer-toolbar').click();
cy.get("@table").find('[data-idx="1"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get("@table-form")
.find('.frappe-control[data-fieldname="is_primary_mobile_no"]')
.should("be.hidden");
cy.get("@table-form").find(".grid-footer-toolbar").click();
cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_mobile_no"]').should("be.hidden");
cy.get('@table-form').find('.grid-footer-toolbar').click();
});
cy.get("@table").find('[data-idx="2"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get("@table-form")
.find('.frappe-control[data-fieldname="is_primary_mobile_no"]')
.should("be.hidden");
cy.get("@table-form").find(".grid-footer-toolbar").click();
});
});
it('update docfield property using toggle_enable', () => {
cy.visit('/app/contact/Test Contact');
cy.window().its("cur_frm").then(frm => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
let field = frm.get_field("phone_nos");
field.grid.toggle_enable("phone", false);
it("update docfield property using toggle_enable", () => {
cy.visit("/app/contact/Test Contact");
cy.window()
.its("cur_frm")
.then((frm) => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
let field = frm.get_field("phone_nos");
field.grid.toggle_enable("phone", false);
cy.get("@table").find('[data-idx="1"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get("@table-form")
.find('.frappe-control[data-fieldname="phone"] .control-value')
.should("have.class", "like-disabled-input");
cy.get("@table-form").find(".grid-footer-toolbar").click();
cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get('@table-form').find('.frappe-control[data-fieldname="phone"] .control-value').should('have.class', 'like-disabled-input');
cy.get('@table-form').find('.grid-footer-toolbar').click();
cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get('@table-form').find('.frappe-control[data-fieldname="phone"] .control-value').should('have.class', 'like-disabled-input');
cy.get('@table-form').find('.grid-footer-toolbar').click();
});
cy.get("@table").find('[data-idx="2"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get("@table-form")
.find('.frappe-control[data-fieldname="phone"] .control-value')
.should("have.class", "like-disabled-input");
cy.get("@table-form").find(".grid-footer-toolbar").click();
});
});
it('update docfield property using toggle_reqd', () => {
cy.visit('/app/contact/Test Contact');
cy.window().its("cur_frm").then(frm => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
let field = frm.get_field("phone_nos");
field.grid.toggle_reqd("phone", false);
it("update docfield property using toggle_reqd", () => {
cy.visit("/app/contact/Test Contact");
cy.window()
.its("cur_frm")
.then((frm) => {
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
let field = frm.get_field("phone_nos");
field.grid.toggle_reqd("phone", false);
cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get_field("phone").as('phone-field');
cy.get('@phone-field').focus().clear().wait(500).blur();
cy.get('@phone-field').should("not.have.class", "has-error");
cy.get('@table-form').find('.grid-footer-toolbar').click();
cy.get("@table").find('[data-idx="1"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get_field("phone").as("phone-field");
cy.get("@phone-field").focus().clear().wait(500).blur();
cy.get("@phone-field").should("not.have.class", "has-error");
cy.get("@table-form").find(".grid-footer-toolbar").click();
cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
cy.get('.grid-row-open').as('table-form');
cy.get_field("phone").as('phone-field');
cy.get('@phone-field').focus().clear().wait(500).blur();
cy.get('@phone-field').should("not.have.class", "has-error");
cy.get('@table-form').find('.grid-footer-toolbar').click();
});
cy.get("@table").find('[data-idx="2"] .edit-grid-row').click();
cy.get(".grid-row-open").as("table-form");
cy.get_field("phone").as("phone-field");
cy.get("@phone-field").focus().clear().wait(500).blur();
cy.get("@phone-field").should("not.have.class", "has-error");
cy.get("@table-form").find(".grid-footer-toolbar").click();
});
});
});

View file

@ -1,23 +1,23 @@
context('Grid Configuration', () => {
context("Grid Configuration", () => {
beforeEach(() => {
cy.login();
cy.visit('/app/doctype/User');
cy.visit("/app/doctype/User");
});
it('Set user wise grid settings', () => {
it("Set user wise grid settings", () => {
cy.wait(100);
cy.get('.frappe-control[data-fieldname="fields"]').as('table');
cy.get('@table').find('.icon-sm').click();
cy.get('.frappe-control[data-fieldname="fields"]').as("table");
cy.get("@table").find(".icon-sm").click();
cy.wait(100);
cy.get('.frappe-control[data-fieldname="fields_html"]').as('modal');
cy.get('@modal').find('.add-new-fields').click();
cy.get('.frappe-control[data-fieldname="fields_html"]').as("modal");
cy.get("@modal").find(".add-new-fields").click();
cy.wait(100);
cy.get('[type="checkbox"][data-unit="read_only"]').check();
cy.findByRole('button', {name: 'Add'}).click();
cy.findByRole("button", { name: "Add" }).click();
cy.wait(100);
cy.get('[data-fieldname="options"]').invoke('attr', 'value', '1');
cy.get('.form-control.column-width[data-fieldname="options"]').trigger('change');
cy.findByRole('button', {name: 'Update'}).click();
cy.get('[data-fieldname="options"]').invoke("attr", "value", "1");
cy.get('.form-control.column-width[data-fieldname="options"]').trigger("change");
cy.findByRole("button", { name: "Update" }).click();
cy.wait(200);
cy.get('[title="Read Only"').should('be.visible');
cy.get('[title="Read Only"').should("be.visible");
});
});
});

View file

@ -1,40 +1,47 @@
context('Grid Keyboard Shortcut', () => {
context("Grid Keyboard Shortcut", () => {
let total_count = 0;
before(() => {
cy.login();
});
beforeEach(() => {
cy.reload();
cy.visit('/app/contact/new-contact-1');
cy.visit("/app/contact/new-contact-1");
cy.get('.frappe-control[data-fieldname="email_ids"]').find(".grid-add-row").click();
});
it('Insert new row at the end', () => {
cy.add_new_row_in_grid('{ctrl}{shift}{downarrow}', (cy, total_count) => {
cy.get('[data-name="new-contact-email-1"]').should('have.attr', 'data-idx', `${total_count+1}`);
}, total_count);
it("Insert new row at the end", () => {
cy.add_new_row_in_grid(
"{ctrl}{shift}{downarrow}",
(cy, total_count) => {
cy.get('[data-name="new-contact-email-1"]').should(
"have.attr",
"data-idx",
`${total_count + 1}`
);
},
total_count
);
});
it('Insert new row at the top', () => {
cy.add_new_row_in_grid('{ctrl}{shift}{uparrow}', (cy) => {
cy.get('[data-name="new-contact-email-1"]').should('have.attr', 'data-idx', '2');
it("Insert new row at the top", () => {
cy.add_new_row_in_grid("{ctrl}{shift}{uparrow}", (cy) => {
cy.get('[data-name="new-contact-email-1"]').should("have.attr", "data-idx", "2");
});
});
it('Insert new row below', () => {
cy.add_new_row_in_grid('{ctrl}{downarrow}', (cy) => {
cy.get('[data-name="new-contact-email-1"]').should('have.attr', 'data-idx', '1');
it("Insert new row below", () => {
cy.add_new_row_in_grid("{ctrl}{downarrow}", (cy) => {
cy.get('[data-name="new-contact-email-1"]').should("have.attr", "data-idx", "1");
});
});
it('Insert new row above', () => {
cy.add_new_row_in_grid('{ctrl}{uparrow}', (cy) => {
cy.get('[data-name="new-contact-email-1"]').should('have.attr', 'data-idx', '2');
it("Insert new row above", () => {
cy.add_new_row_in_grid("{ctrl}{uparrow}", (cy) => {
cy.get('[data-name="new-contact-email-1"]').should("have.attr", "data-idx", "2");
});
});
});
Cypress.Commands.add('add_new_row_in_grid', (shortcut_keys, callbackFn, total_count) => {
cy.get('.frappe-control[data-fieldname="email_ids"]').as('table');
cy.get('@table').find('.grid-body [data-fieldname="email_id"]').first().click();
cy.get('@table').find('.grid-body [data-fieldname="email_id"]')
.first().type(shortcut_keys);
Cypress.Commands.add("add_new_row_in_grid", (shortcut_keys, callbackFn, total_count) => {
cy.get('.frappe-control[data-fieldname="email_ids"]').as("table");
cy.get("@table").find('.grid-body [data-fieldname="email_id"]').first().click();
cy.get("@table").find('.grid-body [data-fieldname="email_id"]').first().type(shortcut_keys);
callbackFn(cy, total_count);
});
});

View file

@ -1,65 +1,73 @@
context('Grid Pagination', () => {
context("Grid Pagination", () => {
beforeEach(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
before(() => {
cy.login();
cy.visit('/app/website');
return cy.window().its('frappe').then(frappe => {
return frappe.call("frappe.tests.ui_test_helpers.create_contact_phone_nos_records");
});
cy.visit("/app/website");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.call(
"frappe.tests.ui_test_helpers.create_contact_phone_nos_records"
);
});
});
it('creates pages for child table', () => {
cy.visit('/app/contact/Test Contact');
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
cy.get('@table').find('.current-page-number').should('have.value', '1');
cy.get('@table').find('.total-page-number').should('contain', '20');
cy.get('@table').find('.grid-body .grid-row').should('have.length', 50);
it("creates pages for child table", () => {
cy.visit("/app/contact/Test Contact");
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
cy.get("@table").find(".current-page-number").should("have.value", "1");
cy.get("@table").find(".total-page-number").should("contain", "20");
cy.get("@table").find(".grid-body .grid-row").should("have.length", 50);
});
it('goes to the next and previous page', () => {
cy.visit('/app/contact/Test Contact');
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
cy.get('@table').find('.next-page').click();
cy.get('@table').find('.current-page-number').should('have.value', '2');
cy.get('@table').find('.grid-body .grid-row').first().should('have.attr', 'data-idx', '51');
cy.get('@table').find('.prev-page').click();
cy.get('@table').find('.current-page-number').should('have.value', '1');
cy.get('@table').find('.grid-body .grid-row').first().should('have.attr', 'data-idx', '1');
it("goes to the next and previous page", () => {
cy.visit("/app/contact/Test Contact");
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
cy.get("@table").find(".next-page").click();
cy.get("@table").find(".current-page-number").should("have.value", "2");
cy.get("@table")
.find(".grid-body .grid-row")
.first()
.should("have.attr", "data-idx", "51");
cy.get("@table").find(".prev-page").click();
cy.get("@table").find(".current-page-number").should("have.value", "1");
cy.get("@table").find(".grid-body .grid-row").first().should("have.attr", "data-idx", "1");
});
it('adds and deletes rows and changes page', () => {
cy.visit('/app/contact/Test Contact');
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
cy.get('@table').findByRole('button', {name: 'Add Row'}).click();
cy.get('@table').find('.grid-body .row-index').should('contain', 1001);
cy.get('@table').find('.current-page-number').should('have.value', '21');
cy.get('@table').find('.total-page-number').should('contain', '21');
cy.get('@table').find('.grid-body .grid-row .grid-row-check').click({ force: true });
cy.get('@table').findByRole('button', {name: 'Delete'}).click();
cy.get('@table').find('.grid-body .row-index').last().should('contain', 1000);
cy.get('@table').find('.current-page-number').should('have.value', '20');
cy.get('@table').find('.total-page-number').should('contain', '20');
it("adds and deletes rows and changes page", () => {
cy.visit("/app/contact/Test Contact");
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
cy.get("@table").findByRole("button", { name: "Add Row" }).click();
cy.get("@table").find(".grid-body .row-index").should("contain", 1001);
cy.get("@table").find(".current-page-number").should("have.value", "21");
cy.get("@table").find(".total-page-number").should("contain", "21");
cy.get("@table").find(".grid-body .grid-row .grid-row-check").click({ force: true });
cy.get("@table").findByRole("button", { name: "Delete" }).click();
cy.get("@table").find(".grid-body .row-index").last().should("contain", 1000);
cy.get("@table").find(".current-page-number").should("have.value", "20");
cy.get("@table").find(".total-page-number").should("contain", "20");
});
it('go to specific page, use up and down arrow, type characters, 0 page and more than existing page', () => {
cy.visit('/app/contact/Test Contact');
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
cy.get('@table').find('.current-page-number').focus().clear().type('17').blur();
cy.get('@table').find('.grid-body .row-index').should('contain', 801);
it("go to specific page, use up and down arrow, type characters, 0 page and more than existing page", () => {
cy.visit("/app/contact/Test Contact");
cy.get('.frappe-control[data-fieldname="phone_nos"]').as("table");
cy.get("@table").find(".current-page-number").focus().clear().type("17").blur();
cy.get("@table").find(".grid-body .row-index").should("contain", 801);
cy.get('@table').find('.current-page-number').focus().type('{uparrow}{uparrow}');
cy.get('@table').find('.current-page-number').should('have.value', '19');
cy.get("@table").find(".current-page-number").focus().type("{uparrow}{uparrow}");
cy.get("@table").find(".current-page-number").should("have.value", "19");
cy.get('@table').find('.current-page-number').focus().type('{downarrow}{downarrow}');
cy.get('@table').find('.current-page-number').should('have.value', '17');
cy.get("@table").find(".current-page-number").focus().type("{downarrow}{downarrow}");
cy.get("@table").find(".current-page-number").should("have.value", "17");
cy.get('@table').find('.current-page-number').focus().clear().type('700').blur();
cy.get('@table').find('.current-page-number').should('have.value', '20');
cy.get("@table").find(".current-page-number").focus().clear().type("700").blur();
cy.get("@table").find(".current-page-number").should("have.value", "20");
cy.get('@table').find('.current-page-number').focus().clear().type('0').blur();
cy.get('@table').find('.current-page-number').should('have.value', '1');
cy.get("@table").find(".current-page-number").focus().clear().type("0").blur();
cy.get("@table").find(".current-page-number").should("have.value", "1");
cy.get('@table').find('.current-page-number').focus().clear().type('abc').blur();
cy.get('@table').find('.current-page-number').should('have.value', '1');
cy.get("@table").find(".current-page-number").focus().clear().type("abc").blur();
cy.get("@table").find(".current-page-number").should("have.value", "1");
});
// it('deletes all rows', ()=> {
// cy.visit('/app/contact/Test Contact');
@ -69,4 +77,4 @@ context('Grid Pagination', () => {
// cy.get('.modal-dialog .btn-primary').contains('Yes').click();
// cy.get('@table').find('.grid-body .grid-row').should('have.length', 0);
// });
});
});

View file

@ -1,107 +1,133 @@
import doctype_with_child_table from '../fixtures/doctype_with_child_table';
import child_table_doctype from '../fixtures/child_table_doctype';
import child_table_doctype_1 from '../fixtures/child_table_doctype_1';
import doctype_with_child_table from "../fixtures/doctype_with_child_table";
import child_table_doctype from "../fixtures/child_table_doctype";
import child_table_doctype_1 from "../fixtures/child_table_doctype_1";
const doctype_with_child_table_name = doctype_with_child_table.name;
context('Grid Search', () => {
context("Grid Search", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.visit('/app/website');
cy.insert_doc('DocType', child_table_doctype, true);
cy.insert_doc('DocType', child_table_doctype_1, true);
cy.insert_doc('DocType', doctype_with_child_table, true);
return cy.window().its('frappe').then(frappe => {
return frappe.xcall("frappe.tests.ui_test_helpers.insert_doctype_with_child_table_record", {
name: doctype_with_child_table_name
cy.visit("/app/website");
cy.insert_doc("DocType", child_table_doctype, true);
cy.insert_doc("DocType", child_table_doctype_1, true);
cy.insert_doc("DocType", doctype_with_child_table, true);
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall(
"frappe.tests.ui_test_helpers.insert_doctype_with_child_table_record",
{
name: doctype_with_child_table_name,
}
);
});
});
});
it('Test search row visibility', () => {
cy.window().its('frappe').then(frappe => {
frappe.model.user_settings.save('Doctype With Child Table', 'GridView', {
'Child Table Doctype 1': [
{'fieldname': 'data', 'columns': 2},
{'fieldname': 'barcode', 'columns': 1},
{'fieldname': 'check', 'columns': 1},
{'fieldname': 'rating', 'columns': 2},
{'fieldname': 'duration', 'columns': 2},
{'fieldname': 'date', 'columns': 2}
]
it("Test search row visibility", () => {
cy.window()
.its("frappe")
.then((frappe) => {
frappe.model.user_settings.save("Doctype With Child Table", "GridView", {
"Child Table Doctype 1": [
{ fieldname: "data", columns: 2 },
{ fieldname: "barcode", columns: 1 },
{ fieldname: "check", columns: 1 },
{ fieldname: "rating", columns: 2 },
{ fieldname: "duration", columns: 2 },
{ fieldname: "date", columns: 2 },
],
});
});
});
cy.visit(`/app/doctype-with-child-table/Test Grid Search`);
cy.get('.frappe-control[data-fieldname="child_table_1"]').as('table');
cy.get('@table').find('.grid-row-check:last').click();
cy.get('@table').find('.grid-footer').contains('Delete').click();
cy.get('.grid-heading-row .grid-row .search').should('not.exist');
cy.get('.frappe-control[data-fieldname="child_table_1"]').as("table");
cy.get("@table").find(".grid-row-check:last").click();
cy.get("@table").find(".grid-footer").contains("Delete").click();
cy.get(".grid-heading-row .grid-row .search").should("not.exist");
});
it('test search field for different fieldtypes', () => {
it("test search field for different fieldtypes", () => {
cy.visit(`/app/doctype-with-child-table/Test Grid Search`);
cy.get('.frappe-control[data-fieldname="child_table_1"]').as('table');
cy.get('.frappe-control[data-fieldname="child_table_1"]').as("table");
// Index Column
cy.get('@table').find('.grid-heading-row .row-index.search input').type('3');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 2);
cy.get('@table').find('.grid-heading-row .row-index.search input').clear();
cy.get("@table").find(".grid-heading-row .row-index.search input").type("3");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 2);
cy.get("@table").find(".grid-heading-row .row-index.search input").clear();
// Data Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Data"]').type('Data');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 1);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Data"]').clear();
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Data"]')
.type("Data");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 1);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Data"]').clear();
// Barcode Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Barcode"]').type('092');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 4);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Barcode"]').clear();
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Barcode"]')
.type("092");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 4);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Barcode"]').clear();
// Check Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Check"]').type('1');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 9);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Check"]').clear();
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Check"]').type("1");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 9);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Check"]').clear();
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Check"]').type('0');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 11);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Check"]').clear();
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Check"]').type("0");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 11);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Check"]').clear();
// Rating Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Rating"]').type('3');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 3);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Rating"]').clear();
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Rating"]')
.type("3");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 3);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Rating"]').clear();
// Duration Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Duration"]').type('3d');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 3);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Duration"]').clear();
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Duration"]')
.type("3d");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 3);
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Duration"]')
.clear();
// Date Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Date"]').type('2022');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 4);
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Date"]').clear();
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Date"]')
.type("2022");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 4);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Date"]').clear();
});
it('test with multiple filter', () => {
cy.get('.frappe-control[data-fieldname="child_table_1"]').as('table');
it("test with multiple filter", () => {
cy.get('.frappe-control[data-fieldname="child_table_1"]').as("table");
// Data Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Data"]').type('a');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 10);
cy.get("@table").find('.grid-heading-row .search input[data-fieldtype="Data"]').type("a");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 10);
// Barcode Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Barcode"]').type('0');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 8);
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Barcode"]')
.type("0");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 8);
// Duration Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Duration"]').type('d');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 5);
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Duration"]')
.type("d");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 5);
// Date Column
cy.get('@table').find('.grid-heading-row .search input[data-fieldtype="Date"]').type('02-');
cy.get('@table').find('.grid-body .rows .grid-row').should('have.length', 2);
cy.get("@table")
.find('.grid-heading-row .search input[data-fieldtype="Date"]')
.type("02-");
cy.get("@table").find(".grid-body .rows .grid-row").should("have.length", 2);
});
});
});

View file

@ -0,0 +1,112 @@
context("Kanban Board", () => {
before(() => {
cy.login();
cy.visit("/app");
});
it("Create ToDo Kanban", () => {
cy.visit("/app/todo");
cy.get(".page-actions .custom-btn-group button").click();
cy.get(".page-actions .custom-btn-group ul.dropdown-menu li").contains("Kanban").click();
cy.focused().blur();
cy.fill_field("board_name", "ToDo Kanban", "Data");
cy.fill_field("field_name", "Status", "Select");
cy.click_modal_primary_button("Save");
cy.get(".title-text").should("contain", "ToDo Kanban");
});
it("Create ToDo from kanban", () => {
cy.intercept({
method: "POST",
url: "api/method/frappe.client.save",
}).as("save-todo");
cy.click_listview_primary_button("Add ToDo");
cy.fill_field("description", "Test Kanban ToDo", "Text Editor").wait(300);
cy.get(".modal-footer .btn-primary").last().click();
cy.wait("@save-todo");
});
it("Add and Remove fields", () => {
cy.visit("/app/todo/view/kanban/ToDo Kanban");
cy.intercept(
"POST",
"/api/method/frappe.desk.doctype.kanban_board.kanban_board.save_settings"
).as("save-kanban");
cy.intercept(
"POST",
"/api/method/frappe.desk.doctype.kanban_board.kanban_board.update_order"
).as("update-order");
cy.get(".page-actions .menu-btn-group > .btn").click();
cy.get(".page-actions .menu-btn-group .dropdown-menu li")
.contains("Kanban Settings")
.click();
cy.get(".add-new-fields").click();
cy.get(".checkbox-options .checkbox").contains("ID").click();
cy.get(".checkbox-options .checkbox").contains("Status").first().click();
cy.get(".checkbox-options .checkbox").contains("Priority").click();
cy.get(".modal-footer .btn-primary").last().click();
cy.get(".frappe-control .label-area").contains("Show Labels").click();
cy.click_modal_primary_button("Save");
cy.wait("@save-kanban");
cy.get('.kanban-column[data-column-value="Open"] .kanban-cards').as("open-cards");
cy.get("@open-cards")
.find(".kanban-card .kanban-card-doc")
.first()
.should("contain", "ID:");
cy.get("@open-cards")
.find(".kanban-card .kanban-card-doc")
.first()
.should("contain", "Status:");
cy.get("@open-cards")
.find(".kanban-card .kanban-card-doc")
.first()
.should("contain", "Priority:");
cy.get(".page-actions .menu-btn-group > .btn").click();
cy.get(".page-actions .menu-btn-group .dropdown-menu li")
.contains("Kanban Settings")
.click();
cy.get_open_dialog()
.find(
'.frappe-control[data-fieldname="fields_html"] div[data-label="ID"] .remove-field'
)
.click();
cy.wait("@update-order");
cy.get_open_dialog().find(".frappe-control .label-area").contains("Show Labels").click();
cy.get(".modal-footer .btn-primary").last().click();
cy.wait("@save-kanban");
cy.get("@open-cards")
.find(".kanban-card .kanban-card-doc")
.first()
.should("not.contain", "ID:");
});
// it('Drag todo', () => {
// cy.intercept({
// method: 'POST',
// url: 'api/method/frappe.desk.doctype.kanban_board.kanban_board.update_order_for_single_card'
// }).as('drag-completed');
// cy.get('.kanban-card-body')
// .contains('Test Kanban ToDo').first()
// .drag('[data-column-value="Closed"] .kanban-cards', { force: true });
// cy.wait('@drag-completed');
// });
});

View file

@ -1,38 +1,42 @@
context('List Paging', () => {
context("List Paging", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.window().its('frappe').then(frappe => {
return frappe.call("frappe.tests.ui_test_helpers.create_multiple_todo_records");
});
cy.visit("/app/website");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.call("frappe.tests.ui_test_helpers.create_multiple_todo_records");
});
});
it('test load more with count selection buttons', () => {
cy.visit('/app/todo/view/report');
it("test load more with count selection buttons", () => {
cy.visit("/app/todo/view/report");
cy.clear_filters();
cy.get('.list-paging-area .list-count').should('contain.text', '20 of');
cy.get('.list-paging-area .btn-more').click();
cy.get('.list-paging-area .list-count').should('contain.text', '40 of');
cy.get('.list-paging-area .btn-more').click();
cy.get('.list-paging-area .list-count').should('contain.text', '60 of');
cy.get(".list-paging-area .list-count").should("contain.text", "20 of");
cy.get(".list-paging-area .btn-more").click();
cy.get(".list-paging-area .list-count").should("contain.text", "40 of");
cy.get(".list-paging-area .btn-more").click();
cy.get(".list-paging-area .list-count").should("contain.text", "60 of");
cy.get('.list-paging-area .btn-group .btn-paging[data-value="100"]').click();
cy.get('.list-paging-area .list-count').should('contain.text', '100 of');
cy.get('.list-paging-area .btn-more').click();
cy.get('.list-paging-area .list-count').should('contain.text', '200 of');
cy.get('.list-paging-area .btn-more').click();
cy.get('.list-paging-area .list-count').should('contain.text', '300 of');
cy.get(".list-paging-area .list-count").should("contain.text", "100 of");
cy.get(".list-paging-area .btn-more").click();
cy.get(".list-paging-area .list-count").should("contain.text", "200 of");
cy.get(".list-paging-area .btn-more").click();
cy.get(".list-paging-area .list-count").should("contain.text", "300 of");
// check if refresh works after load more
cy.get('.page-head .standard-actions [data-original-title="Refresh"]').click();
cy.get('.list-paging-area .list-count').should('contain.text', '300 of');
cy.get(".list-paging-area .list-count").should("contain.text", "300 of");
cy.get('.list-paging-area .btn-group .btn-paging[data-value="500"]').click();
cy.get('.list-paging-area .list-count').should('contain.text', '500 of');
cy.get('.list-paging-area .btn-more').click();
cy.get(".list-paging-area .list-count").should("contain.text", "500 of");
cy.get(".list-paging-area .btn-more").click();
cy.get('.list-paging-area .list-count').should('contain.text', '1000 of');
cy.get(".list-paging-area .list-count").should("contain.text", "1000 of");
});
});

View file

@ -1,46 +1,67 @@
context('List View', () => {
context("List View", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.window().its('frappe').then(frappe => {
return frappe.xcall("frappe.tests.ui_test_helpers.setup_workflow");
});
cy.visit("/app/website");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.setup_workflow");
});
});
it('Keep checkbox checked after Refresh', () => {
cy.go_to_list('ToDo');
cy.get('.list-row-container .list-row-checkbox').click({ multiple: true, force: true });
cy.get('.actions-btn-group button').contains('Actions').should('be.visible');
cy.intercept('/api/method/frappe.desk.reportview.get').as('list-refresh');
it("Keep checkbox checked after Refresh", () => {
cy.go_to_list("ToDo");
cy.clear_filters();
cy.get(".list-row-container .list-row-checkbox").click({ multiple: true, force: true });
cy.get(".actions-btn-group button").contains("Actions").should("be.visible");
cy.intercept("/api/method/frappe.desk.reportview.get").as("list-refresh");
cy.wait(3000); // wait before you hit another refresh
cy.get('button[data-original-title="Refresh"]').click();
cy.wait('@list-refresh');
cy.get('.list-row-container .list-row-checkbox:checked').should('be.visible');
cy.wait("@list-refresh");
cy.get(".list-row-container .list-row-checkbox:checked").should("be.visible");
});
it('enables "Actions" button', () => {
const actions = ['Approve', 'Reject', 'Edit', 'Export', 'Assign To', 'Apply Assignment Rule', 'Add Tags', 'Print', 'Delete'];
cy.go_to_list('ToDo');
cy.get('.list-row-container:contains("Pending") .list-row-checkbox').click({ multiple: true, force: true });
cy.get('.actions-btn-group button').contains('Actions').should('be.visible').click();
cy.get('.dropdown-menu li:visible .dropdown-item').should('have.length', 9).each((el, index) => {
cy.wrap(el).contains(actions[index]);
}).then((elements) => {
cy.intercept({
method: 'POST',
url: 'api/method/frappe.model.workflow.bulk_workflow_approval'
}).as('bulk-approval');
cy.intercept({
method: 'POST',
url: 'api/method/frappe.desk.reportview.get'
}).as('real-time-update');
cy.wrap(elements).contains('Approve').click();
cy.wait(['@bulk-approval', '@real-time-update']);
cy.wait(300);
cy.get_open_dialog().find('.btn-modal-close').click();
cy.reload();
cy.clear_filters();
cy.get('.list-row-container:visible').should('contain', 'Approved');
const actions = [
"Approve",
"Reject",
"Edit",
"Export",
"Assign To",
"Apply Assignment Rule",
"Add Tags",
"Print",
"Delete",
];
cy.go_to_list("ToDo");
cy.clear_filters();
cy.get('.list-row-container:contains("Pending") .list-row-checkbox').click({
multiple: true,
force: true,
});
cy.get(".actions-btn-group button").contains("Actions").should("be.visible").click();
cy.get(".dropdown-menu li:visible .dropdown-item")
.should("have.length", 9)
.each((el, index) => {
cy.wrap(el).contains(actions[index]);
})
.then((elements) => {
cy.intercept({
method: "POST",
url: "api/method/frappe.model.workflow.bulk_workflow_approval",
}).as("bulk-approval");
cy.intercept({
method: "POST",
url: "api/method/frappe.desk.reportview.get",
}).as("real-time-update");
cy.wrap(elements).contains("Approve").click();
cy.wait(["@bulk-approval", "@real-time-update"]);
cy.wait(300);
cy.get_open_dialog().find(".btn-modal-close").click();
cy.reload();
cy.clear_filters();
cy.get(".list-row-container:visible").should("contain", "Approved");
});
});
});

View file

@ -1,36 +1,36 @@
context('List View Settings', () => {
context("List View Settings", () => {
beforeEach(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
it('Default settings', () => {
cy.visit('/app/List/DocType/List');
cy.get('.list-count').should('contain', "20 of");
cy.get('.list-stats').should('contain', "Tags");
it("Default settings", () => {
cy.visit("/app/List/DocType/List");
cy.get(".list-count").should("contain", "20 of");
cy.get(".list-stats").should("contain", "Tags");
});
it('disable count and sidebar stats then verify', () => {
it("disable count and sidebar stats then verify", () => {
cy.wait(300);
cy.visit('/app/List/DocType/List');
cy.visit("/app/List/DocType/List");
cy.wait(300);
cy.get('.list-count').should('contain', "20 of");
cy.get('.menu-btn-group button').click();
cy.get('.dropdown-menu li').filter(':visible').contains('List Settings').click();
cy.get('.modal-dialog').should('contain', 'DocType Settings');
cy.get(".list-count").should("contain", "20 of");
cy.get(".menu-btn-group button").click();
cy.get(".dropdown-menu li").filter(":visible").contains("List Settings").click();
cy.get(".modal-dialog").should("contain", "DocType Settings");
cy.findByLabelText('Disable Count').check({ force: true });
cy.findByLabelText('Disable Sidebar Stats').check({ force: true });
cy.findByRole('button', {name: 'Save'}).click();
cy.findByLabelText("Disable Count").check({ force: true });
cy.findByLabelText("Disable Sidebar Stats").check({ force: true });
cy.findByRole("button", { name: "Save" }).click();
cy.reload({ force: true });
cy.get('.list-count').should('be.empty');
cy.get('.list-sidebar .list-tags').should('not.exist');
cy.get(".list-count").should("be.empty");
cy.get(".list-sidebar .list-tags").should("not.exist");
cy.get('.menu-btn-group button').click({ force: true });
cy.get('.dropdown-menu li').filter(':visible').contains('List Settings').click();
cy.get('.modal-dialog').should('contain', 'DocType Settings');
cy.findByLabelText('Disable Count').uncheck({ force: true });
cy.findByLabelText('Disable Sidebar Stats').uncheck({ force: true });
cy.findByRole('button', {name: 'Save'}).click();
cy.get(".menu-btn-group button").click({ force: true });
cy.get(".dropdown-menu li").filter(":visible").contains("List Settings").click();
cy.get(".modal-dialog").should("contain", "DocType Settings");
cy.findByLabelText("Disable Count").uncheck({ force: true });
cy.findByLabelText("Disable Sidebar Stats").uncheck({ force: true });
cy.findByRole("button", { name: "Save" }).click();
});
});

View file

@ -1,68 +1,66 @@
context('Login', () => {
context("Login", () => {
beforeEach(() => {
cy.request('/api/method/logout');
cy.visit('/login');
cy.location('pathname').should('eq', '/login');
cy.request("/api/method/logout");
cy.visit("/login");
cy.location("pathname").should("eq", "/login");
});
it('greets with login screen', () => {
cy.get('.page-card-head').contains('Login');
it("greets with login screen", () => {
cy.get(".page-card-head").contains("Login");
});
it('validates password', () => {
cy.get('#login_email').type('Administrator');
cy.findByRole('button', {name: 'Login'}).click();
cy.location('pathname').should('eq', '/login');
it("validates password", () => {
cy.get("#login_email").type("Administrator");
cy.findByRole("button", { name: "Login" }).click();
cy.location("pathname").should("eq", "/login");
});
it('validates email', () => {
cy.get('#login_password').type('qwe');
cy.findByRole('button', {name: 'Login'}).click();
cy.location('pathname').should('eq', '/login');
it("validates email", () => {
cy.get("#login_password").type("qwe");
cy.findByRole("button", { name: "Login" }).click();
cy.location("pathname").should("eq", "/login");
});
it('shows invalid login if incorrect credentials', () => {
cy.get('#login_email').type('Administrator');
cy.get('#login_password').type('qwer');
it("shows invalid login if incorrect credentials", () => {
cy.get("#login_email").type("Administrator");
cy.get("#login_password").type("qwer");
cy.findByRole('button', {name: 'Login'}).click();
cy.findByRole('button', {name: 'Invalid Login. Try again.'}).should('exist');
cy.location('pathname').should('eq', '/login');
cy.findByRole("button", { name: "Login" }).click();
cy.findByRole("button", { name: "Invalid Login. Try again." }).should("exist");
cy.location("pathname").should("eq", "/login");
});
it('logs in using correct credentials', () => {
cy.get('#login_email').type('Administrator');
cy.get('#login_password').type(Cypress.config('adminPassword'));
it("logs in using correct credentials", () => {
cy.get("#login_email").type("Administrator");
cy.get("#login_password").type(Cypress.config("adminPassword"));
cy.findByRole('button', {name: 'Login'}).click();
cy.location('pathname').should('eq', '/app');
cy.window().its('frappe.session.user').should('eq', 'Administrator');
cy.findByRole("button", { name: "Login" }).click();
cy.location("pathname").should("eq", "/app");
cy.window().its("frappe.session.user").should("eq", "Administrator");
});
it('check redirect after login', () => {
it("check redirect after login", () => {
// mock for OAuth 2.0 client_id, redirect_uri, scope and state
const payload = new URLSearchParams({
uuid: '6fed1519-cfd8-4a2d-84a6-9a1799c7c741',
encoded_string: 'hello all',
encoded_url: 'http://test.localhost/callback',
base64_string: 'aGVsbG8gYWxs'
uuid: "6fed1519-cfd8-4a2d-84a6-9a1799c7c741",
encoded_string: "hello all",
encoded_url: "http://test.localhost/callback",
base64_string: "aGVsbG8gYWxs",
});
cy.request('/api/method/logout');
cy.request("/api/method/logout");
// redirect-to /me page with params to mock OAuth 2.0 like request
cy.visit(
'/login?redirect-to=/me?' +
encodeURIComponent(payload.toString().replace("+", " "))
"/login?redirect-to=/me?" + encodeURIComponent(payload.toString().replace("+", " "))
);
cy.get('#login_email').type('Administrator');
cy.get('#login_password').type(Cypress.config('adminPassword'));
cy.get("#login_email").type("Administrator");
cy.get("#login_password").type(Cypress.config("adminPassword"));
cy.findByRole('button', {name: 'Login'}).click();
cy.findByRole("button", { name: "Login" }).click();
// verify redirected location and url params after login
cy.url().should('include', '/me?' + payload.toString().replace('+', '%20'));
cy.url().should("include", "/me?" + payload.toString().replace("+", "%20"));
});
});

View file

@ -1,99 +1,102 @@
context('MultiSelectDialog', () => {
context("MultiSelectDialog", () => {
before(() => {
cy.login();
cy.visit('/app');
cy.visit("/app");
const contact_template = {
"doctype": "Contact",
"first_name": "Test",
"status": "Passive",
"email_ids": [
doctype: "Contact",
first_name: "Test",
status: "Passive",
email_ids: [
{
"doctype": "Contact Email",
"email_id": "test@example.com",
"is_primary": 0
}
]
doctype: "Contact Email",
email_id: "test@example.com",
is_primary: 0,
},
],
};
const promises = Array.from({length: 25})
.map(() => cy.insert_doc('Contact', contact_template, true));
const promises = Array.from({ length: 25 }).map(() =>
cy.insert_doc("Contact", contact_template, true)
);
Promise.all(promises);
});
function open_multi_select_dialog() {
cy.window().its('frappe').then(frappe => {
new frappe.ui.form.MultiSelectDialog({
doctype: "Contact",
target: {},
setters: {
status: null,
gender: null
},
add_filters_group: 1,
allow_child_item_selection: 1,
child_fieldname: "email_ids",
child_columns: ["email_id", "is_primary"]
cy.window()
.its("frappe")
.then((frappe) => {
new frappe.ui.form.MultiSelectDialog({
doctype: "Contact",
target: {},
setters: {
status: null,
gender: null,
},
add_filters_group: 1,
allow_child_item_selection: 1,
child_fieldname: "email_ids",
child_columns: ["email_id", "is_primary"],
});
});
});
}
it('checks multi select dialog api works', () => {
it("checks multi select dialog api works", () => {
open_multi_select_dialog();
cy.get_open_dialog().should('contain', 'Select Contacts');
cy.get_open_dialog().should("contain", "Select Contacts");
});
it('checks for filters', () => {
['search_term', 'status', 'gender'].forEach(fieldname => {
cy.get_open_dialog().get(`.frappe-control[data-fieldname="${fieldname}"]`).should('exist');
it("checks for filters", () => {
["search_term", "status", "gender"].forEach((fieldname) => {
cy.get_open_dialog()
.get(`.frappe-control[data-fieldname="${fieldname}"]`)
.should("exist");
});
// add_filters_group: 1 should add a filter group
cy.get_open_dialog().get(`.frappe-control[data-fieldname="filter_area"]`).should('exist');
cy.get_open_dialog().get(`.frappe-control[data-fieldname="filter_area"]`).should("exist");
});
it('checks for child item selection', () => {
cy.get_open_dialog()
.get(`.dt-row-header`).should('not.exist');
it("checks for child item selection", () => {
cy.get_open_dialog().get(`.dt-row-header`).should("not.exist");
cy.get_open_dialog()
.get(`.frappe-control[data-fieldname="allow_child_item_selection"]`)
.find('input[data-fieldname="allow_child_item_selection"]')
.should('exist')
.click({force: true});
.should("exist")
.click({ force: true });
cy.get_open_dialog()
.get(`.frappe-control[data-fieldname="child_selection_area"]`)
.should('exist');
.should("exist");
cy.get_open_dialog()
.get(`.dt-row-header`).should('contain', 'Contact');
cy.get_open_dialog().get(`.dt-row-header`).should("contain", "Contact");
cy.get_open_dialog()
.get(`.dt-row-header`).should('contain', 'Email Id');
cy.get_open_dialog().get(`.dt-row-header`).should("contain", "Email Id");
cy.get_open_dialog()
.get(`.dt-row-header`).should('contain', 'Is Primary');
cy.get_open_dialog().get(`.dt-row-header`).should("contain", "Is Primary");
});
it('tests more button', () => {
it("tests more button", () => {
cy.get_open_dialog()
.get(`.frappe-control[data-fieldname="more_child_btn"]`)
.should('exist')
.as('more-btn');
cy.get_open_dialog().get('.datatable .dt-scrollable .dt-row').should(($rows) => {
expect($rows).to.have.length(20);
});
.should("exist")
.as("more-btn");
cy.intercept('POST', 'api/method/frappe.client.get_list').as('get-more-records');
cy.get('@more-btn').find('button').click({force: true});
cy.wait('@get-more-records');
cy.get_open_dialog()
.get(".datatable .dt-scrollable .dt-row")
.should(($rows) => {
expect($rows).to.have.length(20);
});
cy.get_open_dialog().get('.datatable .dt-scrollable .dt-row').should(($rows) => {
if ($rows.length <= 20) {
throw new Error("More button doesn't work");
}
});
cy.intercept("POST", "api/method/frappe.client.get_list").as("get-more-records");
cy.get("@more-btn").find("button").click({ force: true });
cy.wait("@get-more-records");
cy.get_open_dialog()
.get(".datatable .dt-scrollable .dt-row")
.should(($rows) => {
if ($rows.length <= 20) {
throw new Error("More button doesn't work");
}
});
});
});
});

View file

@ -1,25 +1,29 @@
context('Navigation', () => {
context("Navigation", () => {
before(() => {
cy.login();
});
it('Navigate to route with hash in document name', () => {
cy.insert_doc('ToDo', {'__newname': 'ABC#123', 'description': 'Test this', 'ignore_duplicate': true});
cy.visit('/app/todo/ABC#123');
cy.title().should('eq', 'Test this - ABC#123');
cy.get_field('description', 'Text Editor').contains('Test this');
cy.go('back');
cy.title().should('eq', 'Website');
it("Navigate to route with hash in document name", () => {
cy.insert_doc("ToDo", {
__newname: "ABC#123",
description: "Test this",
ignore_duplicate: true,
});
cy.visit("/app/todo/ABC#123");
cy.title().should("eq", "Test this - ABC#123");
cy.get_field("description", "Text Editor").contains("Test this");
cy.go("back");
cy.title().should("eq", "Website");
});
it.only('Navigate to previous page after login', () => {
cy.visit('/app/todo');
cy.get('.page-head').findByTitle('To Do').should('be.visible');
cy.request('/api/method/logout');
cy.reload().as('reload');
cy.get('@reload').get('.page-card .btn-primary').contains('Login').click();
cy.location('pathname').should('eq', '/login');
it.only("Navigate to previous page after login", () => {
cy.visit("/app/todo");
cy.get(".page-head").findByTitle("To Do").should("be.visible");
cy.request("/api/method/logout");
cy.reload().as("reload");
cy.get("@reload").get(".page-card .btn-primary").contains("Login").click();
cy.location("pathname").should("eq", "/login");
cy.login();
cy.visit('/app');
cy.location('pathname').should('eq', '/app/todo');
cy.visit("/app");
cy.location("pathname").should("eq", "/app/todo");
});
});

View file

@ -1,22 +1,22 @@
context('Number Card', () => {
context("Number Card", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.visit("/app/website");
});
it('Check filter populate for child table doctype', () => {
cy.visit('/app/number-card/new-number-card-1');
cy.get('[data-fieldname="parent_document_type"]').should('have.css', 'display', 'none');
it("Check filter populate for child table doctype", () => {
cy.visit("/app/number-card/new-number-card-1");
cy.get('[data-fieldname="parent_document_type"]').should("have.css", "display", "none");
cy.get_field('document_type', 'Link');
cy.fill_field('document_type', 'Workspace Link', 'Link').focus().blur();
cy.get_field('document_type', 'Link').should('have.value', 'Workspace Link');
cy.get_field("document_type", "Link");
cy.fill_field("document_type", "Workspace Link", "Link").focus().blur();
cy.get_field("document_type", "Link").should("have.value", "Workspace Link");
cy.fill_field('label', 'Test Number Card', 'Data');
cy.fill_field("label", "Test Number Card", "Data");
cy.get('[data-fieldname="filters_json"]').click().wait(200);
cy.get('.modal-body .filter-action-buttons .add-filter').click();
cy.get('.modal-body .fieldname-select-area').click();
cy.get('.modal-actions .btn-modal-close').click();
cy.get(".modal-body .filter-action-buttons .add-filter").click();
cy.get(".modal-body .fieldname-select-area").click();
cy.get(".modal-actions .btn-modal-close").click();
});
});
});

View file

@ -1,63 +1,91 @@
context('Query Report', () => {
context("Query Report", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.insert_doc('Report', {
'report_name': 'Test ToDo Report',
'ref_doctype': 'ToDo',
'report_type': 'Query Report',
'query': 'select * from tabToDo'
}, true).as('doc');
cy.visit("/app/website");
cy.insert_doc(
"Report",
{
report_name: "Test ToDo Report",
ref_doctype: "ToDo",
report_type: "Query Report",
query: "select * from tabToDo",
},
true
).as("doc");
cy.create_records({
doctype: 'ToDo',
description: 'this is a test todo for query report'
}).as('todos');
doctype: "ToDo",
description: "this is a test todo for query report",
}).as("todos");
});
it('add custom column in report', () => {
cy.visit('/app/query-report/Permitted Documents For User');
it("add custom column in report", () => {
cy.visit("/app/query-report/Permitted Documents For User");
cy.get('.page-form.flex', { timeout: 60000 }).should('have.length', 1).then(() => {
cy.get('#page-query-report input[data-fieldname="user"]').as('input-user');
cy.get('@input-user').focus().type('test@erpnext.com', { delay: 100 }).blur();
cy.wait(300);
cy.get('#page-query-report input[data-fieldname="doctype"]').as('input-role');
cy.get('@input-role').focus().type('Role', { delay: 100 }).blur();
cy.get(".page-form.flex", { timeout: 60000 })
.should("have.length", 1)
.then(() => {
cy.get('#page-query-report input[data-fieldname="user"]').as("input-user");
cy.get("@input-user").focus().type("test@erpnext.com", { delay: 100 }).blur();
cy.wait(300);
cy.get('#page-query-report input[data-fieldname="doctype"]').as("input-role");
cy.get("@input-role").focus().type("Role", { delay: 100 }).blur();
cy.get('.datatable').should('exist');
cy.get('#page-query-report .page-actions .menu-btn-group button').click({ force: true });
cy.get('#page-query-report .menu-btn-group .dropdown-menu').contains('Add Column').click({ force: true });
cy.get_open_dialog().get('.modal-title').should('contain', 'Add Column');
cy.get('select[data-fieldname="doctype"]').select("Role", { force: true });
cy.get('select[data-fieldname="field"]').select("Role Name", { force: true });
cy.get('select[data-fieldname="insert_after"]').select("Name", { force: true });
cy.get_open_dialog().findByRole('button', {name: 'Submit'}).click({ force: true });
cy.get('#page-query-report .page-actions .menu-btn-group button').click({ force: true });
cy.get('#page-query-report .menu-btn-group .dropdown-menu').contains('Save').click({ timeout: 100, force: true });
cy.get_open_dialog().get('.modal-title').should('contain', 'Save Report');
cy.get(".datatable").should("exist");
cy.get("#page-query-report .page-actions .menu-btn-group button").click({
force: true,
});
cy.get("#page-query-report .menu-btn-group .dropdown-menu")
.contains("Add Column")
.click({ force: true });
cy.get_open_dialog().get(".modal-title").should("contain", "Add Column");
cy.get('select[data-fieldname="doctype"]').select("Role", { force: true });
cy.get('select[data-fieldname="field"]').select("Role Name", { force: true });
cy.get('select[data-fieldname="insert_after"]').select("Name", { force: true });
cy.get_open_dialog()
.findByRole("button", { name: "Submit" })
.click({ force: true });
cy.get("#page-query-report .page-actions .menu-btn-group button").click({
force: true,
});
cy.get("#page-query-report .menu-btn-group .dropdown-menu")
.contains("Save")
.click({ timeout: 100, force: true });
cy.get_open_dialog().get(".modal-title").should("contain", "Save Report");
cy.get('input[data-fieldname="report_name"]').type("Test Report", { delay: 100, force: true });
cy.get_open_dialog().findByRole('button', {name: 'Submit'}).click({ timeout: 1000, force: true });
});
cy.get('input[data-fieldname="report_name"]').type("Test Report", {
delay: 100,
force: true,
});
cy.get_open_dialog()
.findByRole("button", { name: "Submit" })
.click({ timeout: 1000, force: true });
});
});
let save_report_and_open = (report, update_name) => {
cy.get('#page-query-report .page-actions .menu-btn-group button').click({ force: true });
cy.get('#page-query-report .menu-btn-group .dropdown-menu').contains('Save').click({ timeout: 100, force: true });
cy.get_open_dialog().get('.modal-title').should('contain', 'Save Report');
cy.get("#page-query-report .page-actions .menu-btn-group button").click({ force: true });
cy.get("#page-query-report .menu-btn-group .dropdown-menu")
.contains("Save")
.click({ timeout: 100, force: true });
cy.get_open_dialog().get(".modal-title").should("contain", "Save Report");
cy.get('input[data-fieldname="report_name"]').type(update_name, { delay: 100, force: true });
cy.get_open_dialog().findByRole('button', {name: 'Submit'}).click({ timeout: 1000, force: true });
cy.get('input[data-fieldname="report_name"]').type(update_name, {
delay: 100,
force: true,
});
cy.get_open_dialog()
.findByRole("button", { name: "Submit" })
.click({ timeout: 1000, force: true });
cy.visit('/app/query-report/'+report);
cy.get('.datatable').should('exist');
cy.visit("/app/query-report/" + report);
cy.get(".datatable").should("exist");
};
it('test multi level query report', () => {
cy.visit('/app/query-report/Test ToDo Report');
cy.get('.datatable').should('exist');
it("test multi level query report", () => {
cy.visit("/app/query-report/Test ToDo Report");
cy.get(".datatable").should("exist");
save_report_and_open('Test ToDo Report 1', ' 1');
save_report_and_open('Test ToDo Report 11', '1');
save_report_and_open("Test ToDo Report 1", " 1");
save_report_and_open("Test ToDo Report 11", "1");
});
});
});

View file

@ -1,66 +1,72 @@
context('Recorder', () => {
context.skip("Recorder", () => {
before(() => {
cy.login();
});
beforeEach(() => {
cy.visit('/app/recorder');
return cy.window().its('frappe').then(frappe => {
// reset recorder
return frappe.xcall("frappe.recorder.stop").then(() => {
return frappe.xcall("frappe.recorder.delete");
cy.visit("/app/recorder");
return cy
.window()
.its("frappe")
.then((frappe) => {
// reset recorder
return frappe.xcall("frappe.recorder.stop").then(() => {
return frappe.xcall("frappe.recorder.delete");
});
});
});
});
it('Recorder Empty State', () => {
cy.get('.page-head').findByTitle('Recorder').should('exist');
it("Recorder Empty State", () => {
cy.get(".page-head").findByTitle("Recorder").should("exist");
cy.get('.indicator-pill').should('contain', 'Inactive').should('have.class', 'red');
cy.get(".indicator-pill").should("contain", "Inactive").should("have.class", "red");
cy.get('.page-actions').findByRole('button', {name: 'Start'}).should('exist');
cy.get('.page-actions').findByRole('button', {name: 'Clear'}).should('exist');
cy.get(".page-actions").findByRole("button", { name: "Start" }).should("exist");
cy.get(".page-actions").findByRole("button", { name: "Clear" }).should("exist");
cy.get('.msg-box').should('contain', 'Recorder is Inactive');
cy.get('.msg-box').findByRole('button', {name: 'Start Recording'}).should('exist');
cy.get(".msg-box").should("contain", "Recorder is Inactive");
cy.get(".msg-box").findByRole("button", { name: "Start Recording" }).should("exist");
});
it('Recorder Start', () => {
cy.get('.page-actions').findByRole('button', {name: 'Start'}).click();
cy.get('.indicator-pill').should('contain', 'Active').should('have.class', 'green');
it("Recorder Start", () => {
cy.get(".page-actions").findByRole("button", { name: "Start" }).click();
cy.get(".indicator-pill").should("contain", "Active").should("have.class", "green");
cy.get('.msg-box').should('contain', 'No Requests found');
cy.get(".msg-box").should("contain", "No Requests found");
cy.visit('/app/List/DocType/List');
cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh');
cy.wait('@list_refresh');
cy.visit("/app/List/DocType/List");
cy.intercept("POST", "/api/method/frappe.desk.reportview.get").as("list_refresh");
cy.wait("@list_refresh");
cy.get('.page-head').findByTitle('DocType').should('exist');
cy.get('.list-count').should('contain', '20 of ');
cy.get(".page-head").findByTitle("DocType").should("exist");
cy.get(".list-count").should("contain", "20 of ");
cy.visit('/app/recorder');
cy.get('.page-head').findByTitle('Recorder').should('exist');
cy.get('.frappe-list .result-list').should('contain', '/api/method/frappe.desk.reportview.get');
cy.visit("/app/recorder");
cy.get(".page-head").findByTitle("Recorder").should("exist");
cy.get(".frappe-list .result-list").should(
"contain",
"/api/method/frappe.desk.reportview.get"
);
});
it('Recorder View Request', () => {
cy.get('.page-actions').findByRole('button', {name: 'Start'}).click();
it("Recorder View Request", () => {
cy.get(".page-actions").findByRole("button", { name: "Start" }).click();
cy.visit('/app/List/DocType/List');
cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh');
cy.wait('@list_refresh');
cy.visit("/app/List/DocType/List");
cy.intercept("POST", "/api/method/frappe.desk.reportview.get").as("list_refresh");
cy.wait("@list_refresh");
cy.get('.page-head').findByTitle('DocType').should('exist');
cy.get('.list-count').should('contain', '20 of ');
cy.get(".page-head").findByTitle("DocType").should("exist");
cy.get(".list-count").should("contain", "20 of ");
cy.visit('/app/recorder');
cy.visit("/app/recorder");
cy.get('.frappe-list .list-row-container span')
.contains('/api/method/frappe')
.should('be.visible')
.click({force: true});
cy.get(".frappe-list .list-row-container span")
.contains("/api/method/frappe")
.should("be.visible")
.click({ force: true });
cy.url().should('include', '/recorder/request');
cy.get('form').should('contain', '/api/method/frappe');
cy.url().should("include", "/recorder/request");
cy.get("form").should("contain", "/api/method/frappe");
});
});

View file

@ -1,42 +1,46 @@
import custom_submittable_doctype from '../fixtures/custom_submittable_doctype';
import custom_submittable_doctype from "../fixtures/custom_submittable_doctype";
const doctype_name = custom_submittable_doctype.name;
context('Report View', () => {
context("Report View", () => {
before(() => {
cy.login();
cy.visit('/app/website');
cy.insert_doc('DocType', custom_submittable_doctype, true);
cy.visit("/app/website");
cy.insert_doc("DocType", custom_submittable_doctype, true);
cy.clear_cache();
cy.insert_doc(doctype_name, {
'title': 'Doc 1',
'description': 'Random Text',
'enabled': 0,
'docstatus': 1 // submit document
}, true);
cy.insert_doc(
doctype_name,
{
title: "Doc 1",
description: "Random Text",
enabled: 0,
docstatus: 1, // submit document
},
true
);
});
it('Field with enabled allow_on_submit should be editable.', () => {
cy.intercept('POST', 'api/method/frappe.client.set_value').as('value-update');
it("Field with enabled allow_on_submit should be editable.", () => {
cy.intercept("POST", "api/method/frappe.client.set_value").as("value-update");
cy.visit(`/app/List/${doctype_name}/Report`);
// check status column added from docstatus
cy.get('.dt-row-0 > .dt-cell--col-3').should('contain', 'Submitted');
let cell = cy.get('.dt-row-0 > .dt-cell--col-4');
cy.get(".dt-row-0 > .dt-cell--col-3").should("contain", "Submitted");
let cell = cy.get(".dt-row-0 > .dt-cell--col-4");
// select the cell
cell.dblclick();
cell.get('.dt-cell__edit--col-4').findByRole('checkbox').check({ force: true });
cy.get('.dt-row-0 > .dt-cell--col-3').click(); // click outside
cell.get(".dt-cell__edit--col-4").findByRole("checkbox").check({ force: true });
cy.get(".dt-row-0 > .dt-cell--col-3").click(); // click outside
cy.wait('@value-update');
cy.wait("@value-update");
cy.call('frappe.client.get_value', {
cy.call("frappe.client.get_value", {
doctype: doctype_name,
filters: {
title: 'Doc 1',
title: "Doc 1",
},
fieldname: 'enabled'
}).then(r => {
fieldname: "enabled",
}).then((r) => {
expect(r.message.enabled).to.equals(1);
});
});

View file

@ -0,0 +1,40 @@
const list_view = "/app/todo";
// test round trip with filter types
const test_queries = [
"?status=Open",
`?date=%5B"Between"%2C%5B"2022-06-01"%2C"2022-06-30"%5D%5D`,
`?date=%5B">"%2C"2022-06-01"%5D`,
`?name=%5B"like"%2C"%2542%25"%5D`,
`?status=%5B"not%20in"%2C%5B"Open"%2C"Closed"%5D%5D`,
];
describe("SPA Routing", { scrollBehavior: false }, () => {
before(() => {
cy.login();
cy.go_to_list("ToDo");
});
after(() => {
cy.clear_filters(); // avoid flake in future tests
});
it("should apply filter on list view from route", () => {
test_queries.forEach((query) => {
const full_url = `${list_view}${query}`;
cy.visit(full_url);
cy.findByTitle("To Do").should("exist");
const expected = new URLSearchParams(query);
cy.location().then((loc) => {
const actual = new URLSearchParams(loc.search);
// This might appear like a dumb test checking visited URL to itself
// but it's actually doing a round trip
// URL with params -> parsed filters -> new URL
// if it's same that means everything worked in between.
expect(actual.toString()).to.eq(expected.toString());
});
});
});
});

View file

@ -1,55 +1,64 @@
context('Sidebar', () => {
context("Sidebar", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.visit('/app/doctype');
cy.visit("/app/doctype");
});
it('Test for checking "Assigned To" counter value, adding filter and adding & removing an assignment', () => {
cy.click_sidebar_button("Assigned To");
//To check if no filter is available in "Assigned To" dropdown
cy.get('.empty-state').should('contain', 'No filters found');
cy.get(".empty-state").should("contain", "No filters found");
cy.click_sidebar_button("Created By");
//To check if "Created By" dropdown contains filter
cy.get('.group-by-item > .dropdown-item').should('contain', 'Me');
cy.get(".group-by-item > .dropdown-item").should("contain", "Me");
//Assigning a doctype to a user
cy.visit('/app/doctype/ToDo');
cy.get('.form-assignments > .flex > .text-muted').click();
cy.get_field('assign_to_me', 'Check').click();
cy.get('.modal-footer > .standard-actions > .btn-primary').click();
cy.visit('/app/doctype');
cy.visit("/app/doctype/ToDo");
cy.get(".form-assignments > .flex > .text-muted").click();
cy.get_field("assign_to_me", "Check").click();
cy.get(".modal-footer > .standard-actions > .btn-primary").click();
cy.visit("/app/doctype");
cy.click_sidebar_button("Assigned To");
//To check if filter is added in "Assigned To" dropdown after assignment
cy.get('.group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item').should('contain', '1');
cy.get(".group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item").should(
"contain",
"1"
);
//To check if there is no filter added to the listview
cy.get('.filter-selector > .btn').should('contain', 'Filter');
cy.get(".filter-selector > .btn").should("contain", "Filter");
//To add a filter to display data into the listview
cy.get('.group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item').click();
cy.get(".group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item").click();
//To check if filter is applied
cy.click_filter_button().should('contain', '1 filter');
cy.get('.fieldname-select-area > .awesomplete > .form-control').should('have.value', 'Assigned To');
cy.get('.condition').should('have.value', 'like');
cy.get('.filter-field > .form-group > .input-with-feedback').should('have.value', '%Administrator%');
cy.click_filter_button().should("contain", "1 filter");
cy.get(".fieldname-select-area > .awesomplete > .form-control").should(
"have.value",
"Assigned To"
);
cy.get(".condition").should("have.value", "like");
cy.get(".filter-field > .form-group > .input-with-feedback").should(
"have.value",
"%Administrator%"
);
cy.click_filter_button();
//To remove the applied filter
cy.clear_filters();
//To remove the assignment
cy.visit('/app/doctype/ToDo');
cy.get('.assignments > .avatar-group > .avatar > .avatar-frame').click();
cy.get('.remove-btn').click({force: true});
cy.visit("/app/doctype/ToDo");
cy.get(".assignments > .avatar-group > .avatar > .avatar-frame").click();
cy.get(".remove-btn").click({ force: true });
cy.hide_dialog();
cy.visit('/app/doctype');
cy.visit("/app/doctype");
cy.click_sidebar_button("Assigned To");
cy.get('.empty-state').should('contain', 'No filters found');
cy.get(".empty-state").should("contain", "No filters found");
});
});

View file

@ -1,51 +1,57 @@
context('Table MultiSelect', () => {
context("Table MultiSelect", () => {
before(() => {
cy.login();
});
let name = 'table multiselect' + Math.random().toString().slice(2, 8);
let name = "table multiselect" + Math.random().toString().slice(2, 8);
it('select value from multiselect dropdown', () => {
cy.new_form('Assignment Rule');
cy.fill_field('__newname', name);
cy.fill_field('document_type', 'Blog Post');
cy.get('.section-head').contains('Assignment Rules').scrollIntoView();
cy.fill_field('assign_condition', 'status=="Open"', 'Code');
cy.get('input[data-fieldname="users"]').focus().as('input');
cy.get('input[data-fieldname="users"] + ul').should('be.visible');
cy.get('@input').type('test{enter}', { delay: 100 });
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value .btn-link-to-form')
.as('selected-value');
cy.get('@selected-value').should('contain', 'test@erpnext.com');
it("select value from multiselect dropdown", () => {
cy.new_form("Assignment Rule");
cy.fill_field("__newname", name);
cy.fill_field("document_type", "Blog Post");
cy.get(".section-head").contains("Assignment Rules").scrollIntoView();
cy.fill_field("assign_condition", 'status=="Open"', "Code");
cy.get('input[data-fieldname="users"]').focus().as("input");
cy.get('input[data-fieldname="users"] + ul').should("be.visible");
cy.get("@input").type("test{enter}", { delay: 100 });
cy.get(
'.frappe-control[data-fieldname="users"] .form-control .tb-selected-value .btn-link-to-form'
).as("selected-value");
cy.get("@selected-value").should("contain", "test@erpnext.com");
cy.intercept('POST', '/api/method/frappe.desk.form.save.savedocs').as('save_form');
cy.intercept("POST", "/api/method/frappe.desk.form.save.savedocs").as("save_form");
// trigger save
cy.get('.primary-action').click();
cy.wait('@save_form').its('response.statusCode').should('eq', 200);
cy.get('@selected-value').should('contain', 'test@erpnext.com');
cy.get(".primary-action").click();
cy.wait("@save_form").its("response.statusCode").should("eq", 200);
cy.get("@selected-value").should("contain", "test@erpnext.com");
});
it('delete value using backspace', () => {
cy.go_to_list('Assignment Rule');
cy.get(`.list-subject:contains("table multiselect")`).last().find('a').click();
cy.get('input[data-fieldname="users"]').focus().type('{backspace}');
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value')
.should('not.exist');
it("delete value using backspace", () => {
cy.go_to_list("Assignment Rule");
cy.get(`.list-subject:contains("table multiselect")`).last().find("a").click();
cy.get('input[data-fieldname="users"]').focus().type("{backspace}");
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').should(
"not.exist"
);
});
it('delete value using x', () => {
cy.go_to_list('Assignment Rule');
cy.get(`.list-subject:contains("table multiselect")`).last().find('a').click();
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').as('existing_value');
cy.get('@existing_value').find('.btn-remove').click();
cy.get('@existing_value').should('not.exist');
it("delete value using x", () => {
cy.go_to_list("Assignment Rule");
cy.get(`.list-subject:contains("table multiselect")`).last().find("a").click();
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').as(
"existing_value"
);
cy.get("@existing_value").find(".btn-remove").click();
cy.get("@existing_value").should("not.exist");
});
it('navigate to selected value', () => {
cy.go_to_list('Assignment Rule');
cy.get(`.list-subject:contains("table multiselect")`).last().find('a').click();
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').as('existing_value');
cy.get('@existing_value').find('.btn-link-to-form').click();
cy.location('pathname').should('contain', '/user/test@erpnext.com');
it("navigate to selected value", () => {
cy.go_to_list("Assignment Rule");
cy.get(`.list-subject:contains("table multiselect")`).last().find("a").click();
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').as(
"existing_value"
);
cy.get("@existing_value").find(".btn-link-to-form").click();
cy.location("pathname").should("contain", "/user/test@erpnext.com");
});
});

View file

@ -1,30 +1,29 @@
context('Theme Switcher Shortcut', () => {
context("Theme Switcher Shortcut", () => {
before(() => {
cy.login();
cy.visit('/app');
cy.visit("/app");
});
beforeEach(() => {
cy.reload();
});
it('Check Toggle', () => {
cy.open_theme_dialog('{ctrl+shift+g}');
cy.get('.modal-backdrop').should('exist');
cy.get('.theme-grid > div').first().click();
cy.close_theme('{ctrl+shift+g}');
cy.get('.modal-backdrop').should('not.exist');
it("Check Toggle", () => {
cy.open_theme_dialog("{ctrl+shift+g}");
cy.get(".modal-backdrop").should("exist");
cy.get(".theme-grid > div").first().click();
cy.close_theme("{ctrl+shift+g}");
cy.get(".modal-backdrop").should("not.exist");
});
it('Check Enter', () => {
cy.open_theme_dialog('{ctrl+shift+g}');
cy.get('.theme-grid > div').first().click();
cy.close_theme('{enter}');
cy.get('.modal-backdrop').should('not.exist');
it("Check Enter", () => {
cy.open_theme_dialog("{ctrl+shift+g}");
cy.get(".theme-grid > div").first().click();
cy.close_theme("{enter}");
cy.get(".modal-backdrop").should("not.exist");
});
});
Cypress.Commands.add('open_theme_dialog', (shortcut_keys) => {
cy.get('body').type(shortcut_keys);
Cypress.Commands.add("open_theme_dialog", (shortcut_keys) => {
cy.get("body").type(shortcut_keys);
});
Cypress.Commands.add("close_theme", (shortcut_keys) => {
cy.get(".modal-header").type(shortcut_keys);
});
Cypress.Commands.add('close_theme', (shortcut_keys) => {
cy.get('.modal-header').type(shortcut_keys);
});

View file

@ -1,89 +1,91 @@
import custom_submittable_doctype from '../fixtures/custom_submittable_doctype';
import custom_submittable_doctype from "../fixtures/custom_submittable_doctype";
context('Timeline', () => {
context("Timeline", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
});
it('Adding new ToDo, adding new comment, verifying comment addition & deletion and deleting ToDo', () => {
it("Adding new ToDo, adding new comment, verifying comment addition & deletion and deleting ToDo", () => {
//Adding new ToDo
cy.visit('/app/todo/new-todo-1');
cy.get('[data-fieldname="description"] .ql-editor.ql-blank').type('Test ToDo', {force: true}).wait(200);
cy.get('.page-head .page-actions').findByRole('button', {name: 'Save'}).click();
cy.visit("/app/todo/new-todo-1");
cy.get('[data-fieldname="description"] .ql-editor.ql-blank')
.type("Test ToDo", { force: true })
.wait(200);
cy.get(".page-head .page-actions").findByRole("button", { name: "Save" }).click();
cy.visit('/app/todo');
cy.go_to_list("ToDo");
cy.clear_filters();
cy.click_listview_row_item(0);
//To check if the comment box is initially empty and tying some text into it
cy.get('[data-fieldname="comment"] .ql-editor').should('contain', '').type('Testing Timeline');
cy.get('[data-fieldname="comment"] .ql-editor')
.should("contain", "")
.type("Testing Timeline");
//Adding new comment
cy.get('.comment-box').findByRole('button', {name: 'Comment'}).click();
cy.get(".comment-box").findByRole("button", { name: "Comment" }).click();
//To check if the commented text is visible in the timeline content
cy.get('.timeline-content').should('contain', 'Testing Timeline');
cy.get(".timeline-content").should("contain", "Testing Timeline");
//Editing comment
cy.click_timeline_action_btn("Edit");
cy.get('.timeline-content [data-fieldname="comment"] .ql-editor').first().type(' 123');
cy.get('.timeline-content [data-fieldname="comment"] .ql-editor').first().type(" 123");
cy.click_timeline_action_btn("Save");
//To check if the edited comment text is visible in timeline content
cy.get('.timeline-content').should('contain', 'Testing Timeline 123');
cy.get(".timeline-content").should("contain", "Testing Timeline 123");
//Discarding comment
cy.click_timeline_action_btn("Edit");
cy.click_timeline_action_btn("Dismiss");
//To check if after discarding the timeline content is same as previous
cy.get('.timeline-content').should('contain', 'Testing Timeline 123');
cy.get(".timeline-content").should("contain", "Testing Timeline 123");
//Deleting the added comment
cy.get('.timeline-message-box .more-actions > .action-btn').click(); //Menu button in timeline item
cy.get('.timeline-message-box .more-actions .dropdown-item').contains('Delete').click({ force: true });
cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click({ force: true });
cy.get(".timeline-message-box .more-actions > .action-btn").click(); //Menu button in timeline item
cy.get(".timeline-message-box .more-actions .dropdown-item")
.contains("Delete")
.click({ force: true });
cy.get_open_dialog().findByRole("button", { name: "Yes" }).click({ force: true });
cy.get('.timeline-content').should('not.contain', 'Testing Timeline 123');
cy.get(".timeline-content").should("not.contain", "Testing Timeline 123");
});
it('Timeline should have submit and cancel activity information', () => {
cy.visit('/app/doctype');
it("Timeline should have submit and cancel activity information", () => {
cy.visit("/app/doctype");
//Creating custom doctype
cy.insert_doc('DocType', custom_submittable_doctype, true);
cy.insert_doc("DocType", custom_submittable_doctype, true);
cy.visit('/app/custom-submittable-doctype');
cy.click_listview_primary_button('Add Custom Submittable DocType');
cy.visit("/app/custom-submittable-doctype");
cy.click_listview_primary_button("Add Custom Submittable DocType");
//Adding a new entry for the created custom doctype
cy.fill_field('title', 'Test');
cy.click_modal_primary_button('Save');
cy.click_modal_primary_button('Submit');
cy.fill_field("title", "Test");
cy.click_modal_primary_button("Save");
cy.click_modal_primary_button("Submit");
cy.visit('/app/custom-submittable-doctype');
cy.visit("/app/custom-submittable-doctype");
cy.click_listview_row_item(0);
//To check if the submission of the documemt is visible in the timeline content
cy.get('.timeline-content').should('contain', 'Administrator submitted this document');
cy.get('[id="page-Custom Submittable DocType"] .page-actions').findByRole('button', {name: 'Cancel'}).click();
cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click();
cy.get(".timeline-content").should("contain", "Administrator submitted this document");
cy.get('[id="page-Custom Submittable DocType"] .page-actions')
.findByRole("button", { name: "Cancel" })
.click();
cy.get_open_dialog().findByRole("button", { name: "Yes" }).click();
//To check if the cancellation of the documemt is visible in the timeline content
cy.get('.timeline-content').should('contain', 'Administrator cancelled this document');
cy.get(".timeline-content").should("contain", "Administrator cancelled this document");
//Deleting the document
cy.visit('/app/custom-submittable-doctype');
cy.visit("/app/custom-submittable-doctype");
cy.select_listview_row_checkbox(0);
cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click();
cy.get(".page-actions").findByRole("button", { name: "Actions" }).click();
cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click();
cy.click_modal_primary_button('Yes');
//Deleting the custom doctype
cy.visit('/app/doctype');
cy.select_listview_row_checkbox(0);
cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click();
cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click();
cy.click_modal_primary_button('Yes');
cy.click_modal_primary_button("Yes");
});
});
});

View file

@ -1,76 +1,93 @@
context('Timeline Email', () => {
context("Timeline Email", () => {
before(() => {
cy.visit('/login');
cy.visit("/login");
cy.login();
cy.visit('/app/todo');
cy.visit("/app/todo");
});
it('Adding new ToDo', () => {
cy.click_listview_primary_button('Add ToDo');
cy.get('.custom-actions:visible > .btn').contains("Edit in full page").click({delay: 500});
cy.fill_field("description", "Test ToDo", "Text Editor");
it("Adding new ToDo", () => {
cy.click_listview_primary_button("Add ToDo");
cy.get(".custom-actions:visible > .btn").contains("Edit Full Form").click({ delay: 500 });
cy.fill_field("description", "Test ToDo", "Text Editor");
cy.wait(500);
cy.get('.primary-action').contains('Save').click({force: true});
cy.get(".primary-action").contains("Save").click({ force: true });
cy.wait(700);
});
it('Adding email and verifying timeline content for email attachment', () => {
cy.visit('/app/todo');
cy.get('.list-row > .level-left > .list-subject').eq(0).click();
it("Adding email and verifying timeline content for email attachment", () => {
cy.visit("/app/todo");
cy.click_listview_row_item_with_text("Test ToDo");
//Creating a new email
cy.get('.timeline-actions > .timeline-item > .action-buttons > .action-btn').click();
cy.fill_field('recipients', 'test@example.com', 'MultiSelect');
cy.get('.modal.show > .modal-dialog > .modal-content > .modal-body > :nth-child(1) > .form-layout > .form-page > :nth-child(3) > .section-body > .form-column > form > [data-fieldtype="Text Editor"] > .form-group > .control-input-wrapper > .control-input > .ql-container > .ql-editor').type('Test Mail');
cy.get(".timeline-actions > .timeline-item > .action-buttons > .action-btn").click();
cy.fill_field("recipients", "test@example.com", "MultiSelect");
cy.get(
'.modal.show > .modal-dialog > .modal-content > .modal-body > :nth-child(1) > .form-layout > .form-page > :nth-child(3) > .section-body > .form-column > form > [data-fieldtype="Text Editor"] > .form-group > .control-input-wrapper > .control-input > .ql-container > .ql-editor'
).type("Test Mail");
//Adding attachment to the email
cy.get('.add-more-attachments > .btn').click();
cy.get('.mt-2 > .btn > .mt-1').eq(2).click();
cy.get('.input-group > .form-control').type('https://wallpaperplay.com/walls/full/8/2/b/72402.jpg');
cy.get('.btn-primary').contains('Upload').click();
cy.get(".add-more-attachments > .btn").click();
cy.get(".mt-2 > .btn > .mt-1").eq(2).click();
cy.get(".input-group > .form-control").type(
"https://wallpaperplay.com/walls/full/8/2/b/72402.jpg"
);
cy.get(".btn-primary").contains("Upload").click();
//Sending the email
cy.click_modal_primary_button('Send', {delay: 500});
cy.click_modal_primary_button("Send", { delay: 500 });
//To check if the sent mail content is shown in the timeline content
cy.get('[data-doctype="Communication"] > .timeline-content').should('contain', 'Test Mail');
cy.get('[data-doctype="Communication"] > .timeline-content').should(
"contain",
"Test Mail"
);
//To check if the attachment of email is shown in the timeline content
cy.get('.timeline-content').should('contain', 'Added 72402.jpg');
cy.get(".timeline-content").should("contain", "Added 72402.jpg");
//Deleting the sent email
cy.get('[title="Open Communication"] > .icon').first().click({force: true});
cy.get('#page-Communication > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .btn').click();
cy.get('#page-Communication > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .dropdown-menu > li > .grey-link').eq(9).click();
cy.get('.modal.show > .modal-dialog > .modal-content > .modal-footer > .standard-actions > .btn-primary').click();
cy.get('[title="Open Communication"] > .icon').first().click({ force: true });
cy.get(
"#page-Communication > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .btn"
).click();
cy.get(
"#page-Communication > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .dropdown-menu > li > .grey-link"
)
.eq(9)
.click();
cy.get(
".modal.show > .modal-dialog > .modal-content > .modal-footer > .standard-actions > .btn-primary"
).click();
});
it('Deleting attachment and ToDo', () => {
cy.visit('/app/todo');
cy.get('.list-row > .level-left > .list-subject > .level-item.ellipsis > .ellipsis').eq(0).click();
it("Deleting attachment and ToDo", () => {
cy.visit("/app/todo");
cy.click_listview_row_item_with_text("Test ToDo");
//Removing the added attachment
cy.get('.attachment-row > .data-pill > .remove-btn > .icon').click();
cy.get(".attachment-row > .data-pill > .remove-btn > .icon").click();
cy.wait(500);
cy.get('.modal-footer:visible > .standard-actions > .btn-primary').contains('Yes').click();
cy.get(".modal-footer:visible > .standard-actions > .btn-primary").contains("Yes").click();
//To check if the removed attachment is shown in the timeline content
cy.get('.timeline-content').should('contain', 'Removed 72402.jpg');
cy.get(".timeline-content").should("contain", "Removed 72402.jpg");
cy.wait(500);
//To check if the discard button functionality in email is working correctly
cy.get('.timeline-actions > .timeline-item > .action-buttons > .action-btn').click();
cy.fill_field('recipients', 'test@example.com', 'MultiSelect');
cy.get('.modal-footer > .standard-actions > .btn-secondary').contains('Discard').click();
cy.get(".timeline-actions > .timeline-item > .action-buttons > .action-btn").click();
cy.fill_field("recipients", "test@example.com", "MultiSelect");
cy.get(".modal-footer > .standard-actions > .btn-secondary").contains("Discard").click();
cy.wait(500);
cy.get('.timeline-actions > .timeline-item > .action-buttons > .action-btn').click();
cy.get(".timeline-actions > .timeline-item > .action-buttons > .action-btn").click();
cy.wait(500);
cy.get_field('recipients', 'MultiSelect').should('have.text', '');
cy.get('.modal-header:visible > .modal-actions > .btn-modal-close > .icon').click();
cy.get_field("recipients", "MultiSelect").should("have.text", "");
cy.get(".modal-header:visible > .modal-actions > .btn-modal-close > .icon").click();
//Deleting the added ToDo
cy.get('.menu-btn-group:visible > .btn').click();
cy.get('.menu-btn-group:visible > .dropdown-menu > li > .dropdown-item').contains('Delete').click();
cy.get('.modal-footer:visible > .standard-actions > .btn-primary').click();
cy.get(".menu-btn-group:visible > .btn").click();
cy.get(".menu-btn-group:visible > .dropdown-menu > li > .dropdown-item")
.contains("Delete")
.click();
cy.get(".modal-footer:visible > .standard-actions > .btn-primary").click();
});
});

View file

@ -1,43 +1,42 @@
import data_field_validation_doctype from '../fixtures/data_field_validation_doctype';
import data_field_validation_doctype from "../fixtures/data_field_validation_doctype";
const doctype_name = data_field_validation_doctype.name;
context('URL Data Field Input', () => {
context("URL Data Field Input", () => {
before(() => {
cy.login();
cy.visit('/app/website');
return cy.insert_doc('DocType', data_field_validation_doctype, true);
cy.visit("/app/website");
return cy.insert_doc("DocType", data_field_validation_doctype, true);
});
describe('URL Data Field Input ', () => {
it('should not show URL link button without focus', () => {
describe("URL Data Field Input ", () => {
it("should not show URL link button without focus", () => {
cy.new_form(doctype_name);
cy.get_field('url').clear().type('https://frappe.io');
cy.get_field('url').blur().wait(500);
cy.get('.link-btn').should('not.be.visible');
cy.get_field("url").clear().type("https://frappe.io");
cy.get_field("url").blur().wait(500);
cy.get(".link-btn").should("not.be.visible");
});
it('should show URL link button on focus', () => {
cy.get_field('url').focus().wait(500);
cy.get('.link-btn').should('be.visible');
it("should show URL link button on focus", () => {
cy.get_field("url").focus().wait(500);
cy.get(".link-btn").should("be.visible");
});
it('should not show URL link button for invalid URL', () => {
cy.get_field('url').clear().type('fuzzbuzz');
cy.get('.link-btn').should('not.be.visible');
it("should not show URL link button for invalid URL", () => {
cy.get_field("url").clear().type("fuzzbuzz");
cy.get(".link-btn").should("not.be.visible");
});
it('should have valid URL link with target _blank', () => {
cy.get_field('url').clear().type('https://frappe.io');
cy.get('.link-btn .btn-open').should('have.attr', 'href', 'https://frappe.io');
cy.get('.link-btn .btn-open').should('have.attr', 'target', '_blank');
it("should have valid URL link with target _blank", () => {
cy.get_field("url").clear().type("https://frappe.io");
cy.get(".link-btn .btn-open").should("have.attr", "href", "https://frappe.io");
cy.get(".link-btn .btn-open").should("have.attr", "target", "_blank");
});
it('should inject anchor tag in read-only URL data field', () => {
it("should inject anchor tag in read-only URL data field", () => {
cy.get('[data-fieldname="read_only_url"]')
.find('a')
.should('have.attr', 'target', '_blank');
.find("a")
.should("have.attr", "target", "_blank");
});
});
});
});

Some files were not shown because too many files have changed in this diff Show more