test: kludge for stability

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
This commit is contained in:
Raju Udava
2022-10-29 19:31:52 +05:30
committed by Muhammed Mustafa
parent 074fd3222c
commit bc7d34ece4
2 changed files with 49 additions and 19 deletions

View File

@@ -18,6 +18,10 @@ export class ImportAirtablePage extends BasePage {
}
async import({ key, baseId }: { key: string; baseId: string }) {
// kludge: failing in headless mode
// additional time to allow the modal to render completely
await this.rootPage.waitForTimeout(1000);
await this.get().locator(`.nc-input-api-key >> input`).fill(key);
await this.get().locator(`.nc-input-shared-base`).fill(baseId);
await this.importButton.click();

View File

@@ -12,16 +12,27 @@ test.describe("Attachment column", () => {
dashboard = new DashboardPage(page, context.project);
});
test("Create and verify atttachent column, verify it in shared form,", async ({page, context}) => {
await dashboard.treeView.openTable({title: "Country"});
test("Create and verify atttachent column, verify it in shared form,", async ({
page,
context,
}) => {
await dashboard.treeView.openTable({ title: "Country" });
await dashboard.grid.column.create({
title: "testAttach",
type: "Attachment",
})
});
for (let i = 4; i <= 6; i++) {
const filepath = `${process.cwd()}/fixtures/sampleFiles/${i}.json`;
await dashboard.grid.cell.attachment.addFile({index: i, columnHeader: "testAttach", filePath: filepath});
await dashboard.grid.cell.attachment.verifyFile({index: i, columnHeader: "testAttach"});
await dashboard.grid.cell.attachment.addFile({
index: i,
columnHeader: "testAttach",
filePath: filepath,
});
await dashboard.grid.cell.attachment.verifyFile({
index: i,
columnHeader: "testAttach",
});
}
await dashboard.viewSidebar.createFormView({
@@ -30,35 +41,50 @@ test.describe("Attachment column", () => {
await dashboard.form.toolbar.clickShareView();
const sharedFormUrl = await dashboard.form.toolbar.shareView.getShareLink();
await dashboard.form.toolbar.shareView.close();
await dashboard.viewSidebar.openView({title: "Country"});
await dashboard.viewSidebar.openView({ title: "Country" });
// Verify attachment in shared form
const newPage = await context.newPage()
const newPage = await context.newPage();
await newPage.goto(sharedFormUrl);
const sharedForm = new SharedFormPage(newPage);
await sharedForm.cell.fillText({index: 0, columnHeader: "Country", text: "test"});
await sharedForm.cell.attachment.addFile({columnHeader: 'testAttach', filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`});
await sharedForm.cell.fillText({
index: 0,
columnHeader: "Country",
text: "test",
});
await sharedForm.cell.attachment.addFile({
columnHeader: "testAttach",
filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`,
});
await sharedForm.submit();
await sharedForm.verifySuccessMessage();
await newPage.close();
// Verify attachment in csv
await dashboard.grid.toolbar.clickFields()
await dashboard.grid.toolbar.fields.click({title: "LastUpdate"});
await dashboard.grid.toolbar.clickFields();
await dashboard.grid.toolbar.fields.click({ title: "LastUpdate" });
await dashboard.grid.toolbar.clickActions();
await dashboard.grid.toolbar.actions.click('Download');
// Headless mode observation- menu doesn't render in one go
// Download button appears before menu is fully rendered
await dashboard.rootPage.waitForTimeout(500);
await dashboard.grid.toolbar.actions.click("Download");
const csvFileData: string = await dashboard.downloadAndGetFile({
downloadUIAction: dashboard.grid.toolbar.actions.clickDownloadSubmenu('Download as CSV')
downloadUIAction:
dashboard.grid.toolbar.actions.clickDownloadSubmenu("Download as CSV"),
});
const csvArray = csvFileData.split('\r\n');
const csvArray = csvFileData.split("\r\n");
const columns = csvArray[0];
const rows = csvArray.slice(1);
const cells = rows[4].split(',');
const cells = rows[4].split(",");
await expect(columns).toBe('Country,City List,testAttach');
await expect(cells[0]).toBe('Anguilla');
await expect(cells[1]).toBe('South Hill');
await expect(cells[2].includes('4.json(http://localhost:8080/download/')).toBe(true);
await expect(columns).toBe("Country,City List,testAttach");
await expect(cells[0]).toBe("Anguilla");
await expect(cells[1]).toBe("South Hill");
await expect(
cells[2].includes("4.json(http://localhost:8080/download/")
).toBe(true);
});
});