Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BudgetMaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robert Goldmann
BudgetMaster
Commits
7d3baaa7
Commit
7d3baaa7
authored
3 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
LoginControllerTest: explicitly log out after each test
parent
b8eacc9a
No related branches found
No related tags found
No related merge requests found
Pipeline
#5531
failed
3 years ago
Stage: external
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/de/deadlocker8/budgetmaster/integration/selenium/LoginControllerTest.java
+38
-13
38 additions, 13 deletions
...udgetmaster/integration/selenium/LoginControllerTest.java
with
38 additions
and
13 deletions
src/test/java/de/deadlocker8/budgetmaster/integration/selenium/LoginControllerTest.java
+
38
−
13
View file @
7d3baaa7
...
@@ -6,11 +6,9 @@ import de.deadlocker8.budgetmaster.integration.helpers.SeleniumTestBase;
...
@@ -6,11 +6,9 @@ import de.deadlocker8.budgetmaster.integration.helpers.SeleniumTestBase;
import
de.thecodelabs.utils.util.Localization
;
import
de.thecodelabs.utils.util.Localization
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTimeUtils
;
import
org.joda.time.DateTimeUtils
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.*
;
import
org.openqa.selenium.Cookie
;
import
org.openqa.selenium.JavascriptExecutor
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
...
@@ -24,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -24,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
LoginControllerTest
extends
SeleniumTestBase
class
LoginControllerTest
extends
SeleniumTestBase
{
{
@Test
@Test
void
getLoginPage
()
void
test_
getLoginPage
()
{
{
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
helper
.
start
();
helper
.
start
();
...
@@ -40,7 +38,7 @@ class LoginControllerTest extends SeleniumTestBase
...
@@ -40,7 +38,7 @@ class LoginControllerTest extends SeleniumTestBase
}
}
@Test
@Test
void
wrongCredentials
()
void
test_
wrongCredentials
()
{
{
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
helper
.
start
();
helper
.
start
();
...
@@ -51,7 +49,7 @@ class LoginControllerTest extends SeleniumTestBase
...
@@ -51,7 +49,7 @@ class LoginControllerTest extends SeleniumTestBase
}
}
@Test
@Test
void
successLogin
()
void
test_
successLogin
()
{
{
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
helper
.
start
();
helper
.
start
();
...
@@ -65,7 +63,7 @@ class LoginControllerTest extends SeleniumTestBase
...
@@ -65,7 +63,7 @@ class LoginControllerTest extends SeleniumTestBase
}
}
@Test
@Test
void
successLogin_cookieIsSet
()
void
test_
successLogin_cookieIsSet
()
{
{
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
helper
.
start
();
helper
.
start
();
...
@@ -82,7 +80,7 @@ class LoginControllerTest extends SeleniumTestBase
...
@@ -82,7 +80,7 @@ class LoginControllerTest extends SeleniumTestBase
}
}
@Test
@Test
void
successLogin_cookieShortlyAfterMidnightInSystemTimezone
()
void
test_
successLogin_cookieShortlyAfterMidnightInSystemTimezone
()
{
{
// override system time to setup midnight scenario
// override system time to setup midnight scenario
// DateTime.now() will return the time in UTC --> shortly before midnight
// DateTime.now() will return the time in UTC --> shortly before midnight
...
@@ -112,7 +110,7 @@ class LoginControllerTest extends SeleniumTestBase
...
@@ -112,7 +110,7 @@ class LoginControllerTest extends SeleniumTestBase
}
}
@Test
@Test
void
logout
()
void
test_
logout
()
{
{
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
IntegrationTestHelper
helper
=
new
IntegrationTestHelper
(
driver
,
port
);
helper
.
start
();
helper
.
start
();
...
@@ -120,12 +118,39 @@ class LoginControllerTest extends SeleniumTestBase
...
@@ -120,12 +118,39 @@ class LoginControllerTest extends SeleniumTestBase
helper
.
hideBackupReminder
();
helper
.
hideBackupReminder
();
helper
.
hideWhatsNewDialog
();
helper
.
hideWhatsNewDialog
();
logout
();
WebElement
label
=
driver
.
findElement
(
By
.
id
(
"loginMessage"
));
assertThat
(
label
.
getText
()).
isEqualTo
(
Localization
.
getString
(
"logout.success"
));
}
@AfterEach
public
void
afterEach
()
{
tryToLogout
();
}
private
void
tryToLogout
()
{
//noinspection CatchMayIgnoreException
try
{
logout
();
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
Duration
.
ofSeconds
(
5
));
wait
.
until
(
ExpectedConditions
.
textToBe
(
By
.
id
(
"loginMessage"
),
Localization
.
getString
(
"logout.success"
)));
}
catch
(
NoSuchElementException
e
)
{
}
}
private
void
logout
()
{
WebElement
buttonLogout
=
driver
.
findElement
(
By
.
xpath
(
"//body/ul/li/a[contains(text(), 'Logout')]"
));
WebElement
buttonLogout
=
driver
.
findElement
(
By
.
xpath
(
"//body/ul/li/a[contains(text(), 'Logout')]"
));
JavascriptExecutor
js
=
(
JavascriptExecutor
)
driver
;
JavascriptExecutor
js
=
(
JavascriptExecutor
)
driver
;
js
.
executeScript
(
"arguments[0].scrollIntoView(true);"
,
buttonLogout
);
js
.
executeScript
(
"arguments[0].scrollIntoView(true);"
,
buttonLogout
);
buttonLogout
.
click
();
buttonLogout
.
click
();
WebElement
label
=
driver
.
findElement
(
By
.
id
(
"loginMessage"
));
assertThat
(
label
.
getText
()).
isEqualTo
(
Localization
.
getString
(
"logout.success"
));
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment