Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automated_testing_kit
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
automated_testing_kit
Merge requests
!27
Il/prereq
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Il/prereq
IL/prereq
into
1.0.x
Overview
0
Commits
2
Pipelines
0
Changes
16
Merged
Il/prereq
ilyaukin
requested to merge
IL/prereq
into
1.0.x
4 months ago
Overview
0
Commits
2
Pipelines
0
Changes
16
0
0
Merge request reports
Compare
1.0.x
1.0.x (base)
and
latest version
latest version
db1dbe1a
2 commits,
4 months ago
16 files
+
202
−
57
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
16
cypress/support/atk_utilities.js
+
32
−
7
View file @ db1dbe1a
Edit in single-file editor
Open in Web IDE
Show full file
/// <reference types='Cypress' />
import
fs
from
'
fs
'
;
import
YAML
from
'
yaml
'
;
import
fs
from
'
fs
'
import
YAML
from
'
yaml
'
/**
* Return a string of random characters of specified length.
*
* @param {length} int Length of string to return.
*/
function
createRandomString
(
length
)
{
function
createRandomString
(
length
)
{
let
result
=
''
const
characters
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
const
charactersLength
=
characters
.
length
@@ -25,8 +25,8 @@ function createRandomString (length) {
* @return {{userRoles: *[], userPassword: string, userEmail: string, userName: string}}
*/
function
createRandomUser
()
{
const
name1
=
createRandomString
(
6
)
;
const
name2
=
createRandomString
(
6
)
;
const
name1
=
createRandomString
(
6
)
const
name2
=
createRandomString
(
6
)
return
{
userName
:
`
${
name1
}
${
name2
}
`
,
userEmail
:
`
${
name1
.
toLowerCase
()}
.
${
name2
.
toLowerCase
()}
@ethereal.email`
,
@@ -42,8 +42,33 @@ function createRandomUser() {
* @return {object}
*/
function
readYAML
(
filename
)
{
return
cy
.
readFile
(
`cypress/data/
${
filename
}
`
).
then
((
text
)
=>
YAML
.
parse
(
text
))
;
return
cy
.
readFile
(
`cypress/data/
${
filename
}
`
).
then
((
text
)
=>
YAML
.
parse
(
text
))
}
/**
* Get multi-level property from an object.
* E.g. if object is {"foo":{"bar":"buzz"}} and key is "foo.bar",
* "buzz" will be returned.
* If key at some level does not exist, null is returned.
*
* @param object {*} Initial object.
* @param key {string} Property path.
* @return {*}
*/
function
getProperty
(
object
,
key
)
{
let
result
result
=
object
for
(
const
p
of
key
.
split
(
'
.
'
))
{
if
(
result
===
undefined
)
{
return
null
}
result
=
result
[
p
]
}
if
(
result
===
undefined
)
{
return
null
}
return
result
}
export
{
createRandomString
,
createRandomUser
,
readYAML
}
export
{
createRandomString
,
createRandomUser
,
readYAML
,
getProperty
}
Loading