[MGNLUI-6297] Ensure closed dialogs are removed from fakeVaadinSession Created: 08/Oct/20  Updated: 08/Oct/21

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

Type: Improvement Priority: Neutral
Reporter: Šimon Demočko Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: FakeMagnoliaUI
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)

 Description   

Currently, closed dialogs stay in fakeVaadinSession hanging. Opening another dialog with the same name results in multiple dialogs with the same name in session. Tests were failing because getDialog returned always the first dialog no matter if it was closed and reopened.

A code change was temporarily introduced to allow tests that reopened dialogs. It is not a robust fix, just a makeshift. 

To have tests failing against which to implement the fix, just replace the makeshift with the former line. 

See the TODO comment in FakeMagnoliaUI under the getDialog method for more info. 

public Window getDialog(String caption) {
    List<Window> windows = this.fakeVaadinSession.getWindowsAdded();
    List<Window> collect = windows.stream().filter(w -> caption.equals(w.getCaption())).collect(Collectors.toList());
    Optional<Window> window = Optional.of(collect.get(collect.size() - 1));
    // TODO Currently I am getting the last opened dialog regardless if it was closed or not.
    //  Ensure closed dialogs are removed from the session.
    //  Do not allow dialogs with same name to be opened if one such exists.
    //  To get failing tests replace the above with
    //  Optional<Window> window = windows.stream().filter(w -> caption.equals(w.getCaption())).findFirst();
    return window.orElseThrow(() -> new RuntimeException("Not found window with caption " + caption));
}

 


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