-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathchangeServer.test.ts
More file actions
132 lines (103 loc) · 4.67 KB
/
changeServer.test.ts
File metadata and controls
132 lines (103 loc) · 4.67 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import "detox";
import {
byWebCss,
byWebDataTestId,
tapAfterWaitFor,
tapWebAfterWaitFor,
waitForWebview,
} from "./helper";
import { expect } from "detox";
describe("Change Server", () => {
beforeEach(async () => {
await device.launchApp({
url: "evcc://server?url=localhost:7070&title=Local",
resetAppState: true,
});
});
it("one server: add and remove", async () => {
await element(by.id("serverFormCheckAndSave")).tap();
await waitForWebview();
await byWebDataTestId("tab-more").tap();
await byWebDataTestId("tab-more-app").tap();
await tapAfterWaitFor(element(by.id("editServer0Icon")));
await element(by.id("setingsScreenRemoveServer")).tap();
await expect(element(by.id("serverScreenTitle"))).toExist();
});
it("one server: change server url", async () => {
await element(by.id("serverFormCheckAndSave")).tap();
await waitForWebview();
await expect(byWebDataTestId("header")).toHaveText("");
await byWebDataTestId("tab-more").tap();
await byWebDataTestId("tab-more-app").tap();
await tapAfterWaitFor(element(by.id("editServer0Icon")));
const url = element(by.id("@serverFormUrl/input"));
await url.clearText();
await url.typeText("demo.evcc.io");
await element(by.id("serverFormCheckAndSave")).tap();
await tapAfterWaitFor(element(by.id("server0")));
await waitForWebview();
await expect(byWebCss("[data-testid=header] h1")).toHaveText("DEMO MODE");
});
it("two servers: add and switch", async () => {
await element(by.id("serverFormCheckAndSave")).tap();
await waitForWebview();
await expect(byWebDataTestId("header")).toHaveText("");
await byWebDataTestId("tab-more").tap();
await byWebDataTestId("tab-more-app").tap();
await element(by.id("addServerIcon")).tap();
await element(by.id("@serverFormTitle/input")).typeText("Demo");
await element(by.id("@serverFormUrl/input")).typeText("demo.evcc.io");
await element(by.id("serverFormAuth")).swipe("up");
await element(by.id("serverFormCheckAndSave")).tap();
await tapAfterWaitFor(element(by.id("server1")));
await waitForWebview();
await expect(byWebCss("[data-testid=header] h1")).toHaveText("DEMO MODE");
});
it("two servers: remove active server", async () => {
await element(by.id("serverFormCheckAndSave")).tap();
await waitForWebview();
await byWebDataTestId("tab-more").tap();
await byWebDataTestId("tab-more-app").tap();
await element(by.id("addServerIcon")).tap();
await element(by.id("@serverFormTitle/input")).typeText("Demo");
await element(by.id("@serverFormUrl/input")).typeText("demo.evcc.io");
await element(by.id("serverFormAuth")).swipe("up");
await element(by.id("serverFormCheckAndSave")).tap();
// remove active server (server0 = local); first remaining (demo) is auto-activated
await tapAfterWaitFor(element(by.id("editServer0Icon")));
await element(by.id("setingsScreenRemoveServer")).tap();
// close switch modal by tapping the now-only server, then verify demo is active
await tapAfterWaitFor(element(by.id("server0")));
await waitForWebview();
await expect(byWebCss("[data-testid=header] h1")).toHaveText("DEMO MODE");
});
it("three servers: use add button", async () => {
await element(by.id("serverFormCheckAndSave")).tap();
await waitForWebview();
await byWebDataTestId("tab-more").tap();
await byWebDataTestId("tab-more-app").tap();
// without basic auth
await element(by.id("addServerIcon")).tap();
await element(by.id("@serverFormTitle/input")).typeText("Demo");
await element(by.id("@serverFormUrl/input")).typeText("demo.evcc.io");
await element(by.id("serverFormAuth")).swipe("up");
await element(by.id("serverFormCheckAndSave")).tap();
await tapAfterWaitFor(element(by.id("server1")));
await waitForWebview();
await tapWebAfterWaitFor(byWebDataTestId("tab-more"));
await tapWebAfterWaitFor(byWebDataTestId("tab-more-app"));
// with basic auth
await element(by.id("addServerIcon")).tap();
await element(by.id("@serverFormTitle/input")).typeText("Local Auth");
await element(by.id("@serverFormUrl/input")).typeText("localhost:7080");
await element(by.id("serverFormAuth")).tap();
await element(by.id("serverFormAuth")).swipe("up");
await element(by.id("@serverFormAuthUser/input")).typeText("admin");
await element(by.id("@serverFormAuthPassword/input")).typeText("secret");
await element(by.id("serverFormCheckAndSave")).tap();
// verify the 3rd server was added; switching is covered in "two servers: add and switch"
await waitFor(element(by.id("server2")))
.toExist()
.withTimeout(20000);
});
});