forked from ueokande/vimmatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab.test.ts
179 lines (156 loc) · 4.91 KB
/
tab.test.ts
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import { test, expect } from "./lib/fixture";
import { newNopServer } from "./lib/servers";
const server = newNopServer();
let windowId: number;
test.beforeAll(async () => {
await server.start();
});
test.afterAll(async () => {
await server.stop();
});
test.beforeEach(async ({ api, page }) => {
windowId = (await api.windows.getCurrent()).id;
await setupTabs(api);
await page.goto(server.url("2"));
});
const setupTabs = async (api: typeof browser) => {
for (const i of [0, 1, 3, 4]) {
await api.tabs.create({
windowId,
url: server.url(`${i}`),
active: false,
index: i,
});
}
};
test("select tab", async ({ page, api }) => {
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: server.url("2") }]);
await page.keyboard.press("Shift+J");
await page.keyboard.press("Shift+J");
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: server.url("4") }]);
await page.keyboard.press("Shift+K");
await page.keyboard.press("Shift+K");
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: server.url("2") }]);
await page.keyboard.press("g");
await page.keyboard.press("0");
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: server.url("0"), active: true }]);
await page.keyboard.press("g");
await page.keyboard.press("$");
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: server.url("4"), active: true }]);
await page.keyboard.press("Control+6");
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: server.url("0"), active: true }]);
});
test("deletes tab and selects right by d", async ({ page, api }) => {
await page.keyboard.press("d");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("3"), active: true },
{ url: server.url("4") },
]);
});
test("deletes tab and selects left by D", async ({ page, api }) => {
await page.keyboard.press("Shift+D");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1"), active: true },
{ url: server.url("3") },
{ url: server.url("4") },
]);
});
test("deletes all tabs to the right by x$", async ({ page, api }) => {
await page.keyboard.press("x");
await page.keyboard.press("$");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("2"), active: true },
]);
});
test("duplicate and make pinned", async ({ page, api }) => {
await page.keyboard.type("zd");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("2") },
{ url: server.url("2") },
{ url: server.url("3") },
{ url: server.url("4") },
]);
await page.keyboard.type("zp");
await expect
.poll(() => api.tabs.query({ windowId, pinned: true }))
.toMatchObject([{ url: server.url("2") }]);
});
test("reopen tab by u", async ({ page, api }) => {
const tabs = await api.tabs.query({ windowId });
await api.tabs.remove(tabs[4].id);
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("2") },
{ url: server.url("3") },
]);
await page.keyboard.press("u");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("2") },
{ url: server.url("3") },
{ url: server.url("4") },
]);
});
test("delete a pinned tab", async ({ page, api }) => {
const tabs = await api.tabs.query({ windowId });
await api.tabs.update(tabs[2].id, { pinned: true });
await page.keyboard.press("d");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("2"), pinned: true, active: true },
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("3") },
{ url: server.url("4") },
]);
await page.keyboard.press("!");
await page.keyboard.press("d");
await expect
.poll(() => api.tabs.query({ windowId }))
.toMatchObject([
{ url: server.url("0") },
{ url: server.url("1") },
{ url: server.url("3") },
{ url: server.url("4") },
]);
});
test("opens view-source by gf", async ({ page, api }) => {
await page.keyboard.type("gf");
await expect
.poll(() => api.tabs.query({ windowId, active: true }))
.toMatchObject([{ url: "view-source:" + server.url("2") }]);
});