Closed (duplicate)
Project:
Drupal core
Version:
8.4.x-dev
Component:
Classy theme
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Oct 2015 at 12:07 UTC
Updated:
24 Mar 2022 at 09:46 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersSomething like this.
I think we want test coverage. Especially because I don't even understand why this works. Note that we don't check if there are in fact messages; we simply move this from outside the block to inside the block. Seems like there's some special Twig stuff happening that makes this only be invoked in case a Twig block is not empty?
Comment #3
wim leersComment #4
fabianx commentedInteresting, yes tests would be good for this.
Comment #5
wim leersTweeted about this, hopefully somebody wants to write the tests for this: https://twitter.com/wimleers/status/659679378096410624 :)
For this test, we need a
WebTestBasetest that:loaded
Comment #6
star-szrThanks!
Comment #7
dom. commented@Wim Leers : Are you waiting for something this kind ?!
If yes, then the remaining @todo whould be I guess:
- validate you are okay with where to put this test files
- change the test to work with a lighter profile (ie testing)
Comment #8
wim leersYes!
But I'm confused why this test passes. I suspect it's simply not being executed by testbot? (Because it's in the wrong location?) It's asserting that the CSS exists when no message is shown, and vice versa. Which is the opposite of what we want :)
This is definitely the correct track :)
Needs to be updated.
You should be able to just delete this line, as you already indicated.
s/asserts/assets/ :)
Let's be more specific:
core/themes/classy/css/components/messages.css.Comment #9
snehi commentedDone as suggested in #8 except 1.
What to write in case of 1.
Comment #11
dom. commentedThis tests actually :
"Tests that message assets get loaded only when needed".
This needs also to be as specific as core/themes/classy/css/components/messages.css
Comment #12
dom. commentedAlso because I suggested changing from standard profile in test to testing, Wim Leers said to remove such lign.
But it also takes:
1: to remove associated comments.
2: to make sure the message block is placed on a region by default, which I am not sure about...
Comment #13
dom. commented';' is missing
';' is missing
Comment #14
dom. commentedIn this comment, I'm including a new test-only patch (with interdiff).
Also including same patch with fix by Wim #2 included.
@Wim Leers: do you want us to continue only with usual patch file fix+tests in next comments or test-only ?
Comment #17
dom. commentedIn order to check if CSS files is included or not from source code analysis, it takes to unactivate default css aggregation first.
Also test was upside-down: messages.css should not be loaded when no message is display, but loaded when there is a message.
Correction in patch attached.
Comment #19
sdstyles commentedSeems core/themes/classy/css/components/messages.css is added even a message doesn't exist.
Comment #21
wim leersThat's because:
Fixed those things.
This now lives outside of the Twig block.
Is that correct, Twig experts?
Comment #22
fabianx commented#21: That should be wrong.
A template 'A' using extends on 'B' is just:
So the render function of template B is used, which then calls block_messages() - which is why there is {{ parent() }} command within blocks ...
Comment #23
wim leersThanks for confirming my suspicion!
Comment #24
dom. commented@Wim Leers and @Fabianx :
I got confused on what's remaining to do here. Could you elaborate ? Is it still Novice ?
Comment #25
star-szrIt seems like it's fine being outside the Twig block, and that is how it was before. Maybe I'm missing something though. Moving the attach_library() inside the Twig block would IMO be considered a BC break as well, for example I think it would be a regression for Bartik (let's pretend Bartik was a contrib/custom theme for a moment).
I was wondering why this is in KernelTests if it's a WebTestBase test. I think maybe because it's right next to DrupalSetMessageTest :) it should be moved, /core/modules/system/src/Tests/Bootstrap is probably closer to where we want it.
Comment #26
andypostclean-up tags
Comment #37
quietone commentedDoing Bug smash triage.
Dig some digging and it looks like that was fixed in a later issue #2853509: Don't render status messages if there are no messages but also include their assets if there might be.
Closing as a duplicate and I'll add credit over there.
Thanks.