Closed (fixed)
Project:
Drupal core
Version:
8.8.x-dev
Component:
media system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Aug 2019 at 00:54 UTC
Updated:
17 Sep 2019 at 13:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
oknateHere's a fix, let me see if I can get a fail patch and test coverage.
Comment #3
oknateWhat’s the best way to tell if a config entity hasn’t been saved yet? is it to check the ->id() method?
We could inject the current route match and test if we're on the filter format add form, but this seems unnecessary here.
Comment #4
oknateComment #5
oknateAfter discussing this with larowlan, I think isNew() is the right thing to use. Since Editor uses the ::isNew() method in ConfigEntityBase(), I'm pretty sure isNew() will only return TRUE before saving, although the documentation in ConfigEntityBase is a little unclear, I guess because it can be overridden.
Ah this confirms it:
(from core/tests/Drupal/Tests/Core/Config/ConfigTest.php)
Comment #7
oknateComment #8
oknateCoding standard fixes.
Comment #9
pandaski commentedDo we need to check
Otherwise looks good to me
Comment #10
phenaproximaOnly two things, then RTBC once I've manually tested it. This blocks #2994702: Allow editors to alter embed-specific metadata, as well as `data-align` and `data-caption`.
There's an empty line above this which shouldn't be here, and the we need to expand the comment because it doesn't currently explain why we do this. How about: "If the editor hasn't been saved, we will not be able to create a coherent MediaLibraryState instance, which is needed in order to generate the required configuration. However, if we're creating a new editor, we don't need to do that anyway, so just return an empty array instead."
In a JavaScript test, this feels like cheating. I would prefer if we entered the value in the 'name' field, then waited for the machine name to show up. (Or, alternately, we could wait for the machine name field to have the expected value.)
Comment #11
oknateAddressing feedback in #10.
Comment #12
oknateI forgot to update the comment.
Comment #13
phenaproximaThanks, @oknate. Looks good to me. RTBC when tests are green.
Comment #14
phenaproximaComment #15
oknateSince this regression was found while testing #2994702: Allow editors to alter embed-specific metadata, as well as `data-align` and `data-caption`, I wanted to update the test coverage to reflect changes made there.
I don't want to hold the regression fix back though. So if someone can commit #12, this update in #15 can wait.
Comment #17
oknateSame as #15, just reposting so the last patch isn't a FAIL patch. I should have posted the fail patch penultimately.
Comment #18
oknateFixing a capitalization inconsistency. I capitalized the label one place, but not both places it appears.
Comment #19
wim leers#15 strengthened the test coverage. It already was RTBC in #12.
I wanted to re-RTBC, but:
These comments need to be improved. The first sentence is very broken, the second sentence should have "html" capitalized to "HTML".
Comment #20
wim leersComment #21
oknateFixing comments.
Comment #22
meenakshig commentedimproved comments
Comment #23
oknateI think it's better to just drop the word 'drupal-media', 'drupal-media' isn't the name of the button.
This is what I have in 21:
If we want to be really specific.
Test that when adding the DrupalMediaLibrary button to the editor the correct tags are added to the <drupal-media> tag in the Allowed HTML tags.Comment #24
oknateUpdating the wording.
Comment #25
oknateFixing the wording, part two, line was longer than 80 characters.
Comment #26
oknateAdding the word "when". It was a bit garbled again.
Comment #27
phenaproximaI really wanna re-RTBC, but first a few small things:
Nit: From what I hear, the coding standards don't want us to mix snake_case and camelCase in the same file. So, $buttonElement should be $button_element.
Also, and this is no big deal at all: why are some of the element locators in this test CSS selectors while others are XPath queries?
The comment should have a blank line above it, I think; it's a new "section" of the test.
I'm not sure what this is adding -- it's just proving that the filter form works (and saves the entity), which is surely tested elsewhere and is not really in scope for this test, IMHO.
Comment #28
oknateAddressing feedback in #27
1. Changed $buttonElement variable to $button.
2. Added blank line.
3. Dropped the end of the test where it checks that the attributes save properly. I guess you're right, we don't need test coverage for that.
Comment #29
meenakshig commented1. Changed $buttonElement to $button_element
2. Added a blank line above comment
Comment #30
phenaproximaRegarding #28:
wat.
Looks like there are some unintended changes in here...that patch is RTBC otherwise, I think. Can you post a FAIL patch too, just for completeness' sake?
Comment #31
oknateRerolling patch and adding fail patch.
Comment #32
phenaproximaAnd, DONE. Let's get this bad boy in.
Comment #34
wim leersNot "tags", but "attributes" … 😊
(Can be fixed on commit.)
Comment #35
oknateRe #34: D'oh, yes attributes!, not tags! I won't update it as I don't want to trigger another test. Let's fix it on commit.
Comment #37
catchCommitted/pushed to 8.8.x, thanks!
Comment #38
wim leersThanks @catch, and thanks for fixing #34 on commit :)