Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Cypress.Commands.add('dynamicUserPrepare', () => {
- let $fixture
- const testAccountsArray = userList
- var account = {}
- var email = []
- do {
- var uuid = () => Cypress._.random(10, 1e4)
- var id = uuid()
- var testname = `auto${id}@testing.graviontech.com`
- console.log(testname+' is in account list? - '+testAccountsArray.includes(testname))
- window.emailHandler = testname
- } while (testAccountsArray.includes(testname) === true)
- console.log('E-mail: '+testname)
- console.log('Accounts test list: '+testAccountsArray)
- email.push(window.emailHandler)
- account.id = testAccountsArray.length
- account.email = email[0]
- cy.log('Test run ID: '+account.id)
- window.runID = account.id
- testAccountsArray.push({...account})
- cy.writeFile("cypress/fixtures/parallel/accountsList.json", (testAccountsArray))
- console.log(testAccountsArray)
- cy.checkRegEmail() //Сhecks if the email is registered and completely clears the test account
- function fixturePrepare() { //Fixture list
- switch (true) {
- case fxPrepare == 'recoveruser':
- $fixture = recoveruser
- window.fxConfirm = 'recoveruser'
- break
- case fxPrepare == 'createaccountuser':
- $fixture = createaccountuser
- window.fxConfirm = 'createaccountuser'
- break
- case fxPrepare == 'deleteaccountuser':
- $fixture = deleteaccountuser
- window.fxConfirm = 'deleteaccountuser'
- break
- case fxPrepare == 'accountusers':
- $fixture = accountusers
- window.fxConfirm = 'accountusers'
- break
- case fxPrepare == 'mainuser':
- $fixture = mainuser
- window.fxConfirm = 'mainuser'
- break
- default:
- cy.log('Cannot prepare fixture')
- console.log(window.fxPrepare)
- break
- }
- }
- fixturePrepare()
- cy.log('fx ' + fxConfirm + ' is ready')
- cy.request({
- method: "POST",
- url: Cypress.env('api_register'),
- json: true,
- headers: {
- 'Content-Type': 'application/json'
- },
- body: {
- "email": window.emailHandler,
- "password": $fixture.password,
- "name": $fixture.username,
- "personalDataPermission": true
- }
- })
- cy.emailConfirm()//Confirm registration
- cy.log(JSON.stringify(userList[runID].email + ' has been created'))
- cy.getGQLUrl()//Takes the actual URL for api
- cy.getAccessToken()//Assigns an access token for logging into an account at global level
- })
Add Comment
Please, Sign In to add comment