2020-11-13 14:27:27 -08:00
|
|
|
import "expect-puppeteer";
|
|
|
|
import { deleteNotebook, getNotebookNode, getTestExplorerFrame, uploadNotebook } from "./notebookTestUtils";
|
|
|
|
import * as path from "path";
|
2020-11-17 03:50:12 -08:00
|
|
|
import { ElementHandle, Frame } from "puppeteer";
|
2020-11-13 14:27:27 -08:00
|
|
|
|
|
|
|
jest.setTimeout(300000);
|
|
|
|
|
2020-11-17 03:50:12 -08:00
|
|
|
const notebookName = "GettingStarted.ipynb";
|
|
|
|
let frame: Frame;
|
|
|
|
let uploadedNotebookNode: ElementHandle<Element>;
|
|
|
|
|
2020-11-13 14:27:27 -08:00
|
|
|
describe("Notebook UI tests", () => {
|
2020-11-17 03:50:12 -08:00
|
|
|
it("Upload, Open and Delete Notebook", async () => {
|
|
|
|
try {
|
2020-11-18 12:28:17 -08:00
|
|
|
frame = await getTestExplorerFrame();
|
|
|
|
const uploadNotebookPath = path.join(__dirname, "testNotebooks", notebookName);
|
|
|
|
await uploadNotebook(frame, uploadNotebookPath);
|
|
|
|
uploadedNotebookNode = await getNotebookNode(frame, notebookName);
|
2020-11-18 12:31:21 -08:00
|
|
|
|
2020-11-13 14:30:30 -08:00
|
|
|
await uploadedNotebookNode.click();
|
|
|
|
await frame.waitForSelector(".tabNavText");
|
|
|
|
const tabTitle = await frame.$eval(".tabNavText", element => element.textContent);
|
2020-11-17 03:50:12 -08:00
|
|
|
expect(tabTitle).toEqual(notebookName);
|
2020-11-13 14:30:30 -08:00
|
|
|
const closeIcon = await frame.waitForSelector(".close-Icon");
|
|
|
|
await closeIcon.click();
|
2020-11-18 12:28:17 -08:00
|
|
|
|
|
|
|
await deleteNotebook(frame, uploadedNotebookNode);
|
|
|
|
const deletedNotebookNode = await getNotebookNode(frame, notebookName);
|
|
|
|
if (deletedNotebookNode) {
|
|
|
|
throw new Error(`Deletion of notebook ${notebookName} failed`);
|
|
|
|
}
|
2020-11-13 14:30:30 -08:00
|
|
|
} catch (error) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
const testName = (expect as any).getState().currentTestName;
|
|
|
|
await page.screenshot({ path: `Test Failed ${testName}.jpg` });
|
|
|
|
throw error;
|
|
|
|
}
|
2020-11-13 14:27:27 -08:00
|
|
|
});
|
|
|
|
});
|