[MGNLUI-5893] Fix intermittently failing tests for converted RichTextField Created: 22/May/20  Updated: 22/May/20

Status: Open
Project: Magnolia UI
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Neutral
Reporter: Adam Siska Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoR:
Empty

 Description   

info.magnolia.ui.dialog.FieldsConversionTest#testConvertedRichTextField
src/test/java/info/magnolia/ui/dialog/DefaultValuesConversionTest.java:68

Both tests could fail in two similar situation which are reproducible:

  • in IntelliJ when these particular tests are run in debug mode (single test run) or in batch mode when test is first in a row (or single in batch),
  • with maven if one ignore or comment out all other tests in class (random order of tests is probably cause of random fails on jenkins?).

Both tests fail on NPE because VaadinService call in (RichTextFieldFactory.java:127) that should be set by:

VaadinRequest vaadinRequest = mock(VaadinRequest.class);
doReturn("path").when(vaadinRequest).getContextPath();
VaadinResponse vaadinResponse = mock(VaadinResponse.class);
VaadinService.getCurrent().setCurrentInstances(vaadinRequest, vaadinResponse);

in CompatibilityLayerJcrFormEnvironment::setUp, but under specified conditions VaadinService.getCurrentRequest() returns null here.

Tests could be probably fixed (at least fails not reproducible by provided steps for maven anymore) by setting #setCurrentInstances() inside the test method instead of super.setUp(). Note that this VaadinRequest setup is only needed in case of RichTextField.


Generated at Mon Feb 12 09:31:06 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.