diff --git a/.gitignore b/.gitignore index b231e87..fc71f6a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,6 @@ parts/ pyvenv.cfg var/ local.cfg -.python-version # mxdev /instance/ @@ -47,8 +46,6 @@ local.cfg /venv/ .installed.txt -robot_* -test_* forest.* ## diff --git a/.meta.toml b/.meta.toml index 1414a7f..d6b0222 100644 --- a/.meta.toml +++ b/.meta.toml @@ -3,7 +3,7 @@ # See the inline comments on how to expand/tweak this configuration file [meta] template = "default" -commit-id = "721299ce" +commit-id = "5d22fbf8" [pyproject] codespell_skip = "*.js,*.min.js,*.min.js.map,*.min.css.map,*.svg,*.lock,*.json" @@ -17,7 +17,5 @@ jobs = [ [gitignore] extra_lines = """ -robot_* -test_* forest.* """ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d60054b..1460326 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -16,7 +16,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/collective/zpretty @@ -32,7 +32,7 @@ repos: # """ ## - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 @@ -44,7 +44,7 @@ repos: # """ ## - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell additional_dependencies: @@ -71,7 +71,7 @@ repos: - id: check-python-versions args: ['--only', 'setup.py,pyproject.toml'] - repo: https://github.com/collective/i18ndude - rev: "6.2.0" + rev: "6.2.1" hooks: - id: i18ndude diff --git a/pyproject.toml b/pyproject.toml index 59cb531..9947b68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ target-version = ["py38"] ## [tool.codespell] -ignore-words-list = "discreet," +ignore-words-list = "discreet,assertin," skip = "*.po,*.js,*.min.js,*.min.js.map,*.min.css.map,*.svg,*.lock,*.json" ## # Add extra configuration options in .meta.toml: @@ -83,6 +83,7 @@ Zope = [ 'Products.CMFCore', 'Products.CMFDynamicViewFTI', ] python-dateutil = ['dateutil'] +pytest-plone = ['pytest', 'zope.pytestlayer', 'plone.testing', 'plone.app.testing'] ## # Add extra configuration options in .meta.toml: diff --git a/src/collective/taxonomy/tests/robot/test_taxonomy.robot b/src/collective/taxonomy/tests/robot/test_taxonomy.robot new file mode 100644 index 0000000..c1b2e1a --- /dev/null +++ b/src/collective/taxonomy/tests/robot/test_taxonomy.robot @@ -0,0 +1,78 @@ +*** Settings *** + +Resource plone/app/robotframework/browser.robot + +Library Remote ${PLONE_URL}/RobotRemote +Library Collections + +Test Setup Run Keywords Plone test setup +Test Teardown Run keywords Plone test teardown + + +*** Variables *** + +${TITLE} An edited page +${PAGE_ID} an-edited-page + + +*** Test Cases *** + +Scenario: As a manager I can add a taxonomy + Given a logged in manager + and an page type with a taxonomy + When I edit the page + and I select multiple options + Then I see '2' selected options + + When I save the page + and I edit the page + and I deselect option 'Information Science' + Then I see '1' selected options + +*** Keywords *** + +# Given + +a logged in manager + Enable autologin as Manager + +an page type with a taxonomy + Create content + ... type=Document + ... title=${TITLE} + + Go to ${PLONE_URL}/dexterity-types/Document/@@behaviors + Check Checkbox //input[@name="form.widgets.collective.taxonomy.generated.test:list"] + Click //button[@name="form.buttons.apply"] + Wait For Condition Text //body contains Behaviors successfully updated. + +# When +I edit the page + Go to ${PLONE_URL}/${PAGE_ID}/edit + Get Text //body contains Edit Page + +I select multiple options + Select Options By //select[@name="form.widgets.test.taxonomy_test.from"] index 0 2 + Click //button[@name="from2toButton"] + +I save the page + Click //button[@name="form.buttons.save"] + Wait For Condition Text //body contains Changes saved + +I deselect option '${label}' + Select Options By //select[@name="form.widgets.test.taxonomy_test.to"] label ${label} + Click //button[@name="to2fromButton"] + +# Then +I see '${count}' selected options + Get Element Count //select[@name="form.widgets.test.taxonomy_test.to"]/option should be ${count} + +# Misc + +Pause + [Documentation] Visually pause test execution with interactive dialog by + ... importing **Dialogs**-library and calling its + ... **Pause Execution**-keyword. + Import library Dialogs + Pause execution + diff --git a/src/collective/taxonomy/tests/robot/todo_test_taxonomy.robot b/src/collective/taxonomy/tests/robot/todo_test_taxonomy.robot deleted file mode 100644 index 71a88b9..0000000 --- a/src/collective/taxonomy/tests/robot/todo_test_taxonomy.robot +++ /dev/null @@ -1,105 +0,0 @@ -# ============================================================================ -# EXAMPLE ROBOT TESTS -# ============================================================================ -# -# Run this robot test stand-alone: -# -# $ bin/test -s collective.taxonomy -t test_taxonomy.robot --all -# -# Run this robot test with robot server (which is faster): -# -# 1) Start robot server: -# -# $ bin/robot-server --reload-path src collective.solr.testing.COLLECTIVE_SOLR_ROBOT_TESTING -# -# 2) Run robot tests: -# -# $ bin/robot src/collective/solr/tests/robot/test_search.robot -# -# See the http://docs.plone.org for further details (search for robot -# framework). -# -# ============================================================================ - -*** Settings ***************************************************************** - -Resource plone/app/robotframework/selenium.robot -Resource plone/app/robotframework/keywords.robot -Resource Products/CMFPlone/tests/robot/keywords.robot - -Library Remote ${PLONE_URL}/RobotRemote -Library DateTime - -Test Setup TestSetup -Test Teardown TestTeardown - -*** Variables *** - -${BROWSER} chrome - - -*** Test Cases *************************************************************** - -Scenario: As a manager I can add a taxonomy - Given a logged in manager - When I search for 'Colorless Green Ideas' - Then the search returns '1' results - and the search results should include 'Colorless Green Ideas' - -*** Keywords ***************************************************************** - -# Test Setup/Teardown - -TestSetup - Open test browser -# a logged in Manager - - -TestTeardown -# a logged in Manager - Close all browsers - - -# Given - -a logged in manager - Enable autologin as Manager - - -# When - -I search for '${searchterm}' - Go to ${PLONE_URL}/@@search - Input text xpath=//main//input[@name='SearchableText'] ${searchterm} - -I filter the search by portal type '${portal_type}' - Click Element xpath=//button[@id='search-filter-toggle'] - Wait until page contains element xpath=//input[@id='query-portaltype-Collection'] - Unselect Checkbox xpath=//input[@id='query-portaltype-Collection'] - Unselect Checkbox xpath=//input[@id='query-portaltype-Document'] - -I filter the search by creation date '${date_filter}' - Click Element xpath=//button[@id='search-filter-toggle'] - Wait until page contains element xpath=//input[@id='query-portaltype-Collection'] - Select Radio Button created query-date-${date_filter} - -# Then - -the search returns '${result_count}' results - Wait until keyword succeeds 5s 1s XPath Should Match X Times //strong[@id='search-results-number' and contains(.,'${result_count}')] 1 The search should have returned '${result_count}' results. - -the search results should include '${term}' - Wait until page contains element xpath=//ol[@class='searchResults'] - Page should contain ${term} - XPath Should Match X Times //div[@id='search-results']//ol//li//a[contains(., '${term}')] 1 Search results should have contained '${term}'. - -the search results should not include '${term}' - Wait until page contains Search results - Page should not contain element xpath=//*[@class='searchResults']/a[contains(text(), '${term}')] - - -# Misc - -Capture screenshot - [Arguments] ${filename} - Capture Page Screenshot filename=../../../../docs/_screenshots/${filename} diff --git a/src/collective/taxonomy/widget_input.pt b/src/collective/taxonomy/widget_input.pt index 8001fd9..0a742d6 100644 --- a/src/collective/taxonomy/widget_input.pt +++ b/src/collective/taxonomy/widget_input.pt @@ -150,7 +150,6 @@ function selectionError() {