Created
July 17, 2020 14:25
-
-
Save samlucax/8acb2cb08b16303705c5a250b9e181a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sugestão de solução enviada por Vinicius Flores no grupo do Cypress Brasil | |
describe('Should been possible to validate Update Catalog data in Agena plans table', () => { | |
before(() => { | |
cy.fixture('IIYOGI-1517.csv').then(plans => { | |
lines = plans.split('\n') | |
}) | |
}) | |
beforeEach(() => { | |
cy.getAuthZAuthorizationPie().then(responseToken => { | |
token = responseToken | |
}) | |
}) | |
it('Should been possible to compare csv with the response API', () => { | |
console.log(lines.length) | |
lines.map(line => { | |
column = line.split(';') | |
console.log('passou no map') | |
runCompareGetApiXGetCsvData(token, column) | |
}) | |
}) | |
}) | |
function getAgenaApiPlansData(token) { | |
console.log('start promisse') | |
return new Cypress.Promise(resolve => { | |
console.log('passou no agena api') | |
cy.request({ | |
method: 'GET', | |
url: `${agenaHost}/plans/${column[2]}`, | |
headers: { | |
Authorization: `bearer ${token}`, | |
Accept: 'application/vnd.agena+json;version=3', | |
'Content-Type': 'application/json', | |
}, | |
}) | |
.its('body') | |
.as('response') | |
resolve(cy.get('@response')) | |
}) | |
} | |
function runCompareGetApiXGetCsvData(token, column) { | |
console.log('esse é o promisse all') | |
return Cypress.Promise.all([getAgenaApiPlansData(token)]).spread(res => { | |
console.log('passou no then do request') | |
expect(res.name).eq(column[0]) | |
expect(res.region).eq(column[1]) | |
expect(JSON.stringify(res.catalogData)).eq(column[3]) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment