[MGNLTEST-142] Stop automatically logging the user out if already logged in Created: 15/Feb/21  Updated: 16/Nov/21  Resolved: 12/Nov/21

Status: Closed
Project: Magnolia Test Framework
Component/s: None
Affects Version/s: 1.0.4
Fix Version/s: 1.2.3

Type: Bug Priority: Neutral
Reporter: Roman Kovařík Assignee: Christoph Meier
Resolution: Fixed Votes: 0
Labels: VN-Testing, artt
Remaining Estimate: Not Specified
Time Spent: 0.5d
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: core-TF-features-bugs-improvements
Story Points: 3

 Description   

ticket description not 100% up-to-date, see comments

Move the automagic logout on PageObjects#login, to a better suited place, such as an "after-each" callback on Selenium extension, so that it does not interfere with login logic. Making sure that the next test gets a new session.

Additional context: the reason for automatic logout is because we already recycle the WebDriver instance between test-cases.

Additional task: before re-introducing the logout in Selenium extension, verify via VNC if two consequent tests are presented with the login screen (despite no explicit logout).



 Comments   
Comment by Christoph Meier [ 04/Mar/21 ]

mgeljic, cc rkovarik

I remember this one is a bit related to the effort of re-using webdriver(s).

And I think I remember that during last grooming session, somebody was mentioning, that most tests are executed with the same user/persona.
That's not true. We should not assume that.

This said, it is really important to always logout at the end of a test!

 

Comment by Christoph Meier [ 11/Oct/21 ]

rkovarik, cc mgeljic

I wanted to ask whether this ticket is still valid.

In PageObjects#loginPage we still do perform a logout - see in git
As far as I understand the ticket asks to change that.

Additionally, in Selenium#afterEach we call
getDriver(extensionContext).ifPresent(WebDriver::quit);
see git

From my point of view that's all fine. I recoomend to close the ticket as obsolete.
I would not add more "black magic" to Selenium - but keep the little pice of convenience/black-magic in PageObjects as it is now.

P.S.
This ticket has been created before MGNLTEST-149 has been created (if that matters).

P.P.S we stumbled over this during grooming .

 

Comment by Mikaël Geljić [ 21/Oct/21 ]

Unearthed the original steps to reproduce from former description:

When using expect.loginPage();

Expected results

I get a login page (if available).

Actual results

If a user is logged in, the user is logged out as part of the method logic.

the method name or javadoc doesn't indicate this side

And indeed this is unexpected from any of the expect/PageObjects methods, as per its javadoc: none of them should have a state-changing effect, but should be limited to passive assertions and returning POs that can be interacted with.

Given a scenario where we assert whether a resource is unaccessible, we would expect.loginPage, but if the assertion does this for us, then this test is void.
 
Re: invoking logout from #afterEach, this might be redundant if WebDriver#quit is enough (if it does close all sessions). That seems to contradict the 2nd line in the description, but happy to be proven otherwise.

Comment by Maxime Michel [ 25/Oct/21 ]

TODOs:

  • remove logic PageObjects#loginPage
  • see which tests rely on this undocumented/unexpected behavior
  • see if automatic logging out needs to happen anywhere (or if WebDriver#quit is sufficient)
  • implement if needed
  • write a test
Comment by Christoph Meier [ 27/Oct/21 ]

UI tests in ce, dx-core and test-fwk are not relying on the removed logic of PageObjects#loginPage.
Other repos I haven't checked.

Tests in PublicationWorkflowFunctionalTests originally relied on that logic, but that has been removed earlier, since subsequent login/logout/login didn't worked within one test method due to other reason. 
But I will try out that again when tackling open tests of PublicationWorkflowFunctionalTests (MGNLEE-668).

Comment by Christoph Meier [ 27/Oct/21 ]

About "see if automatic logging out needs to happen anywhere (or if WebDriver#quit is sufficient)":
Selenium#afterEach calls webdriver::quit. 
And according to https://stackoverflow.com/questions/15067107/difference-between-webdriver-dispose-close-and-quit  that really should be enough.

But I did a test to assert each UI-tests starts with a un-authenticated UI (and gets a new driver)

Generated at Mon Feb 12 07:45:58 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.