system-testing 1.0.33 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,297 @@
1
+ export default class SystemTest {
2
+ static rootPath: string;
3
+ /**
4
+ * Gets the current system test instance
5
+ * @param {object} [args]
6
+ * @param {string} [args.host]
7
+ * @param {number} [args.port]
8
+ * @returns {SystemTest}
9
+ */
10
+ static current(args?: {
11
+ host?: string;
12
+ port?: number;
13
+ }): SystemTest;
14
+ /**
15
+ * Runs a system test
16
+ * @param {function(SystemTest): Promise<void>} callback
17
+ * @returns {Promise<void>}
18
+ */
19
+ static run(callback: (arg0: SystemTest) => Promise<void>): Promise<void>;
20
+ /**
21
+ * Creates a new SystemTest instance
22
+ * @param {object} [args]
23
+ * @param {string} [args.host]
24
+ * @param {number} [args.port]
25
+ */
26
+ constructor({ host, port, ...restArgs }?: {
27
+ host?: string;
28
+ port?: number;
29
+ });
30
+ /** @type {SystemTestCommunicator | undefined} */
31
+ communicator: SystemTestCommunicator | undefined;
32
+ /** @type {import("selenium-webdriver").WebDriver | undefined} */
33
+ driver: import("selenium-webdriver").WebDriver | undefined;
34
+ _started: boolean;
35
+ _driverTimeouts: number;
36
+ _timeouts: number;
37
+ getCommunicator(): SystemTestCommunicator;
38
+ _host: string;
39
+ _port: number;
40
+ /** @type {Record<number, object>} */
41
+ _responses: Record<number, object>;
42
+ _sendCount: number;
43
+ /**
44
+ * Gets the base selector for scoping element searches
45
+ * @returns {string | undefined}
46
+ */
47
+ getBaseSelector(): string | undefined;
48
+ /**
49
+ * @returns {import("selenium-webdriver").WebDriver}
50
+ */
51
+ getDriver(): import("selenium-webdriver").WebDriver;
52
+ /**
53
+ * Sets the base selector for scoping element searches
54
+ * @param {string} baseSelector
55
+ */
56
+ setBaseSelector(baseSelector: string): void;
57
+ _baseSelector: string;
58
+ /**
59
+ * Gets a selector scoped to the base selector
60
+ * @param {string} selector
61
+ * @returns {string}
62
+ */
63
+ getSelector(selector: string): string;
64
+ /**
65
+ * Starts Scoundrel server which the browser connects to for remote evaluation in the browser
66
+ * @returns {void}
67
+ */
68
+ startScoundrel(): void;
69
+ wss: import("ws").Server<typeof import("ws").default, typeof import("node:http").IncomingMessage>;
70
+ serverWebSocket: any;
71
+ server: any;
72
+ /**
73
+ * @returns {void}
74
+ */
75
+ stopScoundrel(): void;
76
+ /**
77
+ * Finds all elements by CSS selector
78
+ * @param {string} selector
79
+ * @param {object} args
80
+ * @param {number} [args.timeout]
81
+ * @param {boolean} [args.visible]
82
+ * @param {boolean} [args.useBaseSelector]
83
+ * @returns {Promise<import("selenium-webdriver").WebElement[]>}
84
+ */
85
+ all(selector: string, args?: {
86
+ timeout?: number;
87
+ visible?: boolean;
88
+ useBaseSelector?: boolean;
89
+ }): Promise<import("selenium-webdriver").WebElement[]>;
90
+ /**
91
+ * Clicks an element that has children which fills out the element and would otherwise have caused a ElementClickInterceptedError
92
+ * @param {string|import("selenium-webdriver").WebElement} elementOrIdentifier
93
+ * @returns {Promise<void>}
94
+ */
95
+ click(elementOrIdentifier: string | import("selenium-webdriver").WebElement): Promise<void>;
96
+ /**
97
+ * Finds a single element by CSS selector
98
+ * @param {string} selector
99
+ * @param {object} args
100
+ * @returns {Promise<import("selenium-webdriver").WebElement>}
101
+ */
102
+ find(selector: string, args?: object): Promise<import("selenium-webdriver").WebElement>;
103
+ /**
104
+ * Finds a single element by test ID
105
+ * @param {string} testID
106
+ * @param {object} args
107
+ * @returns {Promise<import("selenium-webdriver").WebElement>}
108
+ */
109
+ findByTestID(testID: string, args: object): Promise<import("selenium-webdriver").WebElement>;
110
+ /**
111
+ * @param {string|import("selenium-webdriver").WebElement} elementOrIdentifier
112
+ * @returns {Promise<import("selenium-webdriver").WebElement>}
113
+ */
114
+ _findElement(elementOrIdentifier: string | import("selenium-webdriver").WebElement): Promise<import("selenium-webdriver").WebElement>;
115
+ /**
116
+ * Finds a single element by CSS selector without waiting
117
+ * @param {string} selector
118
+ * @param {object} [args]
119
+ * @returns {Promise<import("selenium-webdriver").WebElement>}
120
+ */
121
+ findNoWait(selector: string, args?: object): Promise<import("selenium-webdriver").WebElement>;
122
+ /**
123
+ * Gets browser logs
124
+ * @returns {Promise<string[]>}
125
+ */
126
+ getBrowserLogs(): Promise<string[]>;
127
+ /**
128
+ * @returns {Promise<string>}
129
+ */
130
+ getCurrentUrl(): Promise<string>;
131
+ /**
132
+ * @returns {number}
133
+ */
134
+ getTimeouts(): number;
135
+ /**
136
+ * Interacts with an element by calling a method on it with the given arguments.
137
+ * Retrying on ElementNotInteractableError.
138
+ * @param {import("selenium-webdriver").WebElement|string} elementOrIdentifier - The element or a CSS selector to find the element.
139
+ * @param {string} methodName - The method name to call on the element.
140
+ * @param {...any} args - Arguments to pass to the method.
141
+ * @returns {Promise<any>}
142
+ */
143
+ interact(elementOrIdentifier: import("selenium-webdriver").WebElement | string, methodName: string, ...args: any[]): Promise<any>;
144
+ /**
145
+ * Expects no element to be found by CSS selector
146
+ * @param {string} selector
147
+ * @returns {Promise<void>}
148
+ */
149
+ expectNoElement(selector: string): Promise<void>;
150
+ /**
151
+ * @param {string} selector
152
+ * @param {object} args
153
+ * @param {boolean} [args.useBaseSelector]
154
+ * @returns {Promise<void>}
155
+ */
156
+ waitForNoSelector(selector: string, args: {
157
+ useBaseSelector?: boolean;
158
+ }): Promise<void>;
159
+ /**
160
+ * Gets notification messages
161
+ * @returns {Promise<string[]>}
162
+ */
163
+ notificationMessages(): Promise<string[]>;
164
+ /**
165
+ * Expects a notification message to appear and waits for it if necessary.
166
+ * @param {string} expectedNotificationMessage
167
+ * @returns {Promise<void>}
168
+ */
169
+ expectNotificationMessage(expectedNotificationMessage: string): Promise<void>;
170
+ /**
171
+ * @returns {Promise<void>}
172
+ */
173
+ dismissNotificationMessages(): Promise<void>;
174
+ /**
175
+ * Indicates whether the system test has been started
176
+ * @returns {boolean}
177
+ */
178
+ isStarted(): boolean;
179
+ /**
180
+ * Gets the HTML of the current page
181
+ * @returns {Promise<string>}
182
+ */
183
+ getHTML(): Promise<string>;
184
+ /**
185
+ * Starts the system test
186
+ * @returns {Promise<void>}
187
+ */
188
+ start(): Promise<void>;
189
+ currentUrl: string;
190
+ systemTestHttpServer: SystemTestHttpServer;
191
+ /**
192
+ * Restores previously set timeouts
193
+ * @returns {Promise<void>}
194
+ */
195
+ restoreTimeouts(): Promise<void>;
196
+ /**
197
+ * Sets driver timeouts
198
+ * @param {number} newTimeout
199
+ * @returns {Promise<void>}
200
+ */
201
+ driverSetTimeouts(newTimeout: number): Promise<void>;
202
+ /**
203
+ * Sets timeouts and stores the previous timeouts
204
+ * @param {number} newTimeout
205
+ * @returns {Promise<void>}
206
+ */
207
+ setTimeouts(newTimeout: number): Promise<void>;
208
+ /**
209
+ * Waits for the client web socket to connect
210
+ * @returns {Promise<void>}
211
+ */
212
+ waitForClientWebSocket(): Promise<void>;
213
+ waitForClientWebSocketPromiseResolve: (value: void | PromiseLike<void>) => void;
214
+ /**
215
+ * Starts the web socket server
216
+ * @returns {void}
217
+ */
218
+ startWebSocketServer(): void;
219
+ /**
220
+ * Sets the on command callback
221
+ * @param {function({type: string, data: Record<string, any>}): Promise<void>} callback
222
+ * @returns {void}
223
+ */
224
+ onCommand(callback: (arg0: {
225
+ type: string;
226
+ data: Record<string, any>;
227
+ }) => Promise<void>): void;
228
+ _onCommandCallback: (arg0: {
229
+ type: string;
230
+ data: Record<string, any>;
231
+ }) => Promise<void>;
232
+ /**
233
+ * Handles a command received from the browser
234
+ * @param {{data: {message: string, backtrace: string, type: string, value: any[]}}} args
235
+ * @returns {Promise<any>}
236
+ */
237
+ onCommandReceived: ({ data }: {
238
+ data: {
239
+ message: string;
240
+ backtrace: string;
241
+ type: string;
242
+ value: any[];
243
+ };
244
+ }) => Promise<any>;
245
+ /**
246
+ * Handles a new web socket connection
247
+ * @param {WebSocket} ws
248
+ * @returns {Promise<void>}
249
+ */
250
+ onWebSocketConnection: (ws: WebSocket) => Promise<void>;
251
+ ws: WebSocket;
252
+ /**
253
+ * @returns {void}
254
+ */
255
+ onWebSocketClose: () => void;
256
+ /**
257
+ * Handles an error reported from the browser
258
+ * @param {object} data
259
+ * @param {string} data.message
260
+ * @param {string} [data.backtrace]
261
+ * @returns {void}
262
+ */
263
+ handleError(data: {
264
+ message: string;
265
+ backtrace?: string;
266
+ }): void;
267
+ /**
268
+ * Stops the system test
269
+ * @returns {Promise<void>}
270
+ */
271
+ stop(): Promise<void>;
272
+ /**
273
+ * Visits a path in the browser
274
+ * @param {string} path
275
+ * @returns {Promise<void>}
276
+ */
277
+ driverVisit(path: string): Promise<void>;
278
+ /**
279
+ * Takes a screenshot, saves HTML and browser logs
280
+ * @returns {Promise<void>}
281
+ */
282
+ takeScreenshot(): Promise<void>;
283
+ /**
284
+ * Visits a path in the browser
285
+ * @param {string} path
286
+ * @returns {Promise<void>}
287
+ */
288
+ visit(path: string): Promise<void>;
289
+ /**
290
+ * Dismisses to a path in the browser
291
+ * @param {string} path
292
+ * @returns {Promise<void>}
293
+ */
294
+ dismissTo(path: string): Promise<void>;
295
+ }
296
+ import SystemTestCommunicator from "./system-test-communicator.js";
297
+ import SystemTestHttpServer from "./system-test-http-server.js";