Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs #6

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
more atest
  • Loading branch information
bollwyvl committed Nov 10, 2024
commit d41faa6ef78c2c9082bd2823a6999a6d8e25cf08
11 changes: 11 additions & 0 deletions atest/fixtures/002_installer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# this fixture is used in `002_installer.robot` after adding `urljsf` as a dependency

[project]
name = "MyInstaller"
version = "0.1.0"
platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"]
channels = ["conda-forge"]

[dependencies]
python = "*"
urljsf = "*"
34 changes: 26 additions & 8 deletions atest/resources/browser.resource
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
*** Settings ***
Documentation Browser keywords

Library OperatingSystem
Library SeleniumLibrary
Resource ./env.resource


*** Keywords ***
Open Firefox
[Documentation] Start an instrumented firefox.
${options} = Evaluate
... selenium.webdriver.FirefoxOptions()
... selenium.webdriver
${options.binary_location} = Set Variable ${FIREFOX}
Call Method ${options} set_preference ui.prefersReducedMotion ${1}
Call Method ${options} set_preference devtools.console.stdout.content ${True}

Create Directory ${DOWNLOADS}
${ff_options} = Get Firefox Options
... ui.prefersReducedMotion=${1}
... devtools.console.stdout.content=${True}
... browser.download.folderList=${2}
... browser.download.manager.showWhenStarting=${FALSE}
... browser.download.dir=${DOWNLOADS}
... browser.helperApps.neverAsk.saveToDisk=application/toml
${geckolog} = Set Variable ${OUTPUT DIR}${/}geckodriver.log
${geckolog} = Set Variable ${geckolog.replace('\\', '/')}

Open Browser
... about:blank
... headlessfirefox
... options=${options}
... options=${ff_options}
... service=log_output='${geckolog}'; executable_path='${GECKODRIVER}'

Get Firefox Options
[Documentation] Initialize and configure Firefox options
[Arguments] &{prefs}
${ff_options} = Evaluate selenium.webdriver.firefox.options.Options()
... selenium.webdriver.firefox.options
${ff_options.binary_location} = Set Variable ${FIREFOX}
Set Firefox Preferences ${ff_options} &{prefs}
RETURN ${ff_options}

Set Firefox Preferences
[Documentation] Set Firefox options
[Arguments] ${ff_options} &{prefs}
FOR ${pref} ${value} IN &{prefs}
Call Method ${ff_options} set_preference ${pref} ${value}
END
2 changes: 1 addition & 1 deletion atest/resources/coverage.resource
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ ${NEXT_COV_FILE} ${1}
Get Next Coverage File
[Documentation] Get a random filename.
Set Suite Variable ${NEXT_COV_FILE} ${NEXT_COV_FILE.__add__(1)} children=${TRUE}
RETURN ${OUTPUT DIR}${/}istanbul${/}${NEXT_COV_FILE}.cov.json
RETURN ${OUTPUT_DIR}${/}istanbul${/}${NEXT_COV_FILE}.cov.json

Capture Page Coverage
[Documentation] Fetch coverage data from the browser.
1 change: 1 addition & 0 deletions atest/resources/env.resource
Original file line number Diff line number Diff line change
@@ -28,3 +28,4 @@ ${TIMEOUT_LONG} 10s
${BUILD} ${ROOT}${/}build
${DOCS} ${BUILD}${/}docs
${DIST_COV} ${BUILD}${/}dist-cov${/}urljsf
${DOWNLOADS} ${OUTPUT_DIR}${/}Downloads
17 changes: 17 additions & 0 deletions atest/resources/urljsf.resource
Original file line number Diff line number Diff line change
@@ -4,13 +4,16 @@ Documentation Keywords and variables for urljsf.
Resource ./env.resource
Resource ./coverage.resource
Library SeleniumLibrary
Library tomllib AS TOML
Library json AS JSON


*** Variables ***
${CSS_U_FORM} .urljsf-form
${CSS_U_DATALIST} .urljsf-datalist
${CSS_U_DATALIST_CHECK} .urljsf-datalist input[type="checkbox"]
${CSS_U_SUBMIT} .urljsf-submit
&{JSON_NORM} indent=${2} sort_keys=${TRUE}


