92 lines
2.6 KiB
JavaScript
92 lines
2.6 KiB
JavaScript
// ***********************************************************
|
|
// This example support/index.js is processed and
|
|
// loaded automatically before your test files.
|
|
//
|
|
// This is a great place to put global configuration and
|
|
// behavior that modifies Cypress.
|
|
//
|
|
// You can change the location of this file or turn off
|
|
// automatically serving support files with the
|
|
// 'supportFile' configuration option.
|
|
//
|
|
// You can read more here:
|
|
// https://on.cypress.io/configuration
|
|
// ***********************************************************
|
|
|
|
// Import commands.js using ES2015 syntax:
|
|
import "./commands";
|
|
|
|
// Alternatively you can use CommonJS syntax:
|
|
// require('./commands')
|
|
|
|
//unique test run ID for all tests
|
|
Cypress.config("cyid", `cy${new Date().getTime()}`);
|
|
///////////////////////////////////////////////////////////////
|
|
//Generate fresh data
|
|
//
|
|
//
|
|
// //via UI
|
|
// // before(() => {
|
|
// // cy.visit("/login");
|
|
|
|
// // cy.get("input[name=username]").clear().type(Cypress.env("adminusername"));
|
|
|
|
// // // {enter} causes the form to submit
|
|
// // cy.get("input[name=password]")
|
|
// // .clear()
|
|
// // .type(`${Cypress.env("adminpassword")}{enter}`);
|
|
// // cy.url().should("include", "/ay-evaluate");
|
|
|
|
// // cy.get("[data-cy=btnSeed]").click();
|
|
// // cy.get("[data-cy=btnStart]").click();
|
|
// // cy.get('[data-cy="gzconfirm:yesbutton"]').click();
|
|
// // //cy.contains("permanently erase");
|
|
// // cy.get('[data-cy="gzconfirm:yesbutton"]').click();
|
|
// // //long delay here while data is being generated
|
|
// // cy.url({ timeout: 300000 }).should("include", "/login");
|
|
// // });
|
|
//via API
|
|
function confirmJobDone(jobId, authToken) {
|
|
cy.request({
|
|
method: "GET",
|
|
url: `${Cypress.env("apiBaseUrl")}job-operations/status/${jobId}`,
|
|
auth: {
|
|
bearer: authToken
|
|
}
|
|
}).then((resp) => {
|
|
//3 means job done
|
|
if (resp.body.data == 3) return;
|
|
// else recurse
|
|
cy.wait(1000);
|
|
confirmJobDone(jobId, authToken);
|
|
});
|
|
}
|
|
|
|
|
|
before(() => {
|
|
cy.request({
|
|
url: `${Cypress.env("apiBaseUrl")}auth`,
|
|
method: "POST",
|
|
body: {
|
|
login: Cypress.env("adminusername"),
|
|
password: Cypress.env("adminpassword")
|
|
}
|
|
})
|
|
.its("body")
|
|
.then((res) => {
|
|
cy.request({
|
|
method: "POST",
|
|
url: `${Cypress.env("apiBaseUrl")}trial/seed/small/-7/true`,
|
|
auth: {
|
|
bearer: res.data.token
|
|
}
|
|
})
|
|
.its("body")
|
|
.then((resjob) => {
|
|
cy.log(`resjob is: ${resjob}`);
|
|
// expect(resjob.body).to.have.property('jobId');
|
|
confirmJobDone(resjob.jobId, res.data.token);
|
|
});
|
|
});
|
|
});
|