Skip to content

Commit 1bd842a

Browse files
author
Callin Mullaney
committed
fix: refine render ref pages test
1 parent bf41ca1 commit 1bd842a

2 files changed

Lines changed: 50 additions & 17 deletions

File tree

.github/scripts/render-reference-pages.sh

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ fi
1010
fixture_dir="$1"
1111
output_dir="$2"
1212
base_url="${3:-http://127.0.0.1:8888}"
13+
web_root="${fixture_dir}/web"
1314
server_log="${output_dir}/php-server.log"
1415
cookie_file="${output_dir}/cookies.txt"
1516

@@ -25,34 +26,60 @@ cleanup() {
2526
trap cleanup EXIT
2627

2728
(
28-
cd "$fixture_dir"
29-
php -S 127.0.0.1:8888 -t web web/.ht.router.php >"$server_log" 2>&1
29+
cd "$web_root"
30+
php -S 127.0.0.1:8888 .ht.router.php >"$server_log" 2>&1
3031
) &
3132
server_pid="$!"
3233

34+
ready=0
3335
for _ in $(seq 1 30); do
3436
if curl -fsS "${base_url}/node" >/dev/null 2>&1; then
37+
ready=1
3538
break
3639
fi
3740
sleep 1
3841
done
3942

40-
curl -fsSL "${base_url}/node" >"${output_dir}/frontpage-view.html"
41-
curl -fsSL "${base_url}/node/1" >"${output_dir}/node.html"
42-
curl -fsSL "${base_url}/user/1" >"${output_dir}/user.html"
43-
curl -fsSL "${base_url}/user/login" >"${output_dir}/user-login.html"
44-
curl -fsSL "${base_url}/contact" >"${output_dir}/contact.html"
43+
if [ "$ready" -ne 1 ]; then
44+
echo "Timed out waiting for the PHP built-in server." >&2
45+
sed -n '1,160p' "$server_log" >&2 || true
46+
exit 1
47+
fi
4548

46-
form_build_id="$(grep -o 'name="form_build_id" value="[^"]*"' "${output_dir}/user-login.html" | sed 's/^.*value="//; s/"$//')"
47-
form_token="$(grep -o 'name="form_token" value="[^"]*"' "${output_dir}/user-login.html" | sed 's/^.*value="//; s/"$//')"
49+
curl -fsSL "${base_url}/node" >"${output_dir}/frontpage-view.html"
50+
if grep -q "Drupal already installed" "${output_dir}/frontpage-view.html"; then
51+
echo "Fixture site resolved to Drupal's installer instead of the installed site." >&2
52+
sed -n '1,160p' "$server_log" >&2 || true
53+
exit 1
54+
fi
4855

56+
curl -fsSL "${base_url}/node/1" >"${output_dir}/node.html"
4957
curl -fsSL \
5058
-c "$cookie_file" \
5159
-b "$cookie_file" \
52-
--data-urlencode "name=not-a-real-user" \
53-
--data-urlencode "pass=definitely-wrong" \
54-
--data-urlencode "form_build_id=${form_build_id}" \
55-
--data-urlencode "form_token=${form_token}" \
56-
--data-urlencode "form_id=user_login_form" \
57-
--data-urlencode "op=Log in" \
58-
"${base_url}/user/login" >"${output_dir}/user-login-error.html"
60+
"${base_url}/user/login" >"${output_dir}/user-login.html"
61+
62+
form_build_id="$(grep -o 'name="form_build_id" value="[^"]*"' "${output_dir}/user-login.html" | sed 's/^.*value="//; s/"$//')"
63+
form_token="$(grep -o 'name="form_token" value="[^"]*"' "${output_dir}/user-login.html" | sed 's/^.*value="//; s/"$//' || true)"
64+
65+
if [ -z "$form_build_id" ]; then
66+
echo "Unable to extract the login form_build_id from the rendered user login page." >&2
67+
exit 1
68+
fi
69+
70+
post_args=(
71+
-fsSL
72+
-c "$cookie_file"
73+
-b "$cookie_file"
74+
--data-urlencode "name=not-a-real-user"
75+
--data-urlencode "pass=definitely-wrong"
76+
--data-urlencode "form_build_id=${form_build_id}"
77+
--data-urlencode "form_id=user_login_form"
78+
--data-urlencode "op=Log in"
79+
)
80+
81+
if [ -n "$form_token" ]; then
82+
post_args+=(--data-urlencode "form_token=${form_token}")
83+
fi
84+
85+
curl "${post_args[@]}" "${base_url}/user/login" >"${output_dir}/user-login-error.html"

templates/form/form.html.twig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
* @file
44
* Theme override for a form.
55
*
6+
* Available variables:
7+
* - attributes: A list of HTML attributes for the form element.
8+
* - children: The child elements of the form.
9+
*
610
* This preserves Drupal's default form wrapper output while moving ownership
711
* into the Emulsify parent theme.
812
*/
913
#}
10-
{{ form }}
14+
<form{{ attributes }}>
15+
{{ children }}
16+
</form>

0 commit comments

Comments
 (0)