Skip to content

Create local example form for example tests#308

Merged
mshriver merged 1 commit into
RedHatQE:mainfrom
mshriver:docs-example-tests
Jun 3, 2026
Merged

Create local example form for example tests#308
mshriver merged 1 commit into
RedHatQE:mainfrom
mshriver:docs-example-tests

Conversation

@mshriver

@mshriver mshriver commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

the external depedency isn't loading anymore, tests on main branch are failing

Summary by Sourcery

Replace the getting-started example form flow to use a local HTML page instead of an external website, removing the dependency on external network resources for example execution and tests.

Enhancements:

  • Update the getting-started example script to load a local form file rather than navigating to an external httpbin URL.

Chores:

  • Add a lockfile for the uv-based Python environment.

Copilot AI review requested due to automatic review settings June 2, 2026 09:54
@sourcery-ai

sourcery-ai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

Replaces the external httpbin form dependency in the getting-started example with a local HTML pizza order form that mimics httpbin’s form echo behavior, ensuring example tests run without network access and adds a uv.lock file.

File-Level Changes

Change Details Files
Use a local file-based form instead of an external httpbin URL in the getting-started example script.
  • Compute a file:// URL to a new pizza_form.html located alongside first_script.py using pathlib.Path
  • Replace the previous hard-coded https://httpbin.org/forms/post URL with the locally computed form_url
  • Update the navigation comment to describe the new local pizza order form target
docs/examples/getting-started/first_script.py
Introduce a local HTML pizza order form that approximates httpbin’s form POST echo response for tests.
  • Create a simple pizza order form with various input types (text, tel, email, radio buttons, checkboxes, textarea, submit button) and stable element IDs/names for selectors
  • Add client-side JavaScript that intercepts form submission, builds a JSON object keyed by field names (supporting multiple values as arrays), and replaces the page body with the JSON stringified payload to mimic httpbin
  • Ensure the root body element has a predictable id and the form has a fixed id for reliable automation hooks
docs/examples/getting-started/pizza_form.html
Add a uv.lock dependency lockfile to the repository.
  • Introduce a new uv.lock file at the repository root to lock dependencies for this project
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • The new form_path/form_url logic assumes the HTML file is always present on disk; consider adding a simple existence check or a clearer error message if pizza_form.html is missing to make failures easier to diagnose.
  • The new uv.lock file at the repo root looks unrelated to the example change; double-check whether it is meant to be versioned here or should be excluded from this PR.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `form_path`/`form_url` logic assumes the HTML file is always present on disk; consider adding a simple existence check or a clearer error message if `pizza_form.html` is missing to make failures easier to diagnose.
- The new `uv.lock` file at the repo root looks unrelated to the example change; double-check whether it is meant to be versioned here or should be excluded from this PR.

## Individual Comments

### Comment 1
<location path="docs/examples/getting-started/pizza_form.html" line_range="8" />
<code_context>
+  <title>Pizza Order Form</title>
+</head>
+<body id="page-body">
+  <form id="pizza-form" action="javascript:void(0);" method="post">
+    <label for="custname">Customer name:</label>
+    <input type="text" id="custname" name="custname"><br>
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Avoid using a `javascript:` URL in the `action` attribute and rely on the submit handler instead.

Since the `submit` handler already calls `preventDefault()`, this `action` is unnecessary, and `javascript:` URLs are generally discouraged for security and readability. Consider omitting `action` or using `"#"`/a real endpoint instead.

```suggestion
  <form id="pizza-form" method="post">
```
</issue_to_address>

### Comment 2
<location path="docs/examples/getting-started/pizza_form.html" line_range="59-60" />
<code_context>
+        }
+      });
+
+      // Replace the entire page body with the JSON response (mirrors httpbin behaviour)
+      document.body.innerHTML = JSON.stringify(data);
+    });
+  </script>
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Use textContent (and optionally a <pre>) instead of innerHTML for rendering JSON.

Using `innerHTML` here means any `<` or `&` in the JSON could be interpreted as HTML, which is unsafe and not how JSON is typically rendered. To keep it as plain text while preserving formatting, you could create a `<pre>` element and set its `textContent`, e.g.:

```js
document.body.innerHTML = '<pre></pre>';
document.querySelector('pre').textContent = JSON.stringify(data, null, 2);
```

This avoids HTML parsing while still showing the JSON nicely formatted.

```suggestion
      // Replace the entire page body with the JSON response (mirrors httpbin behaviour),
      // rendering it as plain text inside a <pre> to avoid HTML parsing.
      document.body.innerHTML = '<pre></pre>';
      document.querySelector('pre').textContent = JSON.stringify(data, null, 2);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread docs/examples/getting-started/pizza_form.html Outdated
Comment thread docs/examples/getting-started/pizza_form.html Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the getting-started example’s dependency on an external website by switching the demo flow to a local HTML form, improving reliability for running the example and for CI environments without network access.

Changes:

  • Added a local pizza_form.html page that mimics the prior form/response flow.
  • Updated first_script.py to navigate to the local HTML file via a file:// URI.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/examples/getting-started/pizza_form.html Adds a local form page and client-side “response” rendering to emulate the prior external form endpoint.
docs/examples/getting-started/first_script.py Switches navigation from the external URL to a local pizza_form.html file resolved at runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/examples/getting-started/pizza_form.html Outdated
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.72%. Comparing base (7c917f1) to head (e6689c1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #308   +/-   ##
=======================================
  Coverage   92.72%   92.72%           
=======================================
  Files          19       19           
  Lines        2750     2750           
=======================================
  Hits         2550     2550           
  Misses        200      200           
Flag Coverage Δ
unittests 92.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mshriver mshriver force-pushed the docs-example-tests branch 2 times, most recently from d43e831 to 02f7a1b Compare June 2, 2026 14:21
the external depedency isn't loading anymore

Co-authored-by: Claude <noreply@anthropic.com>
@mshriver mshriver force-pushed the docs-example-tests branch from 02f7a1b to e6689c1 Compare June 2, 2026 14:22
@mshriver mshriver merged commit 89479c8 into RedHatQE:main Jun 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants