Skip to content
Snippets Groups Projects
Commit d920a9bc authored by jurgenhaas's avatar jurgenhaas
Browse files

Delete taxonomy terms that have been created during testing when the user gets deleted as well

parent a3234ecc
No related branches found
No related tags found
No related merge requests found
Pipeline #699202 passed
......@@ -13,6 +13,7 @@ Cypress.Commands.add('login', (options) => {
})
Cypress.Commands.add('createAndLogin', (username, role) => {
cy.rememberLatestTaxonomyTerm();
let password = 'random-password-' + Cypress._.random(0, 1e6);
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);
}
});
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment