Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are a lot of totally same functions in ParagraphsTestBase and ParagraphsExperimentalTestBase.
Proposed resolution
Make trait with same functions.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#38 | new-patch-refactor-2855309-38.patch | 24.42 KB | Ginovski |
#38 | interdiff-2855309-36-38.txt | 1.93 KB | Ginovski |
#36 | new-patch-refactor-2855309-36.patch | 24.25 KB | Ginovski |
#36 | interdiff-2855309-34-36.txt | 1.71 KB | Ginovski |
#34 | new-patch-refactor-2855309-34.patch | 23.53 KB | Ginovski |
Comments
Comment #2
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedWill work on this.
Comment #3
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedDuplicated code from test bases moved to the trait. This leads to Experimental test base being obsolete, and completely removed.
Now the tests from Experimental widget are extending
ParagraphsTestBase
. Trait is being used only in tests where needed.Comment #5
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedI made mistake with
'entity_reference_paragraphs'
and'paragraphs'
and assigned them to wrong widgets.Comment #7
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAll previous changes are dropped. After discussion with @Berdir we agreed that it is better to keep
ExperimentalTestBase
without changes, and keep the logic separated for two widgets. Here, we create the Trait for all future JS tests to be used.Comment #8
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAdding parameters to make difference between widgets.
Comment #9
toncic CreditAttribution: toncic at MD Systems GmbH commentedThis looks fine for me. We have some basic function that we can continue to work on other issue which are waiting this to be committed.
Comment #10
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedNice!
Maybe $widget_type is more appropriate here.
Also IMHO we should explicitly state which two options are available. Ie: "Options are: ..."
Comment #11
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAddressing comment #10.
Comment #12
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedAny more feedback here?
Comment #13
toncic CreditAttribution: toncic at MD Systems GmbH commentedI am not pretty sure that name is ok for the trait. I think that should have something which will associate that is trait for JS testing.
Comment #14
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedI disagree with the comment #13. This trait can be later used for all of the tests, not only JS. We can just call the namespace and use it in both Experimental and Classic tests.
Comment #15
toncic CreditAttribution: toncic at MD Systems GmbH commentedThe general idea was to do not mix the experimental and classic widget, we are creating this trait only for JS tests.
Comment #16
miro_dietikerHere's why the two worlds should not be mixed:
Say the new widget changes functionality, people start to mangle / alter the test trait. Then they will update the classic trait calls to make the classic still work. This risks that they update it just to make the tests pass - while possibly not understanding what was (and still is) broken.
So every change on the new widget should not interfere with the old widget. This can only be reached by separating traits and bases.
Review complexity and cost of all issues significantly rise and speed is reduced otherwise.
Comment #17
miro_dietikerBut in general, a common trait makes sense, as long as those methods are NOT using the widget UI - instead just use the entity API to create resources. :-)
Comment #18
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedMy proposal is then to have that in
tests/src
and rename it to something that carries the information that we just want to have entity api paragraphs creation stuff in there. Perhaps TestParagraphGeneratiopnTrait? If we find in the future that we could have other general trait stuff, we could have more traits if those are unrelated. Thoughts?Comment #19
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdded check for creating the field storage.
Comment #20
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedIf we take the approach from #17, do we want to update existing tests where relevant (even though we stated differently in #7)?
Comment #21
miro_dietikerWhat we want to keep separate are widget interaction methods and test helpers. A common trait for those are the wrong direction.
Helpers to create entities through entity api (zero UI interaction) are a healthy trait to share and apply to both widgets.
Comment #22
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedThen I think moving this back to Needs work is fine
Comment #23
miro_dietikerAgree. I see the trait here, but it's not used.
For sure, introducing this Trait only makes sense if we use it and through that, the patch will proof that the test code is getting more beautiful - for instance through less repetition.
Comment #24
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedReplaced the test bases methods with the trait and adjusted tests accordingly.
Comment #26
miro_dietikerIMHO we should default $widget_type to 'paragraphs' here and not change those calls above.
Also default the $paragraphs_field_name to something and unify it / skip it wherever possible to field_paragraphs. Currently we also have at least paragraphs and paragraphs_field.
Committing for the current improvements, back to work for the proposed transformation.
Chances are that we broke tests of Paragraphs Collection or other project tests building on top of our traits?
Comment #27
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdded defaults params and modified some function calls that didn't need a lot of changes.
Comment #28
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedRe-uploading with some minor changes
Comment #29
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedRetry for applying patch
Comment #30
miro_dietikerWhy do we need to have here an own field and can't use the default field? (lots of similar locations)
Comment #31
miro_dietikerAgree, this leads to lots of renames. We can commit some intermediate update without #30 rename.
I tried to apply the patch locally, but i have many errors from the test run. Need to investigate what the problem is here.
Comment #32
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedFixed the error in ParagraphsExperimentalAddModesTest, now locally web tests are passing
Comment #33
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedNeeds refactoring after the container summary was committed.
Comment #34
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedRemoved unneeded function in summary test.
Comment #35
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedIf we are adding the defaults, we should change the docblock too.
Comment #36
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdded default in the function docs.
Comment #37
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedTriggered 8.3.x tests too. Looks good to me.
Comment #38
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedOptional in the function docs
Comment #40
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedCommitted, thanks.