Skip to content

Commit

Permalink
ci: hurl end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rosado committed Oct 21, 2024
1 parent b10507d commit 7bb787f
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/hurl/307-missin-params.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# accessing the route without required params should return an error
GET {{ app_host }}/check/link
HTTP 302
[Asserts]
header "Location" == "/check"

GET {{ app_host }}/check/link?dataset=foo
HTTP 302
[Asserts]
header "Location" == "/check"
45 changes: 45 additions & 0 deletions test/hurl/307-submit-file.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
GET {{ app_host }}/check/link
[QueryStringParams]
dataset: conservation-area
orgName: Some Organisation
HTTP 302
[Captures]
session-id: cookie "connect.sid"
upload-method-location: header "Location"

GET {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "How do you want to provide your data"

POST {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
[FormParams]
upload-method: file
HTTP 302
[Captures]
upload-url: header "Location"

GET {{ app_host }}{{ upload-url }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "Upload data"

POST {{ app_host }}{{ upload-url }}
[Cookies]
connect.sid: {{ session-id }}
[MultipartFormData]
datafile: file,common/geox-geoy-example.csv;
HTTP 302
[Captures]
status-url: header "Location"

GET {{ app_host }}{{ status-url }}
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "Status"
20 changes: 20 additions & 0 deletions test/hurl/307-submit-go-back.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GET {{ app_host }}/check/link
[QueryStringParams]
dataset: conservation-area
orgName: Some Organisation
HTTP 302
[Captures]
session-id: cookie "connect.sid"
upload-method-location: header "Location"

GET {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "How do you want to provide your data"

GET {{ app_host }}/check/dataset
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
56 changes: 56 additions & 0 deletions test/hurl/307-submit-tree-url.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
GET {{ app_host }}/check/link
[QueryStringParams]
dataset: tree
orgName: Some Organisation
HTTP 302
[Captures]
session-id: cookie "connect.sid"
geometry-type-location: header "Location"

GET {{ app_host }}{{ geometry-type-location }}
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "Is your geometry data given as points or polygons"

POST {{ app_host }}{{ geometry-type-location }}
[Cookies]
connect.sid: {{ session-id }}
[FormParams]
geomType: point
# alternatively, geomType: polygon
HTTP 302
[Captures]
upload-method-location: header "Location"

GET {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "How do you want to provide your data"

POST {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
[FormParams]
upload-method: url
HTTP 302
[Captures]
upload-url: url

POST {{ app_host }}/check/url
[Cookies]
connect.sid: {{session-id}}
[FormParams]
url: https://gist.githubusercontent.com/rosado/3994e2420857d5c6b0e3bd8dc1488aa1/raw/bf1b52316f66a480a6d116c993ffd57d119094f9/geox-geoy-example.csv
HTTP 302
[Captures]
status-url: header "Location"

GET {{ app_host }}{{ status-url }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "Status"

39 changes: 39 additions & 0 deletions test/hurl/307-submit-url.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
GET {{ app_host }}/check/link
[QueryStringParams]
dataset: conservation-area
orgName: Some Organisation
HTTP 302
[Captures]
session-id: cookie "connect.sid"
upload-method-location: header "Location"

GET {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "How do you want to provide your data"
xpath "string(/html/body/div[2]/main/div/div/form/span)" contains "Conservation area dataset"

POST {{ app_host }}{{ upload-method-location }}
[Cookies]
connect.sid: {{ session-id }}
[FormParams]
upload-method: url
HTTP 302
[Captures]
upload-url: url

POST {{ app_host }}/check/url
[Cookies]
connect.sid: {{ session-id }}
[FormParams]
url: https://gist.githubusercontent.com/rosado/3994e2420857d5c6b0e3bd8dc1488aa1/raw/bf1b52316f66a480a6d116c993ffd57d119094f9/geox-geoy-example.csv
HTTP 302
[Captures]
status-url: header "Location"

GET {{ app_host }}{{ status-url }}
HTTP 200
[Asserts]
xpath "string(/html/head/title)" contains "Status"
36 changes: 36 additions & 0 deletions test/hurl/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# arguments:
# FILE_OR_DIR - optional, name of the file to run, if not provided, runs all scripts
#
# env:
# HURL_app_host - optional, defaults to "http://localhost:5000"
# HURL_report_dir - optional

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

app_host="${HURL_app_host:-"http://localhost:5000"}"
report_dir="${HURL_report_dir:-""}"
test_file="${1:-"${script_dir}"}"

report_option=""
if [ -n "${report_dir}" ]; then
report_option="--report-html ${report_dir}"
fi

echo
echo "ℹ️ Running scripts in directory $script_dir"
echo "ℹ️ app_host=${app_host}"
echo

function run_hurl() {
local file=$1
hurl --test ${report_option} \
--variable app_host="${app_host}" \
${file}
}

if [ -z "${test_file}" ]; then
run_hurl "${script_dir}"
else
echo " running single test"
run_hurl ${test_file}
fi

0 comments on commit 7bb787f

Please sign in to comment.