*** Keywords ***
@@ -40,3 +43,17 @@ Scroll To
[Arguments] ${css_selector}
Execute Javascript
... document.querySelector(`${css_selector.replace('css:', '')}`).scrollIntoView()

Get TOML Fixture
[Documentation] Get some TOML data.
[Arguments] ${path}
${raw} = Get File ${ROOT}${/}atest${/}fixtures${/}${path}
${data} = TOML.Loads ${raw}
RETURN ${data}

Should Be JSON Equivalent
[Documentation] Compare two object for normalized JSON equivalence.
[Arguments] ${left} ${right} ${message}=${EMPTY}
${left_raw} = JSON.Dumps ${left} &{JSON_NORM}
${right_raw} = JSON.Dumps ${right} &{JSON_NORM}
Should Be Equal ${left_raw} ${right_raw} ${message}
37 changes: 37 additions & 0 deletions atest/suites/00_jsdemo.robot
Original file line number Diff line number Diff line change
@@ -9,8 +9,45 @@ Test Setup Open Page _static/urljsf/demo/index.html
Test Teardown Open Blank


*** Variables ***
${SLIDER_ID} urljsf-0-url_xkcd


*** Test Cases ***
JS Demo Opens
[Documentation] Verify the JS demo opens.
Wait Until Element Is Visible css:${CSS_U_FORM}
Capture Element Screenshot css:${CSS_U_FORM} 00-open.png
${n} = Verify XKCD Value Changes
Capture Element Screenshot css:${CSS_U_FORM} 01-changed.png
Verify XKCD URL ${n}


*** Keywords ***
Verify XKCD Value Changes
[Documentation] Verify the slider changes.
${old} = Get XKCD Number
Change XKCD
${new} = Get XKCD Number
Should Not Be Equal ${old} ${new}
RETURN ${new}

Change XKCD
[Documentation] Change a slider value
Press Keys css:#${SLIDER_ID} RIGHT RIGHT

Get XKCD Number
[Documentation] Get a slider value.
${xkcd} = Get Element Attribute css:#${SLIDER_ID} value
RETURN ${xkcd}

Get XKCD URL
[Documentation] Get the submit value.
${url} = Get Element Attribute css:${CSS_U_SUBMIT} href
RETURN ${url}

Verify XKCD URL
[Documentation] Verify the URL against an expected value.
[Arguments] ${n}
${url} = Get Element Attribute css:${CSS_U_SUBMIT} href
Should Be Equal As Strings ${url} https://xkcd.com/${n}
28 changes: 27 additions & 1 deletion atest/suites/01_docs/002_installer.robot
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@ Documentation Verify the `installer` demo.

Resource ../../resources/rjsf.resource
Resource ../../resources/urljsf.resource
Library Collections
Library OperatingSystem
Library SeleniumLibrary
Library urllib.parse

Suite Setup Setup Urljsf Suite 01_docs/002_installer
Test Setup Open Demo installer
@@ -23,6 +26,8 @@ Create An Installer Pixi Project
Capture Page Screenshot 00-open.png
Try Licenses
Make And Fix An Error
Verify Installer URL
Verify Installer Download


*** Keywords ***
@@ -49,5 +54,26 @@ Make And Fix An Error
Input Text css:${p2} python
Wait Until Page Contains 2 dependencies have the name
Element Should Contain css:${CSS_U_SUBMIT} 1 Error
Input Text css:${p2} urlsjf
Input Text css:${p2} urljsf
Element Should Not Contain css:${CSS_U_SUBMIT} Error

Verify Installer URL
[Documentation] Verify the URL against an expected value.
${url} = Get Element Attribute css:${CSS_U_SUBMIT} href
${raw} = Unquote ${url.split(",", 1)[1]}
${from_toml} = TOML.Loads ${raw}
${expected} = Get TOML Fixture 002_installer.toml
Should Be JSON Equivalent ${from_toml} ${expected}

