chore: cypress screenshots

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
This commit is contained in:
Raju Udava
2022-02-17 10:28:36 +05:30
parent 010138dec6
commit 897c861986
29 changed files with 2290 additions and 1992 deletions

View File

@@ -4,8 +4,8 @@
import { projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage";
import {
roles,
isTestSuiteActive,
roles,
isTestSuiteActive,
} from "../../support/page_objects/projectConstants";
// stores sheet names (table name)
@@ -21,29 +21,29 @@ let filepath = `sampleFiles/simple.xlsx`;
// let UrlFilePath = `sampleFiles/Financial Sample.xlsx`
let expectedData = {
0: ["number", "Number"],
1: ["float", "Decimal"],
2: ["text", "SingleLineText"],
0: ["number", "Number"],
1: ["float", "Decimal"],
2: ["text", "SingleLineText"],
};
// column names with spaces will be converted to include _
let UrlFileExpectedData = {
0: ["Segment", "SingleSelect", ["Government"]],
1: ["Country", "SingleSelect", ["Canada"]],
2: ["Product", "SingleSelect", ["Carretera"]],
3: ["Discount_Band", "SingleSelect", ["None"]],
4: ["Units_Sold", "Decimal", [1618.5]],
5: ["Manufacturing_Price", "Number", [3]],
6: ["Sale_Price", "Number", [20]],
7: ["Gross_Sales", "Decimal", [32370]],
8: ["Discounts", "Decimal", [0]],
9: ["Sales", "Decimal", [32370]],
10: ["COGS", "Decimal", [16185]],
11: ["Profit", "Decimal", [16185]],
12: ["Date", "Date", ["2014-01-01"]],
13: ["Month_Number", "Number", [1]],
14: ["Month_Name", "SingleSelect", ["January"]],
15: ["Year", "SingleSelect", [2014]],
0: ["Segment", "SingleSelect", ["Government"]],
1: ["Country", "SingleSelect", ["Canada"]],
2: ["Product", "SingleSelect", ["Carretera"]],
3: ["Discount_Band", "SingleSelect", ["None"]],
4: ["Units_Sold", "Decimal", [1618.5]],
5: ["Manufacturing_Price", "Number", [3]],
6: ["Sale_Price", "Number", [20]],
7: ["Gross_Sales", "Decimal", [32370]],
8: ["Discounts", "Decimal", [0]],
9: ["Sales", "Decimal", [32370]],
10: ["COGS", "Decimal", [16185]],
11: ["Profit", "Decimal", [16185]],
12: ["Date", "Date", ["2014-01-01"]],
13: ["Month_Number", "Number", [1]],
14: ["Month_Name", "SingleSelect", ["January"]],
15: ["Year", "SingleSelect", [2014]],
};
// let filepath = `sampleFiles/sample.xlsx`
@@ -64,259 +64,281 @@ let UrlFileExpectedData = {
// }
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Import from excel`, () => {
before(() => {
cy.task("readSheetList", {
file: `./scripts/cypress/fixtures/${filepath}`,
}).then((rows) => {
cy.log(rows);
sheetList = rows;
});
cy.task("readXlsx", {
file: `./scripts/cypress/fixtures/${filepath}`,
sheet: "Sheet2",
}).then((rows) => {
cy.log(rows);
sheetData = rows;
});
// cy.task('readXlsx', { file: `./scripts/cypress/fixtures/${UrlFilePath}`, sheet: "Sheet1" })
// .then((rows) => {
// cy.log(rows)
// UrlSheetData = rows
// })
});
it("File Upload: Upload excel as template", () => {
mainPage.toolBarTopLeft(mainPage.HOME).click();
// click on "New Project"
cy.get(":nth-child(5) > .v-btn", { timeout: 20000 }).click();
// Subsequent form, select (+ Create) option
cy.get(".nc-create-project-from-excel", { timeout: 20000 }).click({
force: true,
});
cy.get(".nc-excel-import-input").attachFile(filepath);
cy.get(".nc-btn-use-template", { timeout: 120000 }).should("exist");
});
it("File Upload: Verify pre-load template page", () => {
cy.getActiveContentModal()
.find(".v-expansion-panel")
.then((sheets) => {
for (let i = 0; i < sheets.length; i++) {
// verify if all sheet names are correct
// cy.wrap(sheets[i]).find('.title').then((blk) => {
// cy.log(blk.text().trim())
// expect(blk.text().trim()).to.equal(sheetList[i])
// })
cy.wrap(sheets[i]).contains(sheetList[i]).should("exist");
// for each sheet, expand to verify table names & their data types
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
// wait for 4 DOM rows to become visible, corresponding to 4 column names in excel
// change to avoid static wait
cy.get(".v-data-table").find("tr:visible").should("have.length", 4);
cy.get(".v-data-table")
.find("tr:visible")
.then((row) => {
for (let j = 1; j < row.length; j++) {
// column name to match input in excel
cy.wrap(row[j])
.find('[placeholder="Column name"]')
.then((obj) => {
cy.log(obj[0].value);
expect(obj[0].value).to.equal(expectedData[j - 1][0]);
});
// datatype to match expected output
cy.wrap(row[j])
.find("span.caption")
.then((obj) => {
cy.log(obj[0].innerText);
expect(obj[0].innerText).to.equal(expectedData[j - 1][1]);
});
}
});
// unwind
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
}
});
});
it("File Upload: Verify loaded data", () => {
// create rest/ gql project
cy.get(".nc-btn-use-template", { timeout: 120000 }).click();
// if (type == 'rest') {
// cy.getActiveMenu().find('[role="menuitem"]').contains('REST').click()
// } else {
// cy.getActiveMenu().find('[role="menuitem"]').contains('GQL').click()
// }
// wait for loading to be completed
projectsPage.waitHomePageLoad();
// open sheet & validate contents
// sheetData contains data read from excel in format
// 0: { float: 1.1, number: 1, text: "abc" }
// 1: { float: 1.2, number: 0, text: "def" }
cy.openTableTab("Sheet2", 2);
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[0], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[0], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet2");
cy.openTableTab("Sheet3", 2);
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[0], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[0], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet3");
// delete project once all operations are completed
mainPage.toolBarTopLeft(mainPage.HOME).click();
cy.get(`.nc-${apiType}-project-row .mdi-delete-circle-outline`, {
timeout: 10000,
})
.should("exist")
.last()
.invoke("show")
.click();
cy.contains("Submit").closest("button").click();
});
it("URL: Upload excel as template", () => {
// click on "New Project"
cy.get(":nth-child(5) > .v-btn", { timeout: 20000 }).click();
// Subsequent form, select (+ Create) option
cy.get(".nc-create-project-from-excel", { timeout: 20000 }).click({
force: true,
});
cy.getActiveModal().find(".caption").contains("URL").click();
cy.get(".nc-excel-import-tab-item")
.find('input[type="url"]')
.click()
.type(URL);
cy.get(".nc-excel-import-tab-item")
.find("button")
.contains("Load")
.click();
cy.get(".nc-btn-use-template", { timeout: 120000 }).should("exist");
});
it("URL: Verify pre-load template page", () => {
cy.getActiveContentModal()
.find(".v-expansion-panel")
.then((sheets) => {
for (let i = 0; i < sheets.length; i++) {
// verify if all sheet names are correct
// cy.wrap(sheets[i]).find('.title').then((blk) => {
// cy.log(blk.text().trim())
// expect(blk.text().trim()).to.equal('Sheet1')
// })
cy.wrap(sheets[i]).contains("Sheet1").should("exist");
// for each sheet, expand to verify table names & their data types
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
cy.wait(3000).then(() => {
cy.get(".v-data-table")
.find("tr:visible")
.then((row) => {
// verification restricting to 10, as others need to be scrolled back into view
for (let j = 1; j <= 10 /*row.length*/; j++) {
// column name to match input in excel
cy.wrap(row[j])
.find('[placeholder="Column name"]')
.then((obj) => {
cy.log(obj[0].value);
expect(obj[0].value).to.equal(
UrlFileExpectedData[j - 1][0]
);
});
// datatype to match expected output
cy.wrap(row[j])
.find("span.caption")
.then((obj) => {
cy.log(obj[0].innerText);
expect(obj[0].innerText).to.equal(
UrlFileExpectedData[j - 1][1]
);
});
}
});
describe(`Import from excel`, () => {
before(() => {
cy.task("readSheetList", {
file: `./scripts/cypress/fixtures/${filepath}`,
}).then((rows) => {
cy.log(rows);
sheetList = rows;
});
// unwind
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
}
cy.task("readXlsx", {
file: `./scripts/cypress/fixtures/${filepath}`,
sheet: "Sheet2",
}).then((rows) => {
cy.log(rows);
sheetData = rows;
});
// cy.task('readXlsx', { file: `./scripts/cypress/fixtures/${UrlFilePath}`, sheet: "Sheet1" })
// .then((rows) => {
// cy.log(rows)
// UrlSheetData = rows
// })
});
it("File Upload: Upload excel as template", () => {
mainPage.toolBarTopLeft(mainPage.HOME).click();
// click on "New Project"
cy.get(":nth-child(5) > .v-btn", { timeout: 20000 }).click();
// Subsequent form, select (+ Create) option
cy.get(".nc-create-project-from-excel", { timeout: 20000 }).click({
force: true,
});
cy.snipActiveModal("Modal_CreateFromExcel");
cy.get(".nc-excel-import-input").attachFile(filepath);
cy.get(".nc-btn-use-template", { timeout: 120000 }).should("exist");
});
it("File Upload: Verify pre-load template page", () => {
cy.snip("ExcelImport");
cy.getActiveContentModal()
.find(".v-expansion-panel")
.then((sheets) => {
for (let i = 0; i < sheets.length; i++) {
// verify if all sheet names are correct
// cy.wrap(sheets[i]).find('.title').then((blk) => {
// cy.log(blk.text().trim())
// expect(blk.text().trim()).to.equal(sheetList[i])
// })
cy.wrap(sheets[i])
.contains(sheetList[i])
.should("exist");
// for each sheet, expand to verify table names & their data types
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
// wait for 4 DOM rows to become visible, corresponding to 4 column names in excel
// change to avoid static wait
cy.get(".v-data-table")
.find("tr:visible")
.should("have.length", 4);
cy.get(".v-data-table")
.find("tr:visible")
.then((row) => {
for (let j = 1; j < row.length; j++) {
// column name to match input in excel
cy.wrap(row[j])
.find('[placeholder="Column name"]')
.then((obj) => {
cy.log(obj[0].value);
expect(obj[0].value).to.equal(
expectedData[j - 1][0]
);
});
// datatype to match expected output
cy.wrap(row[j])
.find("span.caption")
.then((obj) => {
cy.log(obj[0].innerText);
expect(obj[0].innerText).to.equal(
expectedData[j - 1][1]
);
});
}
});
// unwind
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
}
});
});
it("File Upload: Verify loaded data", () => {
// create rest/ gql project
cy.get(".nc-btn-use-template", { timeout: 120000 }).click();
// if (type == 'rest') {
// cy.getActiveMenu().find('[role="menuitem"]').contains('REST').click()
// } else {
// cy.getActiveMenu().find('[role="menuitem"]').contains('GQL').click()
// }
// wait for loading to be completed
projectsPage.waitHomePageLoad();
// open sheet & validate contents
// sheetData contains data read from excel in format
// 0: { float: 1.1, number: 1, text: "abc" }
// 1: { float: 1.2, number: 0, text: "def" }
cy.openTableTab("Sheet2", 2);
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[0], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[0], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet2");
cy.openTableTab("Sheet3", 2);
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[0], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[0], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet3");
// delete project once all operations are completed
mainPage.toolBarTopLeft(mainPage.HOME).click();
cy.get(`.nc-${apiType}-project-row .mdi-delete-circle-outline`, {
timeout: 10000,
})
.should("exist")
.last()
.invoke("show")
.click();
cy.contains("Submit").closest("button").click();
});
it("URL: Upload excel as template", () => {
// click on "New Project"
cy.get(":nth-child(5) > .v-btn", { timeout: 20000 }).click();
// Subsequent form, select (+ Create) option
cy.get(".nc-create-project-from-excel", { timeout: 20000 }).click({
force: true,
});
cy.snipActiveModal("Modal_ImportExcelURL");
cy.getActiveModal().find(".caption").contains("URL").click();
cy.get(".nc-excel-import-tab-item")
.find('input[type="url"]')
.click()
.type(URL);
cy.get(".nc-excel-import-tab-item")
.find("button")
.contains("Load")
.click();
cy.get(".nc-btn-use-template", { timeout: 120000 }).should("exist");
});
it("URL: Verify pre-load template page", () => {
cy.getActiveContentModal()
.find(".v-expansion-panel")
.then((sheets) => {
for (let i = 0; i < sheets.length; i++) {
// verify if all sheet names are correct
// cy.wrap(sheets[i]).find('.title').then((blk) => {
// cy.log(blk.text().trim())
// expect(blk.text().trim()).to.equal('Sheet1')
// })
cy.wrap(sheets[i]).contains("Sheet1").should("exist");
// for each sheet, expand to verify table names & their data types
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
cy.wait(3000).then(() => {
cy.get(".v-data-table")
.find("tr:visible")
.then((row) => {
// verification restricting to 10, as others need to be scrolled back into view
for (
let j = 1;
j <= 10 /*row.length*/;
j++
) {
// column name to match input in excel
cy.wrap(row[j])
.find('[placeholder="Column name"]')
.then((obj) => {
cy.log(obj[0].value);
expect(obj[0].value).to.equal(
UrlFileExpectedData[
j - 1
][0]
);
});
// datatype to match expected output
cy.wrap(row[j])
.find("span.caption")
.then((obj) => {
cy.log(obj[0].innerText);
expect(
obj[0].innerText
).to.equal(
UrlFileExpectedData[
j - 1
][1]
);
});
}
});
});
// unwind
cy.wrap(sheets[i]).find(".mdi-chevron-down").click();
}
});
});
it("URL: Verify loaded data", () => {
// create rest/ gql project
cy.get(".nc-btn-use-template", { timeout: 120000 }).click();
// wait for loading to be completed
projectsPage.waitHomePageLoad();
// open sheet & validate contents
// sheetData contains data read from excel in format
// 0: { float: 1.1, number: 1, text: "abc" }
// 1: { float: 1.2, number: 0, text: "def" }
cy.openTableTab("Sheet1", 25);
let idx = 0;
for (const [key, value] of Object.entries(UrlFileExpectedData)) {
if (UrlFileExpectedData[idx][1] != "Date")
mainPage
.getCell(value[0], 1)
.contains(UrlFileExpectedData[idx++][2][0])
.should("exist");
}
cy.closeTableTab("Sheet1");
});
after(() => {
// delete project once all operations are completed
mainPage.toolBarTopLeft(mainPage.HOME).click();
cy.get(`.nc-${apiType}-project-row .mdi-delete-circle-outline`, {
timeout: 10000,
})
.should("exist")
.last()
.invoke("show")
.click();
cy.contains("Submit").closest("button").click();
});
});
it("URL: Verify loaded data", () => {
// create rest/ gql project
cy.get(".nc-btn-use-template", { timeout: 120000 }).click();
// wait for loading to be completed
projectsPage.waitHomePageLoad();
// open sheet & validate contents
// sheetData contains data read from excel in format
// 0: { float: 1.1, number: 1, text: "abc" }
// 1: { float: 1.2, number: 0, text: "def" }
cy.openTableTab("Sheet1", 25);
let idx = 0;
for (const [key, value] of Object.entries(UrlFileExpectedData)) {
if (UrlFileExpectedData[idx][1] != "Date")
mainPage
.getCell(value[0], 1)
.contains(UrlFileExpectedData[idx++][2][0])
.should("exist");
}
cy.closeTableTab("Sheet1");
});
after(() => {
// delete project once all operations are completed
mainPage.toolBarTopLeft(mainPage.HOME).click();
cy.get(`.nc-${apiType}-project-row .mdi-delete-circle-outline`, {
timeout: 10000,
})
.should("exist")
.last()
.invoke("show")
.click();
cy.contains("Submit").closest("button").click();
});
});
};
// if (typeof require !== 'undefined') XLSX = require('xlsx');