We broke the output of pseudofield flags and didn't notice (#2599304: [regression] Reimplement Contextual Link Display). We're missing tests for the various options that allow a flag to show in different places:

- entity links, each view mode
- pseudofield, enabled and disabled
- entity form (probably not working right now)
- contextual links (patch here: #2599304: [regression] Reimplement Contextual Link Display)

I think the best thing here is a new test class that covers just this area -- called something like OutputLocationTest maybe.

Test should create a flag with the reload link type (as that's the simplest). We don't need to test the link works -- that's the job of other tests. We just need to check the link outputs as expected. We also need to check the link *doesn't* output, so there should be one step where all the options are disabled and the flag link text should not show.

So:

- create flag programmatically, set it to not show anywhere
- create node that's flaggable
- check teaser and full views modes for the flag link: it should not show
- set the flag link to show in entity links, one mode at a time, checking each time
- set the flag link to show as a pseudofield. Disable it, then enable it in field view options.

Also, there's a bit of testing for this in FlagSimpleTest::doFlagLinkTeaserTest(), which should be removed from there and incorporated into the new tests.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Active » Needs work
FileSize
3.31 KB

I am totally stumped on this at the moment.

I am using the test xpath() method to check the flag link, as we need to differentiate between the link as a pseudofield, and the link within the entity links.

When I open the page as seen by the test browser, this xpath expression works (with a Firefox xpath plugin):

"//*[contains(@class, 'node__content')]/a[@id = ':id']"

but it fails in the test!

I'm posting my work so far in the hope someone can help me figure this out :)

nlisgo’s picture

Status: Needs work » Needs review
FileSize
706 bytes
3.26 KB
nlisgo’s picture

Just needed to remove the single quotes around the placeholder :id.

joachim’s picture

THANK YOU!!!! :)

nlisgo’s picture

You're very welcome. Happy to help.

emclaughlin’s picture

Status: Needs review » Needs work

I think some of the TODOs should be filled out before this can actually be committed? But I mean, beyond TODOs, it looks good to me so if y'all are okay with those being a separate issue, then this is RBTC by me. But I'm setting it back to Needs Work until someone with more authority than me weighs in.

joachim’s picture

Assigned: Unassigned » joachim

No, this is still a work in progress. I just got stuck on the xpath bit.

joachim’s picture

Assigned: joachim » Unassigned
Status: Needs work » Needs review
FileSize
6.35 KB

Finished -- as much as can be until #2411977: [regression] Reimplement Entity links Display is fixed.

joachim’s picture

Tests pass, but it would be good to get a review of this, just to check that it tests the things it ought to be testing.

joachim’s picture

Status: Needs review » Needs work

FlagSimpleTest::doFlagLinkTeaserTest() should be removed, as that's covered in the new class this patch adds.

joachim’s picture

joachim’s picture

martin107’s picture

From #10

Tests pass, but it would be good to get a review of this, just to check that it tests the things it ought to be testing.

The separation of test concerns makes sense to me.... and we get coverage that is appropriate.. yes there are lots of todos but that is ok it is in a good direction
so plus one from me...

My changes are just minor nit picks

1) I have locked down the input parameter requirements for various LinkOutputLocationTest::assertXYZ() methods and spruced up the method annotations.

2) I have changed a variable name ... LinkOutputLocationTest::testLinkLocation()::$flag_config. As it was showing up in my lint tool as an inappropriate reuse of a unconnected local variable. This is a trivial maintenance hazard ... if a config option needs to be added to the configuration at the top of the method then something unwanted could bleed into the second configuration.

Naming things is hard so if you object to the variable names that is fine ... please let me know and I will jump on it.

3) LinkOutputLocationTest::$node - I have changed the propery type to NodeInterface ... I just want to imply flexibility, while the call to Node::create() will generate an instance of \Drupal\node\Entity\Node I want to suggest that our test will work on anything conforming to the interface.

4) Make little changes seen while running LinkOutputLocationTest through phpcs.

socketwench’s picture

Status: Needs review » Reviewed & tested by the community

I like this. Again, there's a lot of TODOs, but it's clear what is intended to go where as we solve issues.

joachim’s picture

Thanks for all those cleanups, @martin107!

There's just one I'm not keen on:

> 2) I have changed a variable name ... LinkOutputLocationTest::testLinkLocation()::$flag_config. As it was showing up in my lint tool as an inappropriate reuse of a unconnected local variable. This is a trivial maintenance hazard ... if a config option needs to be added to the configuration at the top of the method then something unwanted could bleed into the second configuration.

I see this as the same way that each time you do a drupalPost, you make an $edit array. Having the variable name change each time means that it's harder to copy-paste bits of the code to further tests in future, and I think it makes it harder to follow the repetitive pattern of the test.

I'll reroll :)

martin107’s picture

Assigned: Unassigned » martin107

If you don;t mind waiting until tonight ... I will revert

( I am quite happy to backout things that fail review.)

martin107’s picture

Title: missing test coverage for flag link output locations » Missing test coverage for flag link output locations
Assigned: martin107 » Unassigned
FileSize
8.41 KB
1.61 KB

Reverted #14.2

joachim’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the reroll :) And thanks @socketwench for the review too.

Committed! -- with just a small tweak for a missing blank line after the import statements.

  • joachim committed ec5650a on 8.x-4.x
    Issue #2600146 by joachim, martin107, nlisgo: Fixed missing test...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.