Verify Installer Download
[Documentation] Verify downloaded file
${pt} = Set Variable ${DOWNLOADS}${/}pixi.toml
File Should Not Exist ${pt}
Click Element css:${CSS_U_SUBMIT}
Wait Until Created ${pt}
Sleep 0.1s
${raw} = Get File ${pt}
${from_toml} = TOML.Loads ${raw}
${expected} = Get TOML Fixture 002_installer.toml
Should Be JSON Equivalent ${from_toml} ${expected} Downloaded TOML not as expected
[Teardown] Remove File ${pt}
2 changes: 1 addition & 1 deletion atest/suites/__init__.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*** Settings ***
Documentation Acceptance tests for `urlsjf`
Documentation Acceptance tests for `urljsf`

Resource ../resources/browser.resource
Resource ../resources/server.resource
10 changes: 5 additions & 5 deletions docs/demos.py
Original file line number Diff line number Diff line change
@@ -269,7 +269,7 @@ def installer() -> Urljsf:
"license": "BSD-3-Clause",
"platforms": ["linux-64", "osx-64", "osx-arm64", "win-64"],
"channels": ["conda-forge"],
"dependencies": [{"package": "python", "spec": "3.13.*"}],
"dependencies": [{"package": "python", "spec": "*"}],
}

pixi_checks = {
@@ -307,18 +307,18 @@ def installer() -> Urljsf:

below_template = """
{% import "_pixi_toml" as p %}
{% set t = p.pixi_toml(data.pixi) | trim | safe %}
{% set t = (p.pixi_toml(data.pixi) | trim).val %}

_As TOML:_

```toml
{{ t | trim | safe }}
{{ t }}
```

_As URL:_

```
data:application/toml,{{ t | trim | urlencode | safe }}
data:application/toml,{{ t | urlencode }}
```
"""
macro_import = "{% import '_pixi_toml' as p %}"
@@ -338,7 +338,7 @@ def installer() -> Urljsf:
"url": [
macro_import,
"data:application/toml,",
"{{ p.pixi_toml(data.pixi) | trim | urlencode | safe }}",
"{{ (p.pixi_toml(data.pixi) | trim).val | urlencode }}",
],
"download_filename": "pixi.toml",
"submit_button": "Download `pixi.toml`",
13 changes: 8 additions & 5 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -101,9 +101,11 @@ pip-- = """rm -rf build/pip-freeze/$PIXI_ENVIORNMENT_NAME.txt
pip-check-- = """python -m pip check
&& mkdir -p build/pip-freeze
&& python -m pip list --format=freeze
> build/pip-freeze/$PIXI_ENVIRONMENT_NAME"""
pip-e-- = """pixi r pip-- -e . && pixi r pip-check--"""
pip-whl-- = """pixi r pip-- urljsf --find-links=dist --no-index && pixi r pip-check--"""
> build/pip-freeze/$PIXI_ENVIRONMENT_NAME.txt"""
pip-e-- = """pixi r pip-- -e .
&& pixi r pip-check--"""
pip-whl-- = """pixi r pip-- urljsf --find-links=dist --no-index
&& pixi r pip-check--"""
schema-vars-- = '''echo
PROPS_TS=$PIXI_PROJECT_ROOT/js/src/_props.ts
PROPS_JSON=$PIXI_PROJECT_ROOT/js/schema/v0/props.schema.json
@@ -268,8 +270,9 @@ cmd = """taplo fmt
*.toml
js/demo/toml/*.toml
js/schema/*.toml
tests/fixtures/*/*/*/*.toml"""
inputs = ["*.toml", "{docs,js,src,tests}/**/*.toml"]
tests/fixtures/*/*/*/*.toml
atest/fixtures/*.toml"""
inputs = ["*.toml", "{atest,docs,js,src,tests}/**/*.toml"]

[feature.tasks-lint.tasks.fix-prettier]
description = "- format web-adjacent files with prettier"
2 changes: 1 addition & 1 deletion scripts/atest.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
def main() -> int:
"""Run acceptance tests."""
args: list[str | Path | int] = ["pabot"]
args += ["--artifacts", "png,log,json", "--artifactsinsubfolders"]
args += ["--artifacts", "png,log,json,toml,yaml,yml", "--artifactsinsubfolders"]
env = dict(os.environ)
env.update(
ROOT=f"{ROOT}",
2 changes: 1 addition & 1 deletion scripts/report.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@

HEAD = """<html>
<head>
<title>urlsjf test reports</title>
<title>urljsf test reports</title>
<style>{}</style>
</head>
<body>