Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cypress
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Docker
Cypress
Commits
d920a9bc
Commit
d920a9bc
authored
2 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
Delete taxonomy terms that have been created during testing when the user gets deleted as well
parent
a3234ecc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#699202
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
commands.js
+23
-0
23 additions, 0 deletions
commands.js
with
23 additions
and
0 deletions
commands.js
+
23
−
0
View file @
d920a9bc
...
...
@@ -13,6 +13,7 @@ Cypress.Commands.add('login', (options) => {
})
Cypress
.
Commands
.
add
(
'
createAndLogin
'
,
(
username
,
role
)
=>
{
cy
.
rememberLatestTaxonomyTerm
();
let
password
=
'
random-password-
'
+
Cypress
.
_
.
random
(
0
,
1
e6
);
cy
.
drush
(
'
user:create
'
+
username
+
'
--password=
'
+
password
);
cy
.
drush
(
'
user:role:add
'
+
role
+
'
'
+
username
);
...
...
@@ -25,6 +26,7 @@ Cypress.Commands.add('createAndLogin', (username, role) => {
Cypress
.
Commands
.
add
(
'
deleteLogin
'
,
(
username
)
=>
{
cy
.
drush
(
'
user:cancel --delete-content
'
+
username
);
cy
.
deleteTestTaxonomyTerms
();
})
Cypress
.
Commands
.
add
(
'
checkSessionCookie
'
,
()
=>
{
...
...
@@ -43,3 +45,24 @@ Cypress.Commands.add('checkSessionCookie', () => {
Cypress
.
Commands
.
add
(
'
drush
'
,
(
command
)
=>
{
cy
.
exec
(
'
docker exec $PHP_CONTAINER drush -y
'
+
command
)
})
let
maxTid
=
-
1
;
Cypress
.
Commands
.
add
(
'
rememberLatestTaxonomyTerm
'
,
()
=>
{
cy
.
drush
(
'
sql:query "select max(tid) from taxonomy_term_data"
'
).
then
((
result
)
=>
{
cy
.
log
(
result
);
maxTid
=
result
.
stdout
;
});
})
Cypress
.
Commands
.
add
(
'
deleteTestTaxonomyTerms
'
,
()
=>
{
if
(
maxTid
<
1
)
{
return
;
}
cy
.
drush
(
'
sql:query "select tid from taxonomy_term_data where tid>
'
+
maxTid
+
'
"
'
).
then
((
result
)
=>
{
let
tids
=
result
.
stdout
.
split
(
"
\n
"
).
join
(
'
,
'
);
if
(
tids
)
{
cy
.
drush
(
'
edel taxonomy_term
'
+
tids
);
}
});
})
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