106 lines
2.9 KiB
JavaScript
106 lines
2.9 KiB
JavaScript
describe(
|
|
"Importing an available job",
|
|
{
|
|
defaultCommandTimeout: 5000,
|
|
},
|
|
() => {
|
|
beforeEach(() => {
|
|
cy.visit("/manage/available");
|
|
|
|
cy.get("body").then(($body) => {
|
|
if ($body.text().includes("Login")) {
|
|
// Log in
|
|
cy.get('[data-cy="username"]').type("john@imex.dev");
|
|
cy.get('[data-cy="password"]').type("john123");
|
|
cy.get('[data-cy="sign-in-button"]').click();
|
|
}
|
|
});
|
|
|
|
cy.get('[data-cy="available-jobs-table"]')
|
|
.find("tr")
|
|
.should("not.have.class", "ant-table-placeholder");
|
|
});
|
|
|
|
it("creates a new owner record for the job", () => {
|
|
cy.get('[data-cy="add-job-as-new-button"]')
|
|
.filter(":enabled")
|
|
.first()
|
|
.click();
|
|
|
|
cy.get('[data-cy="new_owner_checkbox"]').should("be.checked");
|
|
|
|
cy.get(".ant-modal-content").find("button").contains("OK").click();
|
|
|
|
cy.get(".ant-notification-notice-message")
|
|
.contains("Job created successfully. Click to view.")
|
|
.click();
|
|
|
|
cy.url().should("include", "/manage/jobs");
|
|
});
|
|
|
|
it("imports a supplement for an existing job", () => {
|
|
cy.get('[data-cy="add-job-as-supplement"]')
|
|
.filter(":enabled")
|
|
.first()
|
|
.click();
|
|
|
|
cy.get('[data-cy="existing-jobs-table"]')
|
|
.find(".ant-table-tbody tr")
|
|
.should("not.have.class", "ant-table-placeholder")
|
|
.first()
|
|
.click();
|
|
|
|
cy.get('[data-cy="existing-jobs-ok-button"]')
|
|
.should("not.be", "disabled")
|
|
.click();
|
|
|
|
cy.get(".ant-notification-notice-message")
|
|
.contains("Job supplemented successfully.")
|
|
.click();
|
|
|
|
cy.url().should("include", "/manage/jobs");
|
|
});
|
|
|
|
it("imports a job with an existing owner", () => {
|
|
let hasOwner = false;
|
|
|
|
cy.get('[data-cy="add-job-as-new-button"]')
|
|
.filter(":enabled")
|
|
.each(($el) => {
|
|
cy.then(() => {
|
|
if (hasOwner) return false;
|
|
|
|
cy.wrap($el).click();
|
|
|
|
// check if table is not empty
|
|
cy.get('[data-cy="existing-owner-table"]', { timeout: 20000 })
|
|
.find(".ant-table-tbody tr")
|
|
.should("not.have.class", "ant-table-placeholder")
|
|
.then(($table) => {
|
|
if ($table.length === 0) {
|
|
cy.get('[data-cy="existing-owners-cancel-button"]').click();
|
|
}
|
|
|
|
cy.wrap($table).first().click();
|
|
|
|
cy.get('[data-cy="new_owner_checkbox"]').should(
|
|
"not.be",
|
|
"checked"
|
|
);
|
|
|
|
hasOwner = true;
|
|
});
|
|
});
|
|
});
|
|
|
|
cy.get('[data-cy="existing-owners-ok-button"]').click();
|
|
|
|
cy.get(".ant-notification-notice-message")
|
|
.contains("Job created successfully. Click to view.")
|
|
.click();
|
|
|
|
cy.url().should("include", "/manage/jobs");
|
|
});
|
|
}
|
|
);
|