silverstripe / silverstripe/developer-docs

`assertPartialHTMLMatchBySelector` docs confusion

Open
#72 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/docs
Dominant language
No language data
Stars
7
Forks
74
Avg merge
1d 14m
Merged PRs (30d)
6

Description

Affected Version

4.10

Description

The functional test docs suggest that $this->assertPartialHTMLMatchBySelector will test the element content, but the code actually tests against the outerHTML.

That is to say, the example code in the docs will always fail

$this->assertPartialHTMLMatchBySelector("#MyForm_ID p.error", [
    "That email address is invalid."
]);

it would need to be changed to something like this if we expect it to ever work

$this->assertPartialHTMLMatchBySelector("#MyForm_ID p.error", [
    "<p class=\"error\">That email address is invalid.</p>"
]);

In my case the result I'm getting is

        $this->assertPartialHTMLMatchBySelector('#SaleAdEditForm_getForm_Create_your_account', ['Create your account']);
1) SaleAdEditorPageTest::testCreateAccountWithListing
Failed asserting the CSS selector '#SaleAdEditForm_getForm_Create_your_account' has a partial match to the expected elements:
'Create your account'

Instead the following elements were found:
'<h2 id="SaleAdEditForm_getForm_Create_your_account">Create your account</h2>'
Failed asserting that false is true.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the functional test documentation section linked in the issue and review the assertPartialHTMLMatchBySelector examples alongside the reported failure output. Clarify that matching uses outerHTML, and update the example or explanation so the documented usage matches the actual result. Done means the section no longer implies content-only matching and its example is valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.