-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathhelpers.js
73 lines (64 loc) · 1.54 KB
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { DESIGNER, extension, MESHMAP_PATH } from "./constants";
export function waitFor(str) {
return "@" + str;
}
export function id(str) {
return "#" + str;
}
const doInitialSetup = () => {
// cy.setViewPort();
cy.dpiAndResize(3, 1920, 1080);
cy.login();
cy.setReleaseTag();
cy.interceptCapabilities();
cy.setMode(DESIGNER);
};
export const beforeEachCallback = () => {
doInitialSetup();
cy.intercept(extension.path).as(extension.alias);
cy.visit(MESHMAP_PATH);
// cy.wait(waitFor(extension.alias), { timeout: 15000 });
};
export const setThemeMode = async (mode) => {
const window = await cy.window();
window.localStorage.setItem("theme", mode);
};
export const beforeEachCallbackForCustomUrl = (customPath, theme = "light") => {
cy.setThemeMode(theme);
doInitialSetup();
cy.intercept(extension.path).as(extension.alias);
cy.visit(customPath);
// cy.wait(waitFor(extension.alias), { timeout: 60_000 });
};
export const saveGraph = (cy) => {
let image = cy.png();
let lnk = document.createElement("a"),
date = new Date(),
e;
lnk.href = image;
lnk.download =
"MeshMap-" + date.toDateString() + "/" + date.toLocaleTimeString() + ".png";
if (document.createEvent) {
e = document.createEvent("MouseEvents");
e.initMouseEvent(
"click",
true,
true,
window,
0,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
lnk.dispatchEvent(e);
} else if (lnk.fireEvent) {
lnk.fireEvent("onclick");
}
};