Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Merge requests
!131
Resolve "Increase client test coverage"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Increase client test coverage"
165-increase-client-test-coverage
into
dev
Overview
0
Commits
5
Pipelines
4
Changes
3
Merged
Albin Henriksson
requested to merge
165-increase-client-test-coverage
into
dev
3 years ago
Overview
0
Commits
5
Pipelines
4
Changes
3
Expand
Closes
#165 (closed)
0
0
Merge request reports
Viewing commit
ea9a2c12
Prev
Next
Show latest version
3 files
+
3
−
63
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
ea9a2c12
Fix test path
· ea9a2c12
Albin Henriksson
authored
3 years ago
client/src/e2e/LoginPage.test.tsx
0 → 100644
+
70
−
0
Options
import
puppeteer
from
'
puppeteer
'
import
{
CLIENT_URL
,
DEVTOOLS_ENABLED
,
HEADLESS_ENABLED
,
SLOW_DOWN_FACTOR
}
from
'
./TestingConstants
'
describe
(
'
Login page
'
,
()
=>
{
const
buttonSelector
=
'
[data-testid="submit"]
'
const
emailSelector
=
'
[data-testid="email"]
'
const
passwordSelector
=
'
[data-testid="password"]
'
let
browser
:
puppeteer
.
Browser
let
page
:
puppeteer
.
Page
beforeEach
(
async
()
=>
{
// Set up testing environment
browser
=
await
puppeteer
.
launch
({
headless
:
HEADLESS_ENABLED
,
devtools
:
DEVTOOLS_ENABLED
,
slowMo
:
SLOW_DOWN_FACTOR
,
})
page
=
await
browser
.
newPage
()
//Navigate to login screen
await
page
.
goto
(
CLIENT_URL
)
await
page
.
waitForSelector
(
'
.MuiFormControl-root
'
)
})
afterEach
(
async
()
=>
{
await
browser
.
close
()
})
it
(
'
Can submit login user with correct credentials
'
,
async
()
=>
{
await
page
.
click
(
emailSelector
)
await
page
.
keyboard
.
type
(
'
admin@test.se
'
)
await
page
.
click
(
passwordSelector
)
await
page
.
keyboard
.
type
(
'
password
'
)
await
page
.
click
(
buttonSelector
)
await
page
.
waitForTimeout
(
4000
)
const
AdminTitle
=
await
page
.
$eval
(
'
.MuiTypography-root
'
,
(
el
)
=>
el
.
textContent
)
expect
(
AdminTitle
).
toEqual
(
'
Startsida
'
)
},
9000000
)
it
(
'
Shows correct error message when logging in user with incorrect credentials
'
,
async
()
=>
{
await
page
.
click
(
emailSelector
)
await
page
.
keyboard
.
type
(
'
wrong@wrong.se
'
)
await
page
.
click
(
passwordSelector
)
await
page
.
keyboard
.
type
(
'
wrongPassword
'
)
await
page
.
click
(
buttonSelector
)
await
page
.
waitForTimeout
(
1000
)
const
errorMessages
=
await
page
.
$
$eval
(
'
.MuiAlert-message > p
'
,
(
elList
)
=>
elList
.
map
((
p
)
=>
p
.
textContent
))
// The error message is divided into two p elements
const
errorMessageRow1
=
errorMessages
[
0
]
const
errorMessageRow2
=
errorMessages
[
1
]
expect
(
errorMessageRow1
).
toEqual
(
'
Någonting gick fel. Kontrollera
'
)
expect
(
errorMessageRow2
).
toEqual
(
'
dina användaruppgifter och försök igen
'
)
},
9000000
)
it
(
'
Shows correct error message when email is in incorrect format
'
,
async
()
=>
{
await
page
.
click
(
emailSelector
)
await
page
.
keyboard
.
type
(
'
email
'
)
await
page
.
click
(
passwordSelector
)
await
page
.
waitForTimeout
(
1000
)
const
helperText
=
await
page
.
$eval
(
'
.MuiFormHelperText-root
'
,
(
el
)
=>
el
.
textContent
)
expect
(
helperText
).
toEqual
(
'
Email inte giltig
'
)
},
9000000
)
it
(
'
Shows correct error message when password is too short (<6 chars)
'
,
async
()
=>
{
await
page
.
click
(
passwordSelector
)
await
page
.
keyboard
.
type
(
'
short
'
)
await
page
.
click
(
emailSelector
)
const
helperText
=
await
page
.
$eval
(
'
.MuiFormHelperText-root
'
,
(
el
)
=>
el
.
textContent
)
expect
(
helperText
).
toEqual
(
'
Lösenord måste vara minst 6 tecken
'
)
},
9000000
)
})
Loading