Problem/Motivation

This is proving necessary at #3582242: Convert functional tests with suitably simple HTTP requests to kernel tests -- specifically, #3517299: Convert functional tests in help module to kernel tests.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

New \Drupal\Tests\HttpKernelUiHelperTrait::clickLink() method.

Data model changes

Release notes snippet

Issue fork drupal-3582769

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Active » Needs review

joachim’s picture

smustgrave’s picture

Kinda the same for the other one can we convert least 1 spot to use this before marking? Or least a functional test being converted to kernel that'll need this.

Also are we tracking all these as 1 single CR? I'd be in favor of that if possible. Kinda like they're doing with the module function deprecations

joachim’s picture

It's got a test that covers it in the MR though. What do we need an additional test for?

Something with pagination would be simple -- testRevisionsPagination() for example -- but it makes this MR noisier.

CR -- yes, this can be added to the CR for the main drupalGet() issue.

smustgrave’s picture

Correct me if I'm wrong please. But these additional functions aren't needed "right now" but will be useful for when we start to convert functional tests to kernel? If you're saying testRevisionsPagination then I agree with you we shouldn't do that conversion here but I can review testRevisionsPagination to see where this comes into play.

What I was asking if there's an existing kernel test that could make use of this test method but not an additional test on the method itself.

joachim’s picture

Issue summary: View changes

> What I was asking if there's an existing kernel test that could make use of this test method but not an additional test on the method itself.

No, because existing kernel tests don't make HTTP requests yet!

This is needed for #3517299: Convert functional tests in help module to kernel tests. Updating the IS with that link.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Gotcha, then I believe this one is good to go. Appears the same as UiHelperTrait.

dww’s picture

Issue summary: View changes

Looks great, thanks! Nothing to complain about. 😅 Agreed this is both sufficient and necessary. We don't need to do a conversion in this issue, that would be noise. But there are absolutely a bunch of tests that will make use of this once it exists, so we don't have to worry about the "we don't add unused code to core" rule.

I see this is tagged for CR updates. I assume the plan is to add a mention of this at https://www.drupal.org/node/3502609 ?

Something like:

Current MR text

The test trait \Drupal\Tests\HttpKernelUiHelperTrait provides methods drupalGet() and assertSession() which work the same way as drupalGet() in the test trait Drupal\Tests\UiHelperTrait for Browser tests.
...

  public function testFoo(): void {
    $this->drupalGet('my-path');
    $this->assertSession()->pageTextContains('Page title');
    $this->assertSession()->linkExists('Read more'); 
  }

Proposed MR text once this is committed

The test trait \Drupal\Tests\HttpKernelUiHelperTrait provides methods drupalGet(), clickLink() and assertSession() which work the same way as the corresponding methods in the test trait \Drupal\Tests\UiHelperTrait for Browser tests.
...

  public function testFoo(): void {
    $this->drupalGet('my-path');
    $this->assertSession()->pageTextContains('Page title');
    $this->assertSession()->linkExists('Read more'); 
    $this->clickLink('Read more');
    $this->assertSession()->pageTextContains('New page title');
  }

??

Anything else to mention?

Thanks again!
-Derek

smustgrave’s picture

@dww want to open a follow up to address some of those? Maybe a novice task for first time users if you think it's simple (I'm not able to judge that)

dww’s picture

Re: #11 Huh? I was proposing edits to the existing CR so that once this is committed, we can easily finish this task and be done. I'm not interested in follow-up tasks for novices. I just want core committers to not be bothered that this needs CR edits because they're already done and agreed. Trying to be ready to go as soon as this is merged. To that end, any objections to my proposed edits? 😅

Or do you mean about converting tests from Functional to Kernel? That's already being handled (carefully at first, before we open the floodgates) at #3582242: Convert functional tests with suitably simple HTTP requests to kernel tests

Either way, no followups needed, and nothing is ready for novices, yet, either. 😉 Let's make sure we know what we're doing and it's working before we subject new folks to struggling with it (and us to having to review / handhold them through their struggles).

Thanks,
-Derek

dww’s picture

Title: add clickLink to HttpKernelUiHelperTrait » Add clickLink() to HttpKernelUiHelperTrait
joachim’s picture

HttpKernelUiHelperTrait only got committed to core last week, so do we need to do a 'before & after'? Realistically how many people will have started using it?

amateescu’s picture

Posted a couple of comments on the MR, but leaving at RTBC because they're quite minor.

@joachim, the "before" part from @dww's comment is the current text from the CR, so he only pointed out which parts should change.

dww’s picture

Re: #14 - yes, #15, exactly. 😅

Since the CRs aren't markdown docs generated via GitLab pages, which we can't edit along with the code MRs, that was a low-tech attempt at a "patch" against the current CR node. 😂 Updated the headings in #10 to hopefully be more clear.

  • amateescu committed aac54ad5 on 11.x
    feat: #3582769 Add clickLink() to HttpKernelUiHelperTrait
    
    By: joachim...

  • amateescu committed 53a72dc5 on main
    feat: #3582769 Add clickLink() to HttpKernelUiHelperTrait
    
    By: joachim...
amateescu’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 53a72dc5eff to main and aac54ad5278 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joachim’s picture

Ahhhh understood! I've updated the CR: https://www.drupal.org/node/3502609.

dww’s picture

Yay, thanks!

CR edits look good, removing the tag.

Onward!