@chrryai/waffles 1.1.78

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.
package/dist/index.js ADDED
@@ -0,0 +1,1764 @@
1
+ 'use strict';
2
+
3
+ var test = require('@playwright/test');
4
+ var path = require('path');
5
+ var process2 = require('process');
6
+ var faker = require('@faker-js/faker');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var path__default = /*#__PURE__*/_interopDefault(path);
11
+ var process2__default = /*#__PURE__*/_interopDefault(process2);
12
+
13
+ var __create = Object.create;
14
+ var __defProp = Object.defineProperty;
15
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
+ var __getOwnPropNames = Object.getOwnPropertyNames;
17
+ var __getProtoOf = Object.getPrototypeOf;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
20
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
21
+ }) : x)(function(x) {
22
+ if (typeof require !== "undefined") return require.apply(this, arguments);
23
+ throw Error('Dynamic require of "' + x + '" is not supported');
24
+ });
25
+ var __commonJS = (cb, mod) => function __require2() {
26
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ // If the importer is in node compatibility mode or this is not an ESM
38
+ // file that has been converted to a CommonJS file using a Babel-
39
+ // compatible transform (i.e. "__esModule" has not been set), then set
40
+ // "default" to the CommonJS "module.exports" for node compatibility.
41
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
+ mod
43
+ ));
44
+
45
+ // ../../node_modules/dotenv/package.json
46
+ var require_package = __commonJS({
47
+ "../../node_modules/dotenv/package.json"(exports, module) {
48
+ module.exports = {
49
+ name: "dotenv",
50
+ version: "16.0.3",
51
+ description: "Loads environment variables from .env file",
52
+ main: "lib/main.js",
53
+ types: "lib/main.d.ts",
54
+ exports: {
55
+ ".": {
56
+ require: "./lib/main.js",
57
+ types: "./lib/main.d.ts",
58
+ default: "./lib/main.js"
59
+ },
60
+ "./config": "./config.js",
61
+ "./config.js": "./config.js",
62
+ "./lib/env-options": "./lib/env-options.js",
63
+ "./lib/env-options.js": "./lib/env-options.js",
64
+ "./lib/cli-options": "./lib/cli-options.js",
65
+ "./lib/cli-options.js": "./lib/cli-options.js",
66
+ "./package.json": "./package.json"
67
+ },
68
+ scripts: {
69
+ "dts-check": "tsc --project tests/types/tsconfig.json",
70
+ lint: "standard",
71
+ "lint-readme": "standard-markdown",
72
+ pretest: "npm run lint && npm run dts-check",
73
+ test: "tap tests/*.js --100 -Rspec",
74
+ prerelease: "npm test",
75
+ release: "standard-version"
76
+ },
77
+ repository: {
78
+ type: "git",
79
+ url: "git://github.com/motdotla/dotenv.git"
80
+ },
81
+ keywords: [
82
+ "dotenv",
83
+ "env",
84
+ ".env",
85
+ "environment",
86
+ "variables",
87
+ "config",
88
+ "settings"
89
+ ],
90
+ readmeFilename: "README.md",
91
+ license: "BSD-2-Clause",
92
+ devDependencies: {
93
+ "@types/node": "^17.0.9",
94
+ decache: "^4.6.1",
95
+ dtslint: "^3.7.0",
96
+ sinon: "^12.0.1",
97
+ standard: "^16.0.4",
98
+ "standard-markdown": "^7.1.0",
99
+ "standard-version": "^9.3.2",
100
+ tap: "^15.1.6",
101
+ tar: "^6.1.11",
102
+ typescript: "^4.5.4"
103
+ },
104
+ engines: {
105
+ node: ">=12"
106
+ }
107
+ };
108
+ }
109
+ });
110
+
111
+ // ../../node_modules/dotenv/lib/main.js
112
+ var require_main = __commonJS({
113
+ "../../node_modules/dotenv/lib/main.js"(exports, module) {
114
+ var fs = __require("fs");
115
+ var path2 = __require("path");
116
+ var os = __require("os");
117
+ var packageJson = require_package();
118
+ var version = packageJson.version;
119
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
120
+ function parse(src) {
121
+ const obj = {};
122
+ let lines = src.toString();
123
+ lines = lines.replace(/\r\n?/mg, "\n");
124
+ let match;
125
+ while ((match = LINE.exec(lines)) != null) {
126
+ const key = match[1];
127
+ let value = match[2] || "";
128
+ value = value.trim();
129
+ const maybeQuote = value[0];
130
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
131
+ if (maybeQuote === '"') {
132
+ value = value.replace(/\\n/g, "\n");
133
+ value = value.replace(/\\r/g, "\r");
134
+ }
135
+ obj[key] = value;
136
+ }
137
+ return obj;
138
+ }
139
+ function _log(message) {
140
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
141
+ }
142
+ function _resolveHome(envPath) {
143
+ return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
144
+ }
145
+ function config2(options) {
146
+ let dotenvPath = path2.resolve(process.cwd(), ".env");
147
+ let encoding = "utf8";
148
+ const debug = Boolean(options && options.debug);
149
+ const override = Boolean(options && options.override);
150
+ if (options) {
151
+ if (options.path != null) {
152
+ dotenvPath = _resolveHome(options.path);
153
+ }
154
+ if (options.encoding != null) {
155
+ encoding = options.encoding;
156
+ }
157
+ }
158
+ try {
159
+ const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
160
+ Object.keys(parsed).forEach(function(key) {
161
+ if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
162
+ process.env[key] = parsed[key];
163
+ } else {
164
+ if (override === true) {
165
+ process.env[key] = parsed[key];
166
+ }
167
+ if (debug) {
168
+ if (override === true) {
169
+ _log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
170
+ } else {
171
+ _log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
172
+ }
173
+ }
174
+ }
175
+ });
176
+ return { parsed };
177
+ } catch (e) {
178
+ if (debug) {
179
+ _log(`Failed to load ${dotenvPath} ${e.message}`);
180
+ }
181
+ return { error: e };
182
+ }
183
+ }
184
+ var DotenvModule = {
185
+ config: config2,
186
+ parse
187
+ };
188
+ module.exports.config = DotenvModule.config;
189
+ module.exports.parse = DotenvModule.parse;
190
+ module.exports = DotenvModule;
191
+ }
192
+ });
193
+
194
+ // src/utils.ts
195
+ var dotenv = __toESM(require_main());
196
+ var TEST_GUEST_FINGERPRINTS = ["052b1051-35e9-4264-97ac-2f0f67761869"];
197
+ var TEST_MEMBER_FINGERPRINTS = [
198
+ "0493b6d8-80d6-477c-addd-b6b8ccd73e82",
199
+ "244517e0-2a29-4202-a4fc-facc7ba3ce47",
200
+ "5bf88c9b-6975-49ae-a5db-74e85ada82d6"
201
+ ];
202
+ var TEST_MEMBER_EMAILS = [
203
+ "feedbackwallet@gmail.com",
204
+ "diplomatictechno@gmail.com",
205
+ "localswaphub@gmail.com"
206
+ ];
207
+ var VEX_TEST_EMAIL = process.env.VEX_TEST_EMAIL_1;
208
+ var VEX_TEST_PASSWORD = process.env.VEX_TEST_PASSWORD_1;
209
+ var VEX_TEST_FINGERPRINT = TEST_MEMBER_FINGERPRINTS[0];
210
+ var VEX_TEST_EMAIL_2 = process.env.VEX_TEST_EMAIL_2;
211
+ var VEX_TEST_PASSWORD_2 = process.env.VEX_TEST_PASSWORD_2;
212
+ var VEX_TEST_FINGERPRINT_2 = TEST_MEMBER_FINGERPRINTS[1];
213
+ var VEX_TEST_EMAIL_3 = process.env.VEX_TEST_EMAIL_3;
214
+ var VEX_TEST_PASSWORD_3 = process.env.VEX_TEST_PASSWORD_3;
215
+ var VEX_TEST_FINGERPRINT_3 = TEST_MEMBER_FINGERPRINTS[2];
216
+ dotenv.config();
217
+ var TEST_URL = process.env.TEST_URL;
218
+ var LIVE_URL = "https://askvex.com";
219
+ var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
220
+ var isCI = process.env.NEXT_PUBLIC_CI || process.env.CI;
221
+ var getURL = ({
222
+ isLive = false,
223
+ isMember = false,
224
+ path: path2 = "",
225
+ fingerprint = ""
226
+ } = {
227
+ isLive: false,
228
+ isMember: false,
229
+ path: "",
230
+ fingerprint: ""
231
+ }) => {
232
+ const base = isLive ? LIVE_URL : TEST_URL;
233
+ return isMember ? `${base}${path2}?fp=${fingerprint || TEST_MEMBER_FINGERPRINTS[0]}` : `${base}${path2}?fp=${fingerprint || TEST_GUEST_FINGERPRINTS[0]}`;
234
+ };
235
+ var simulateInputPaste = async (page, text) => {
236
+ await page.evaluate((content) => {
237
+ const textarea = document.querySelector(
238
+ 'textarea[data-testid="chat-textarea"]'
239
+ );
240
+ if (!textarea) return;
241
+ const pasteEvent = new Event("paste", {
242
+ bubbles: true,
243
+ cancelable: true
244
+ });
245
+ Object.defineProperty(pasteEvent, "clipboardData", {
246
+ value: {
247
+ getData: () => content,
248
+ types: ["text/plain"],
249
+ files: [],
250
+ items: [
251
+ {
252
+ kind: "string",
253
+ type: "text/plain",
254
+ getAsString: (callback) => callback(content)
255
+ }
256
+ ]
257
+ },
258
+ writable: false
259
+ });
260
+ textarea.dispatchEvent(pasteEvent);
261
+ textarea.value = content;
262
+ const inputEvent = new Event("input", { bubbles: true });
263
+ textarea.dispatchEvent(inputEvent);
264
+ }, text);
265
+ };
266
+ var simulatePaste = async (page, text) => {
267
+ await page.evaluate(async (content) => {
268
+ await navigator.clipboard.writeText(content);
269
+ const pasteButton = document.querySelector(
270
+ '[data-testid*="artifacts-paste-button"]'
271
+ );
272
+ if (pasteButton) {
273
+ pasteButton.click();
274
+ }
275
+ }, text);
276
+ };
277
+ function capitalizeFirstLetter(val) {
278
+ return String(val).charAt(0).toUpperCase() + String(val).slice(1);
279
+ }
280
+ var chat = async ({
281
+ artifacts,
282
+ page,
283
+ isMember,
284
+ isSubscriber,
285
+ instruction = "This thread will be all about React Native, are you ready?",
286
+ prompts = [
287
+ {
288
+ stop: false,
289
+ text: "Hello",
290
+ agentMessageTimeout: 5e5,
291
+ webSearch: false,
292
+ delete: true,
293
+ mix: {
294
+ image: 0,
295
+ video: 0,
296
+ audio: 0,
297
+ paste: 0,
298
+ pdf: 0
299
+ }
300
+ }
301
+ ],
302
+ agentMessageTimeout = 50 * 1e3,
303
+ isNewChat = true,
304
+ isLiveTest = false,
305
+ threadId,
306
+ creditsConsumed = 0,
307
+ bookmark = true
308
+ }) => {
309
+ page.on("console", (msg) => {
310
+ console.log(`[browser][${msg.type()}] ${msg.text()}`, msg);
311
+ });
312
+ if (threadId) {
313
+ instruction = "";
314
+ }
315
+ const hourlyLimit = isSubscriber ? 100 : isMember ? 30 : 10;
316
+ const getModelCredits = (model) => model === "flux" ? 2 : isMember ? model === "chatGPT" ? 4 : model === "deepSeek" ? 1 : model === "claude" ? 3 : 1 : 1;
317
+ const MAX_FILE_SIZE = 4;
318
+ if (prompts?.some(
319
+ (p) => p.pdf && p.pdf > MAX_FILE_SIZE || p.image && p.image > MAX_FILE_SIZE || p.video && p.video > MAX_FILE_SIZE || p.audio && p.audio > MAX_FILE_SIZE || p.paste && p.paste > MAX_FILE_SIZE || Object.values(p.mix || {}).some((v) => v > MAX_FILE_SIZE)
320
+ )) {
321
+ throw new Error("Test file size limit exceeded");
322
+ }
323
+ if (isLiveTest) {
324
+ await page.goto(getURL({ isLive: true, isMember }), {
325
+ waitUntil: "networkidle"
326
+ });
327
+ await wait(3e3);
328
+ } else if (isNewChat) {
329
+ await page.goto(getURL({ isLive: false, isMember }), {
330
+ waitUntil: "networkidle"
331
+ });
332
+ await wait(3e3);
333
+ }
334
+ let credits = isSubscriber ? 2e3 : (isMember ? 150 : 30) - creditsConsumed;
335
+ let hourlyUsage = creditsConsumed || 0;
336
+ const agentModal = page.getByTestId("agent-modal");
337
+ await test.expect(agentModal).not.toBeVisible();
338
+ const signInModal = page.getByTestId("sign-in-modal");
339
+ await test.expect(signInModal).not.toBeVisible();
340
+ const agentSelectButton = page.getByTestId("agent-select-button");
341
+ await test.expect(agentSelectButton).toBeVisible();
342
+ const addDebateAgentButton = page.getByTestId("add-debate-agent-button");
343
+ await test.expect(addDebateAgentButton).toBeVisible();
344
+ const getAgentName = async () => {
345
+ return page.getByTestId("agent-select-button").getAttribute("data-agent-name");
346
+ };
347
+ const getDebateAgentName = async () => {
348
+ return page.getByTestId("add-debate-agent-button").getAttribute("data-agent-name");
349
+ };
350
+ !isMember && test.expect(await getAgentName()).toBe("deepSeek");
351
+ const chatTextarea = page.getByTestId("chat-textarea");
352
+ await test.expect(chatTextarea).toBeVisible();
353
+ const creditsInfo = page.getByTestId("credits-info");
354
+ await test.expect(creditsInfo).toBeVisible();
355
+ const scrollToBottom = async () => {
356
+ await page.evaluate(() => {
357
+ window.scrollTo(0, document.body.scrollHeight);
358
+ });
359
+ await wait(500);
360
+ };
361
+ const getCreditsLeft = async () => {
362
+ await scrollToBottom();
363
+ const creditsInfo2 = page.getByTestId("credits-info");
364
+ const isCreditsVisible = await creditsInfo2.isVisible().catch(() => false);
365
+ if (!isCreditsVisible) {
366
+ return null;
367
+ }
368
+ return await creditsInfo2.getAttribute("data-credits-left", {
369
+ timeout: 1e3
370
+ });
371
+ };
372
+ const getHourlyUsageLeft = async () => {
373
+ await scrollToBottom();
374
+ const hourlyLimitInfo = page.getByTestId("hourly-limit-info");
375
+ return await hourlyLimitInfo.getAttribute("data-hourly-left", {
376
+ timeout: 1e3
377
+ });
378
+ };
379
+ const subscribeButton = page.getByTestId("subscribe-from-chat-button");
380
+ await test.expect(subscribeButton).toBeVisible();
381
+ test.expect(await getCreditsLeft()).toBe(credits.toString());
382
+ const thread2 = page.getByTestId("thread");
383
+ let willFail = false;
384
+ const why = page.getByTestId("instruction-why");
385
+ let instructionButton = page.getByTestId("instruction-button");
386
+ let artifactsButton = page.getByTestId("instruction-artifacts-button");
387
+ if (!threadId) {
388
+ await test.expect(thread2).not.toBeVisible();
389
+ await test.expect(why).toBeVisible();
390
+ } else {
391
+ await test.expect(instructionButton).not.toBeVisible();
392
+ instructionButton = page.getByTestId("chat-instruction-button");
393
+ artifactsButton = page.getByTestId("chat-artifacts-button");
394
+ await test.expect(thread2).toBeVisible();
395
+ await test.expect(why).not.toBeVisible();
396
+ }
397
+ await test.expect(instructionButton).toBeVisible();
398
+ const instructionModal = page.getByTestId("instruction-modal");
399
+ await test.expect(instructionModal).not.toBeVisible();
400
+ if (instruction) {
401
+ await instructionButton.click();
402
+ await test.expect(instructionModal).toBeVisible();
403
+ const modalMaxCharCount = page.getByTestId(
404
+ "instruction-modal-max-char-count"
405
+ );
406
+ await test.expect(modalMaxCharCount).toBeVisible();
407
+ const modalTextarea = page.getByTestId("instruction-modal-textarea");
408
+ await test.expect(modalTextarea).toBeVisible();
409
+ await modalTextarea.fill(instruction);
410
+ const modalCharLeft = page.getByTestId("instruction-modal-char-left");
411
+ await test.expect(modalCharLeft).toBeVisible();
412
+ await test.expect(modalMaxCharCount).not.toBeVisible();
413
+ const modalSaveButton = page.getByTestId("instruction-modal-save-button");
414
+ await test.expect(modalSaveButton).toBeVisible();
415
+ await modalSaveButton.click();
416
+ }
417
+ if (artifacts) {
418
+ await artifactsButton.click();
419
+ const dataTestId = threadId ? "chat" : "instruction";
420
+ await test.expect(instructionModal).toBeVisible();
421
+ if (artifacts.pdf) {
422
+ const fileChooserPromise = page.waitForEvent("filechooser");
423
+ await page.getByTestId(`${dataTestId}-artifacts-upload-button`).click();
424
+ const testUsedPaths = Array.from({ length: artifacts.pdf }, (_, i) => {
425
+ const fileType = "pdf";
426
+ const fileName = `test${capitalizeFirstLetter(fileType)}${i + 1}`;
427
+ const extension = "pdf";
428
+ return path__default.default.join(
429
+ process2__default.default.cwd(),
430
+ "tests/shared",
431
+ fileType,
432
+ `${fileName}.${extension}`
433
+ );
434
+ });
435
+ const fileChooser = await fileChooserPromise;
436
+ await fileChooser.setFiles(testUsedPaths);
437
+ }
438
+ if (artifacts.paste) {
439
+ for (let i = 0; i < artifacts.paste; i++) {
440
+ await simulatePaste(page, faker.faker.lorem.sentence({ min: 550, max: 750 }));
441
+ }
442
+ }
443
+ if ((artifacts.pdf || 0) + (artifacts.paste || 0) > 5) {
444
+ await test.expect(page.getByText("Maximum 5 files allowed")).toBeVisible();
445
+ }
446
+ const modalSaveButton = page.getByTestId(`${dataTestId}-modal-save-button`);
447
+ await test.expect(modalSaveButton).toBeVisible();
448
+ await modalSaveButton.click();
449
+ test.expect(await page.getByText("Updated").count()).toBeGreaterThan(0);
450
+ }
451
+ const getAgentModalButton = (agent) => {
452
+ const agentModalButton = page.getByTestId(`agent-modal-button-${agent}`);
453
+ return agentModalButton;
454
+ };
455
+ for (const prompt of prompts) {
456
+ const debateAgentDeleteButton = page.getByTestId(
457
+ "debate-agent-delete-button"
458
+ );
459
+ const isDebateAgentVisible = await debateAgentDeleteButton.isVisible();
460
+ if (isDebateAgentVisible) {
461
+ await debateAgentDeleteButton.click();
462
+ }
463
+ if (prompt.model && prompt.model !== await getAgentName()) {
464
+ await agentSelectButton.click();
465
+ await test.expect(agentModal).toBeVisible();
466
+ const agentModalButton = getAgentModalButton(prompt.model);
467
+ await agentModalButton.click();
468
+ if (prompt.model === "gemini") {
469
+ const agentModalCloseButton = page.getByTestId(
470
+ "agent-modal-close-button"
471
+ );
472
+ await test.expect(agentModalCloseButton).toBeVisible();
473
+ await agentModalCloseButton.click();
474
+ test.expect(await getAgentName()).toBe(isMember ? "chatGPT" : "flux");
475
+ } else {
476
+ if (!isMember) {
477
+ if (!["flux", "deepSeek", "gemini"].includes(prompt.model)) {
478
+ await test.expect(signInModal).toBeVisible();
479
+ const signInModalCloseButton = page.getByTestId(
480
+ "sign-in-modal-close-button"
481
+ );
482
+ await test.expect(signInModalCloseButton).toBeVisible();
483
+ await signInModalCloseButton.click();
484
+ test.expect(await getAgentName()).toBe("deepSeek");
485
+ }
486
+ } else {
487
+ test.expect(await getAgentName()).toBe(prompt.model);
488
+ }
489
+ }
490
+ }
491
+ if (prompt.debateAgent) {
492
+ {
493
+ await addDebateAgentButton.click();
494
+ await test.expect(agentModal).toBeVisible();
495
+ const geminiButton = page.getByTestId(`agent-modal-button-gemini`);
496
+ const fluxButton = page.getByTestId(`agent-modal-button-flux`);
497
+ test.expect(geminiButton).not.toBeVisible();
498
+ test.expect(fluxButton).not.toBeVisible();
499
+ const agentModalButton = page.getByTestId(
500
+ `agent-modal-button-${prompt.debateAgent}`
501
+ );
502
+ await agentModalButton.click();
503
+ }
504
+ if (!isMember) {
505
+ test.expect(prompt.shouldFail).toBe(true);
506
+ willFail = true;
507
+ } else {
508
+ test.expect(await getDebateAgentName()).toBe(prompt.debateAgent);
509
+ await addDebateAgentButton.click();
510
+ await test.expect(getAgentModalButton(prompt.debateAgent)).not.toBeVisible();
511
+ const agentModalCloseButton = page.getByTestId(
512
+ "agent-modal-close-button"
513
+ );
514
+ await test.expect(agentModalCloseButton).toBeVisible();
515
+ await agentModalCloseButton.click();
516
+ await agentSelectButton.click();
517
+ await test.expect(agentModal).toBeVisible();
518
+ const fluxButton = getAgentModalButton("flux");
519
+ await test.expect(fluxButton).toBeVisible();
520
+ await fluxButton.click();
521
+ await wait(1e3);
522
+ await test.expect(addDebateAgentButton).not.toBeVisible();
523
+ await agentSelectButton.click();
524
+ const promptAgentModalButton = page.getByTestId(
525
+ `agent-modal-button-${prompt.model}`
526
+ );
527
+ await promptAgentModalButton.click();
528
+ test.expect(await getAgentName()).toBe(prompt.model);
529
+ await addDebateAgentButton.click();
530
+ await test.expect(addDebateAgentButton).toBeVisible();
531
+ await getAgentModalButton(prompt.debateAgent).click();
532
+ test.expect(await getDebateAgentName()).toBe(prompt.debateAgent);
533
+ test.expect(await getAgentName()).toBe(prompt.model);
534
+ }
535
+ }
536
+ if (willFail) {
537
+ return;
538
+ }
539
+ const attachButton = page.getByTestId("attach-button");
540
+ const attachButtonClose = page.getByTestId("attach-button-close");
541
+ const attachButtonImage = page.getByTestId("attach-button-image");
542
+ const attachButtonVideo = page.getByTestId("attach-button-video");
543
+ const attachButtonAudio = page.getByTestId("attach-button-audio");
544
+ const attachButtonPdf = page.getByTestId("attach-button-pdf");
545
+ if (prompt.image) {
546
+ for (let i = 0; i < prompt.image; i++) {
547
+ attachButton.click();
548
+ await wait(1e3);
549
+ await test.expect(attachButton).not.toBeVisible();
550
+ await test.expect(attachButtonClose).toBeVisible();
551
+ await test.expect(attachButtonImage).toBeVisible();
552
+ await test.expect(attachButtonVideo).toBeVisible();
553
+ await test.expect(attachButtonAudio).toBeVisible();
554
+ await test.expect(attachButtonPdf).toBeVisible();
555
+ const fileChooserPromise2 = page.waitForEvent("filechooser");
556
+ if (i === 3) {
557
+ await test.expect(attachButtonImage).toBeDisabled();
558
+ await test.expect(attachButtonVideo).toBeDisabled();
559
+ await test.expect(attachButtonAudio).toBeDisabled();
560
+ await test.expect(attachButtonPdf).toBeDisabled();
561
+ await attachButtonClose.click();
562
+ await test.expect(attachButton).toBeVisible();
563
+ break;
564
+ }
565
+ await attachButtonImage.click();
566
+ {
567
+ const fileChooser2 = await fileChooserPromise2;
568
+ const testUsed = path__default.default.join(
569
+ process2__default.default.cwd(),
570
+ `tests/shared/image/testImage${i + 1}.jpeg`
571
+ );
572
+ await fileChooser2.setFiles(testUsed);
573
+ await page.waitForTimeout(2e3);
574
+ await test.expect(attachButton).toBeVisible();
575
+ attachButton.click();
576
+ await test.expect(attachButtonImage).toBeVisible();
577
+ await test.expect(attachButtonVideo).toBeVisible();
578
+ await test.expect(attachButtonAudio).toBeVisible();
579
+ await test.expect(attachButtonPdf).toBeVisible();
580
+ await attachButtonClose.click();
581
+ await test.expect(attachButton).toBeVisible();
582
+ }
583
+ }
584
+ const filePreviewClears = page.getByTestId("file-preview-clear");
585
+ const count = prompt.image > 3 ? 3 : prompt.image;
586
+ for (let i = 0; i < count; i++) {
587
+ const filePreviewClear = filePreviewClears.nth(count - i - 1);
588
+ await test.expect(filePreviewClear).toBeVisible();
589
+ await filePreviewClear.click();
590
+ await page.waitForTimeout(500);
591
+ }
592
+ await test.expect(attachButton).toBeVisible();
593
+ attachButton.click();
594
+ const fileChooserPromise = page.waitForEvent("filechooser");
595
+ await test.expect(attachButtonImage).toBeVisible();
596
+ await attachButtonImage.click();
597
+ const fileChooser = await fileChooserPromise;
598
+ const testUsedPaths = Array.from(
599
+ { length: prompt.image },
600
+ (_, i) => path__default.default.join(
601
+ process2__default.default.cwd(),
602
+ "tests/shared/image",
603
+ `testImage${i + 1}.jpeg`
604
+ )
605
+ );
606
+ await fileChooser.setFiles(testUsedPaths);
607
+ if (prompt.image > 3) {
608
+ await test.expect(page.getByText("Too many files selected")).toBeVisible();
609
+ }
610
+ } else if (prompt.audio) {
611
+ for (let i = 0; i < prompt.audio; i++) {
612
+ attachButton.click();
613
+ await wait(1e3);
614
+ await test.expect(attachButton).not.toBeVisible();
615
+ await test.expect(attachButtonClose).toBeVisible();
616
+ await test.expect(attachButtonImage).toBeVisible();
617
+ await test.expect(attachButtonVideo).toBeVisible();
618
+ await test.expect(attachButtonAudio).toBeVisible();
619
+ await test.expect(attachButtonPdf).toBeVisible();
620
+ const fileChooserPromise2 = page.waitForEvent("filechooser");
621
+ if (i === 3) {
622
+ await test.expect(attachButtonImage).toBeDisabled();
623
+ await test.expect(attachButtonVideo).toBeDisabled();
624
+ await test.expect(attachButtonAudio).toBeDisabled();
625
+ await test.expect(attachButtonPdf).toBeDisabled();
626
+ await attachButtonClose.click();
627
+ await test.expect(attachButton).toBeVisible();
628
+ break;
629
+ }
630
+ await attachButtonAudio.click();
631
+ {
632
+ const fileChooser2 = await fileChooserPromise2;
633
+ const testUsed = path__default.default.join(
634
+ process2__default.default.cwd(),
635
+ `tests/shared/audio/testAudio${i + 1}.wav`
636
+ );
637
+ await fileChooser2.setFiles(testUsed);
638
+ await page.waitForTimeout(2e3);
639
+ await test.expect(attachButton).toBeVisible();
640
+ attachButton.click();
641
+ await test.expect(attachButtonImage).toBeVisible();
642
+ await test.expect(attachButtonVideo).toBeVisible();
643
+ await test.expect(attachButtonAudio).toBeVisible();
644
+ await test.expect(attachButtonPdf).toBeVisible();
645
+ await attachButtonClose.click();
646
+ await test.expect(attachButton).toBeVisible();
647
+ }
648
+ }
649
+ const filePreviewClears = page.getByTestId("file-preview-clear");
650
+ const count = prompt.audio > 3 ? 3 : prompt.audio;
651
+ for (let i = 0; i < count; i++) {
652
+ const filePreviewClear = filePreviewClears.nth(count - i - 1);
653
+ await test.expect(filePreviewClear).toBeVisible();
654
+ await filePreviewClear.click();
655
+ await page.waitForTimeout(500);
656
+ }
657
+ await test.expect(attachButton).toBeVisible();
658
+ attachButton.click();
659
+ const fileChooserPromise = page.waitForEvent("filechooser");
660
+ await test.expect(attachButtonAudio).toBeVisible();
661
+ await attachButtonAudio.click();
662
+ const fileChooser = await fileChooserPromise;
663
+ const testUsedPaths = Array.from(
664
+ { length: prompt.audio },
665
+ (_, i) => path__default.default.join(process2__default.default.cwd(), "tests/shared/audio", `testAudio${i + 1}.wav`)
666
+ );
667
+ await fileChooser.setFiles(testUsedPaths);
668
+ if (prompt.audio > 3) {
669
+ await test.expect(page.getByText("Too many files selected")).toBeVisible();
670
+ }
671
+ } else if (prompt.video) {
672
+ for (let i = 0; i < prompt.video; i++) {
673
+ attachButton.click();
674
+ await wait(1e3);
675
+ await test.expect(attachButton).not.toBeVisible();
676
+ await test.expect(attachButtonClose).toBeVisible();
677
+ await test.expect(attachButtonImage).toBeVisible();
678
+ await test.expect(attachButtonVideo).toBeVisible();
679
+ await test.expect(attachButtonAudio).toBeVisible();
680
+ await test.expect(attachButtonPdf).toBeVisible();
681
+ const fileChooserPromise2 = page.waitForEvent("filechooser");
682
+ if (i === 3) {
683
+ await test.expect(attachButtonImage).toBeDisabled();
684
+ await test.expect(attachButtonVideo).toBeDisabled();
685
+ await test.expect(attachButtonAudio).toBeDisabled();
686
+ await test.expect(attachButtonPdf).toBeDisabled();
687
+ await attachButtonClose.click();
688
+ await test.expect(attachButton).toBeVisible();
689
+ break;
690
+ }
691
+ await attachButtonAudio.click();
692
+ {
693
+ const fileChooser2 = await fileChooserPromise2;
694
+ const testUsed = path__default.default.join(
695
+ process2__default.default.cwd(),
696
+ `tests/shared/video/testVideo${i + 1}.webm`
697
+ );
698
+ await fileChooser2.setFiles(testUsed);
699
+ await page.waitForTimeout(2e3);
700
+ await test.expect(attachButton).toBeVisible();
701
+ attachButton.click();
702
+ await test.expect(attachButtonImage).toBeVisible();
703
+ await test.expect(attachButtonVideo).toBeVisible();
704
+ await test.expect(attachButtonAudio).toBeVisible();
705
+ await test.expect(attachButtonPdf).toBeVisible();
706
+ await attachButtonClose.click();
707
+ await test.expect(attachButton).toBeVisible();
708
+ }
709
+ }
710
+ const filePreviewClears = page.getByTestId("file-preview-clear");
711
+ const count = prompt.video > 3 ? 3 : prompt.video;
712
+ for (let i = 0; i < count; i++) {
713
+ const filePreviewClear = filePreviewClears.nth(count - i - 1);
714
+ await test.expect(filePreviewClear).toBeVisible();
715
+ await filePreviewClear.click();
716
+ await page.waitForTimeout(500);
717
+ }
718
+ await test.expect(attachButton).toBeVisible();
719
+ attachButton.click();
720
+ const fileChooserPromise = page.waitForEvent("filechooser");
721
+ await test.expect(attachButtonAudio).toBeVisible();
722
+ await attachButtonAudio.click();
723
+ const fileChooser = await fileChooserPromise;
724
+ const testUsedPaths = Array.from(
725
+ { length: prompt.video },
726
+ (_, i) => path__default.default.join(
727
+ process2__default.default.cwd(),
728
+ "tests/shared/video",
729
+ `testVideo${i + 1}.webm`
730
+ )
731
+ );
732
+ await fileChooser.setFiles(testUsedPaths);
733
+ if (prompt.video > 3) {
734
+ await test.expect(page.getByText("Too many files selected")).toBeVisible();
735
+ }
736
+ } else if (prompt.pdf) {
737
+ for (let i = 0; i < prompt.pdf; i++) {
738
+ attachButton.click();
739
+ await wait(1e3);
740
+ await test.expect(attachButton).not.toBeVisible();
741
+ await test.expect(attachButtonClose).toBeVisible();
742
+ await test.expect(attachButtonImage).toBeVisible();
743
+ await test.expect(attachButtonVideo).toBeVisible();
744
+ await test.expect(attachButtonAudio).toBeVisible();
745
+ await test.expect(attachButtonPdf).toBeVisible();
746
+ const fileChooserPromise2 = page.waitForEvent("filechooser");
747
+ if (i === 3) {
748
+ await test.expect(attachButtonImage).toBeDisabled();
749
+ await test.expect(attachButtonVideo).toBeDisabled();
750
+ await test.expect(attachButtonAudio).toBeDisabled();
751
+ await test.expect(attachButtonPdf).toBeDisabled();
752
+ await attachButtonClose.click();
753
+ await test.expect(attachButton).toBeVisible();
754
+ break;
755
+ }
756
+ await attachButtonPdf.click();
757
+ {
758
+ const fileChooser2 = await fileChooserPromise2;
759
+ const testUsed = path__default.default.join(
760
+ process2__default.default.cwd(),
761
+ `tests/shared/pdf/testPdf${i + 1}.pdf`
762
+ );
763
+ await fileChooser2.setFiles(testUsed);
764
+ await page.waitForTimeout(2e3);
765
+ await test.expect(attachButton).toBeVisible();
766
+ attachButton.click();
767
+ await test.expect(attachButtonImage).toBeVisible();
768
+ await test.expect(attachButtonVideo).toBeVisible();
769
+ await test.expect(attachButtonAudio).toBeVisible();
770
+ await test.expect(attachButtonPdf).toBeVisible();
771
+ await attachButtonClose.click();
772
+ await test.expect(attachButton).toBeVisible();
773
+ }
774
+ }
775
+ const filePreviewClears = page.getByTestId("file-preview-clear");
776
+ const count = prompt.pdf > 3 ? 3 : prompt.pdf;
777
+ for (let i = 0; i < count; i++) {
778
+ const filePreviewClear = filePreviewClears.nth(count - i - 1);
779
+ await test.expect(filePreviewClear).toBeVisible();
780
+ await filePreviewClear.click();
781
+ await page.waitForTimeout(500);
782
+ }
783
+ await test.expect(attachButton).toBeVisible();
784
+ attachButton.click();
785
+ const fileChooserPromise = page.waitForEvent("filechooser");
786
+ await test.expect(attachButtonPdf).toBeVisible();
787
+ await attachButtonPdf.click();
788
+ const fileChooser = await fileChooserPromise;
789
+ const testUsedPaths = Array.from(
790
+ { length: prompt.pdf },
791
+ (_, i) => path__default.default.join(process2__default.default.cwd(), "tests/shared/pdf", `testPdf${i + 1}.pdf`)
792
+ );
793
+ await fileChooser.setFiles(testUsedPaths);
794
+ if (prompt.pdf > 3) {
795
+ await test.expect(page.getByText("Too many files selected")).toBeVisible();
796
+ }
797
+ } else if (prompt.paste) {
798
+ const filePreviewClears = page.getByTestId("file-preview-clear");
799
+ const count = prompt.paste > 3 ? 3 : prompt.paste;
800
+ for (let i = 0; i < prompt.paste; i++) {
801
+ const text = faker.faker.lorem.sentence({ min: 550, max: 750 });
802
+ await simulateInputPaste(page, text);
803
+ await page.waitForTimeout(1e3);
804
+ }
805
+ if (prompt.paste > 3) {
806
+ await test.expect(page.getByText("Too many files")).toBeVisible();
807
+ }
808
+ for (let i = 0; i < count; i++) {
809
+ const filePreviewClear = filePreviewClears.nth(count - i - 1);
810
+ await test.expect(filePreviewClear).toBeVisible();
811
+ await filePreviewClear.click();
812
+ await page.waitForTimeout(500);
813
+ }
814
+ for (let i = 0; i < count; i++) {
815
+ const text = faker.faker.lorem.sentence({ min: 550, max: 750 });
816
+ await simulateInputPaste(page, text);
817
+ }
818
+ } else if (prompt.mix) {
819
+ const fileExtensions = {
820
+ image: "jpeg",
821
+ video: "mp4",
822
+ audio: "wav",
823
+ pdf: "pdf"
824
+ };
825
+ const size = Object.values(prompt.mix).reduce((a, b) => a + b);
826
+ const to = size > 3 ? 3 : size;
827
+ let filesToAttach = [];
828
+ let filesToPaste = 0;
829
+ for (const [key, count] of Object.entries(prompt.mix)) {
830
+ if (key === "paste") {
831
+ filesToPaste = count;
832
+ } else {
833
+ for (let i = 0; i < count; i++) {
834
+ filesToAttach.push(key);
835
+ }
836
+ }
837
+ }
838
+ filesToAttach = filesToAttach.slice(0, 3 - filesToPaste);
839
+ for (let i = 0; i < filesToPaste; i++) {
840
+ const text = faker.faker.lorem.sentence({ min: 550, max: 750 });
841
+ await simulateInputPaste(page, text);
842
+ await page.waitForTimeout(1e3);
843
+ }
844
+ for (let i = 0; i < filesToAttach.length; i++) {
845
+ const key = filesToAttach[i];
846
+ if (!key) break;
847
+ attachButton.click();
848
+ await wait(1e3);
849
+ await test.expect(attachButton).not.toBeVisible();
850
+ await test.expect(attachButtonClose).toBeVisible();
851
+ await test.expect(attachButtonImage).toBeVisible();
852
+ await test.expect(attachButtonVideo).toBeVisible();
853
+ await test.expect(attachButtonAudio).toBeVisible();
854
+ await test.expect(attachButtonPdf).toBeVisible();
855
+ if (i > to) {
856
+ await test.expect(attachButtonImage).toBeDisabled();
857
+ await test.expect(attachButtonVideo).toBeDisabled();
858
+ await test.expect(attachButtonAudio).toBeDisabled();
859
+ await test.expect(attachButtonPdf).toBeDisabled();
860
+ await attachButtonClose.click();
861
+ await test.expect(attachButton).toBeVisible();
862
+ break;
863
+ }
864
+ const fileChooserPromise = page.waitForEvent("filechooser");
865
+ if (key === "audio") {
866
+ await test.expect(attachButtonAudio).toBeVisible();
867
+ await attachButtonAudio.click();
868
+ } else if (key === "image") {
869
+ await test.expect(attachButtonImage).toBeVisible();
870
+ await attachButtonImage.click();
871
+ } else if (key === "video") {
872
+ await test.expect(attachButtonVideo).toBeVisible();
873
+ await attachButtonVideo.click();
874
+ } else if (key === "pdf") {
875
+ await test.expect(attachButtonPdf).toBeVisible();
876
+ await attachButtonPdf.click();
877
+ }
878
+ {
879
+ const fileChooser = await fileChooserPromise;
880
+ const extension = fileExtensions[key] || "jpeg";
881
+ const fileIndex = filesToAttach.slice(0, i + 1).filter((k) => k === key).length;
882
+ const testUsed = path__default.default.join(
883
+ process2__default.default.cwd(),
884
+ `tests/shared/${key}/test${capitalizeFirstLetter(key)}${fileIndex}.${extension}`
885
+ );
886
+ await fileChooser.setFiles(testUsed);
887
+ await page.waitForTimeout(2e3);
888
+ await test.expect(attachButton).toBeVisible();
889
+ attachButton.click();
890
+ await test.expect(attachButtonImage).toBeVisible();
891
+ await test.expect(attachButtonVideo).toBeVisible();
892
+ await test.expect(attachButtonAudio).toBeVisible();
893
+ await test.expect(attachButtonPdf).toBeVisible();
894
+ await attachButtonClose.click();
895
+ await test.expect(attachButton).toBeVisible();
896
+ }
897
+ }
898
+ const filePreviewClears = page.getByTestId("file-preview-clear");
899
+ for (let i = 0; i < to; i++) {
900
+ const filePreviewClear = filePreviewClears.nth(0);
901
+ await test.expect(filePreviewClear).toBeVisible();
902
+ await filePreviewClear.click();
903
+ await page.waitForTimeout(500);
904
+ }
905
+ for (let i = 0; i < filesToPaste; i++) {
906
+ const text = faker.faker.lorem.sentence({ min: 550, max: 750 });
907
+ await simulateInputPaste(page, text);
908
+ await page.waitForTimeout(1e3);
909
+ }
910
+ if (filesToAttach.length > 0) {
911
+ await test.expect(attachButton).toBeVisible();
912
+ attachButton.click();
913
+ const fileChooserPromise = page.waitForEvent("filechooser");
914
+ const key = filesToAttach[0];
915
+ if (key === "image") {
916
+ await attachButtonImage.click();
917
+ } else if (key === "video") {
918
+ await attachButtonVideo.click();
919
+ } else if (key === "audio") {
920
+ await attachButtonAudio.click();
921
+ } else if (key === "pdf") {
922
+ await attachButtonPdf.click();
923
+ }
924
+ const fileChooser = await fileChooserPromise;
925
+ const testUsedPaths = await Promise.all(
926
+ Array.from({ length: filesToAttach.length }, async (_, i) => {
927
+ const fileType = filesToAttach[i];
928
+ if (!fileType) {
929
+ return null;
930
+ }
931
+ const fileName = `test${capitalizeFirstLetter(fileType)}${i + 1}`;
932
+ const extension = fileExtensions[fileType] || "jpeg";
933
+ return path__default.default.join(
934
+ process2__default.default.cwd(),
935
+ "tests/shared",
936
+ fileType,
937
+ `${fileName}.${extension}`
938
+ );
939
+ })
940
+ );
941
+ await fileChooser.setFiles(
942
+ testUsedPaths.filter((path2) => path2 !== null)
943
+ );
944
+ if (filesToAttach.length + filesToPaste > 3) {
945
+ await test.expect(page.getByText("Too many files selected")).toBeVisible();
946
+ }
947
+ }
948
+ }
949
+ await chatTextarea.fill(prompt.text);
950
+ if (prompt.webSearch) {
951
+ const webSearchButton = page.getByTestId("web-search-button-disabled");
952
+ await test.expect(webSearchButton).toBeVisible();
953
+ await webSearchButton.click();
954
+ if (!isMember) {
955
+ await test.expect(agentModal).toBeVisible();
956
+ const agentModalCloseButton = page.getByTestId(
957
+ "agent-modal-close-button"
958
+ );
959
+ await test.expect(agentModalCloseButton).toBeVisible();
960
+ await agentModalCloseButton.click();
961
+ }
962
+ }
963
+ const sendButton = page.getByTestId("chat-send-button");
964
+ await test.expect(sendButton).toBeVisible();
965
+ if (prompt.shouldFail) {
966
+ console.log(
967
+ `\u{1F6AB} Testing hourly limit boundary with message: "${prompt.text}"`
968
+ );
969
+ await test.expect(sendButton).toBeDisabled();
970
+ break;
971
+ }
972
+ await scrollToBottom();
973
+ await sendButton.click();
974
+ if (prompts.indexOf(prompt) === 0 && artifacts) {
975
+ await test.expect(page.getByText("Uploading artifacts...")).toBeVisible();
976
+ }
977
+ await page.waitForTimeout(5e3);
978
+ const stopButton = page.getByTestId("chat-stop-streaming-button");
979
+ await test.expect(stopButton).toBeVisible({
980
+ timeout: prompt.agentMessageTimeout || agentMessageTimeout
981
+ });
982
+ const getLastMessage = async () => {
983
+ await page.waitForFunction(
984
+ () => {
985
+ const userMessages2 = document.querySelectorAll(
986
+ '[data-testid="user-message"]'
987
+ );
988
+ const guestMessages2 = document.querySelectorAll(
989
+ '[data-testid="guest-message"]'
990
+ );
991
+ console.log(
992
+ `Debug: Found ${userMessages2.length} user messages, ${guestMessages2.length} guest messages`
993
+ );
994
+ return userMessages2.length > 0 || guestMessages2.length > 0;
995
+ },
996
+ { timeout: 1e4 }
997
+ );
998
+ const userMessages = page.getByTestId("user-message");
999
+ const guestMessages = page.getByTestId("guest-message");
1000
+ const userCount = await userMessages.count();
1001
+ const guestCount = await guestMessages.count();
1002
+ console.log(
1003
+ `Debug: After wait - ${userCount} user messages, ${guestCount} guest messages`
1004
+ );
1005
+ if (userCount > 0) {
1006
+ console.log(`Debug: Using user message (${userCount} found)`);
1007
+ return userMessages.nth(userCount - 1);
1008
+ } else if (guestCount > 0) {
1009
+ console.log(`Debug: Using guest message (${guestCount} found)`);
1010
+ return guestMessages.nth(guestCount - 1);
1011
+ } else {
1012
+ throw new Error("No user or guest messages found after waiting");
1013
+ }
1014
+ };
1015
+ await test.expect(await getLastMessage()).toBeVisible({
1016
+ timeout: prompt.agentMessageTimeout || agentMessageTimeout
1017
+ });
1018
+ const lastMessage = await getLastMessage();
1019
+ console.log(`Debug: Got last message, looking for delete button...`);
1020
+ if (prompt.stop) {
1021
+ await stopButton.click();
1022
+ await test.expect(stopButton).not.toBeVisible({
1023
+ timeout: 8e3
1024
+ });
1025
+ prompt.model && (credits -= getModelCredits(prompt.model));
1026
+ } else {
1027
+ hourlyUsage += 1 + (prompt.debateAgent ? 1 : 0);
1028
+ }
1029
+ const deleteMessageButton = lastMessage.locator(
1030
+ "[data-testid=delete-message]"
1031
+ );
1032
+ const deleteButtonCount = await deleteMessageButton.count();
1033
+ console.log(
1034
+ `Debug: Found ${deleteButtonCount} delete buttons in last message`
1035
+ );
1036
+ const userMessageContent = (await getLastMessage()).getByText(prompt.text);
1037
+ await test.expect(userMessageContent).toBeVisible({
1038
+ timeout: agentMessageTimeout
1039
+ });
1040
+ const getLastAgentMessage = async () => {
1041
+ const agentMessages = page.getByTestId("agent-message");
1042
+ const messageCount = await agentMessages.count();
1043
+ return agentMessages.nth(messageCount - 1);
1044
+ };
1045
+ const getLastUserMessage = async () => {
1046
+ const userMessages = page.getByTestId(
1047
+ `${isMember ? "user" : "guest"}-message`
1048
+ );
1049
+ const messageCount = await userMessages.count();
1050
+ return userMessages.nth(messageCount - 1);
1051
+ };
1052
+ await test.expect(await getLastAgentMessage()).toBeVisible();
1053
+ const deleteAgentMessageButton = (await getLastAgentMessage()).locator(
1054
+ "[data-testid=delete-message]"
1055
+ );
1056
+ await test.expect(deleteAgentMessageButton).toBeVisible({
1057
+ timeout: prompt.agentMessageTimeout || agentMessageTimeout,
1058
+ visible: !prompt.stop
1059
+ });
1060
+ if (prompt.image) {
1061
+ const userMessageImageCount = await (await getLastUserMessage()).getByTestId("user-message-image").count();
1062
+ test.expect(userMessageImageCount).toBe(prompt.image > 3 ? 3 : prompt.image);
1063
+ } else if (prompt.mix?.image) {
1064
+ const userMessageImageCount = await (await getLastUserMessage()).getByTestId("user-message-image").count();
1065
+ test.expect(userMessageImageCount).toBe(
1066
+ prompt.mix.image > 3 ? 3 : prompt.mix.image
1067
+ );
1068
+ } else if (prompt.video) {
1069
+ const userMessageVideoCount = await (await getLastUserMessage()).getByTestId("user-message-video").count();
1070
+ test.expect(userMessageVideoCount).toBe(prompt.video > 3 ? 3 : prompt.video);
1071
+ } else if (prompt.mix?.video) {
1072
+ const userMessageVideoCount = (await getLastUserMessage()).getByTestId("user-message-video").count();
1073
+ test.expect(userMessageVideoCount).toBe(
1074
+ prompt.mix.video > 3 ? 3 : prompt.mix.video
1075
+ );
1076
+ } else if (prompt.audio) {
1077
+ const userMessageAudioCount = await (await getLastUserMessage()).getByTestId("user-message-audio").count();
1078
+ test.expect(userMessageAudioCount).toBe(prompt.audio > 3 ? 3 : prompt.audio);
1079
+ } else if (prompt.mix?.audio) {
1080
+ const userMessageAudioCount = (await getLastUserMessage()).getByTestId("user-message-audio").count();
1081
+ test.expect(userMessageAudioCount).toBe(
1082
+ prompt.mix.audio > 3 ? 3 : prompt.mix.audio
1083
+ );
1084
+ } else if (prompt.pdf) {
1085
+ const userMessagePdfCount = await (await getLastUserMessage()).getByTestId("user-message-pdf").count();
1086
+ test.expect(userMessagePdfCount).toBe(prompt.pdf > 3 ? 3 : prompt.pdf);
1087
+ } else if (prompt.mix?.pdf) {
1088
+ const userMessagePdfCount = await (await getLastUserMessage()).getByTestId("user-message-pdf").count();
1089
+ test.expect(userMessagePdfCount).toBe(prompt.mix.pdf > 3 ? 3 : prompt.mix.pdf);
1090
+ }
1091
+ if (prompt.webSearch) {
1092
+ const webSearchResults = (await getLastAgentMessage()).getByTestId(
1093
+ "web-search-results"
1094
+ );
1095
+ await test.expect(webSearchResults).toBeVisible({
1096
+ timeout: prompt.agentMessageTimeout || agentMessageTimeout
1097
+ });
1098
+ const webSearchResult = webSearchResults.getByTestId("web-search-result");
1099
+ test.expect(await webSearchResult.count()).toBe(4);
1100
+ }
1101
+ await wait(1e3);
1102
+ const threadUrl = page.url();
1103
+ const threadId2 = threadUrl.split("/threads/")[1]?.split("?")[0];
1104
+ test.expect(threadId2).toBeTruthy();
1105
+ console.log("Thread:", threadId2);
1106
+ const likeButton = (await getLastAgentMessage()).locator(
1107
+ "[data-testid=like-button]"
1108
+ );
1109
+ if (prompts.indexOf(prompt) === 0 && artifacts) {
1110
+ const dataTestId = threadId2 ? "chat" : "instruction";
1111
+ let artifactsButton2 = page.getByTestId(
1112
+ `${dataTestId}-instruction-artifacts-button`
1113
+ );
1114
+ await artifactsButton2.click();
1115
+ const instructionModal2 = page.getByTestId(
1116
+ `${dataTestId}-instruction-modal`
1117
+ );
1118
+ await test.expect(instructionModal2).toBeVisible();
1119
+ const filePreviewClears = page.getByTestId(
1120
+ `${dataTestId}-instruction-file-preview-clear`
1121
+ );
1122
+ let count = (artifacts.pdf || 0) + (artifacts.paste || 0);
1123
+ if (count > 5) {
1124
+ count = 5;
1125
+ }
1126
+ for (let i = 0; i < count; i++) {
1127
+ const filePreviewClear = filePreviewClears.nth(count - i - 1);
1128
+ await test.expect(filePreviewClear).toBeVisible();
1129
+ await filePreviewClear.click();
1130
+ await page.waitForTimeout(1e3);
1131
+ }
1132
+ test.expect(await filePreviewClears.count()).toBe(0);
1133
+ if (artifacts.paste) {
1134
+ for (let i = 0; i < artifacts.paste; i++) {
1135
+ await simulatePaste(
1136
+ page,
1137
+ faker.faker.lorem.sentence({ min: 550, max: 750 })
1138
+ );
1139
+ }
1140
+ }
1141
+ if (artifacts.pdf) {
1142
+ const fileChooserPromise = page.waitForEvent("filechooser");
1143
+ await page.getByTestId(`${dataTestId}-instruction-artifacts-upload-button`).click();
1144
+ const testUsedPaths = Array.from({ length: artifacts.pdf }, (_, i) => {
1145
+ const fileType = "pdf";
1146
+ const fileName = `test${capitalizeFirstLetter(fileType)}${i + 1}`;
1147
+ const extension = "pdf";
1148
+ return path__default.default.join(
1149
+ process2__default.default.cwd(),
1150
+ "tests/shared",
1151
+ fileType,
1152
+ `${fileName}.${extension}`
1153
+ );
1154
+ });
1155
+ const fileChooser = await fileChooserPromise;
1156
+ await fileChooser.setFiles(testUsedPaths);
1157
+ }
1158
+ if ((artifacts.pdf || 0) + (artifacts.paste || 0) > 5) {
1159
+ await test.expect(page.getByText("Maximum 5 files allowed")).toBeVisible();
1160
+ }
1161
+ const modalSaveButton = page.getByTestId(
1162
+ `${dataTestId}-instruction-modal-save-button`
1163
+ );
1164
+ await test.expect(modalSaveButton).toBeVisible();
1165
+ await modalSaveButton.click();
1166
+ await wait(1e4);
1167
+ const modalCloseButton = page.getByTestId(
1168
+ `${dataTestId}-instruction-modal-close-button`
1169
+ );
1170
+ await test.expect(modalCloseButton).toBeVisible();
1171
+ await modalCloseButton.click();
1172
+ }
1173
+ if (!prompt.stop) {
1174
+ await test.expect(likeButton).toBeVisible({
1175
+ timeout: prompt.agentMessageTimeout || agentMessageTimeout
1176
+ });
1177
+ const dislikeButton = (await getLastAgentMessage()).locator(
1178
+ "[data-testid=dislike-button]"
1179
+ );
1180
+ await test.expect(dislikeButton).toBeVisible({
1181
+ timeout: prompt.agentMessageTimeout || agentMessageTimeout
1182
+ });
1183
+ const getFilterLikedButton = ({ liked }) => page.getByTestId(`${liked ? "unfilter" : "filter"}-liked-button`);
1184
+ await test.expect(getFilterLikedButton({ liked: false })).toBeVisible({
1185
+ timeout: 1e4
1186
+ });
1187
+ if (prompt.like) {
1188
+ await getFilterLikedButton({ liked: false }).click();
1189
+ await test.expect(await getLastAgentMessage()).not.toBeVisible({
1190
+ timeout: 8e3
1191
+ });
1192
+ await getFilterLikedButton({ liked: true }).click();
1193
+ await test.expect(await getLastAgentMessage()).toBeVisible({
1194
+ timeout: 8e3
1195
+ });
1196
+ await likeButton.click();
1197
+ await wait(4e3);
1198
+ await getFilterLikedButton({ liked: false }).click();
1199
+ const unlikeButton = (await getLastAgentMessage()).locator(
1200
+ "[data-testid=unlike-button]"
1201
+ );
1202
+ await test.expect(unlikeButton).toBeVisible({
1203
+ timeout: 8e3
1204
+ });
1205
+ await unlikeButton.click();
1206
+ await test.expect(await getLastAgentMessage()).not.toBeVisible({
1207
+ timeout: 8e3
1208
+ });
1209
+ await getFilterLikedButton({ liked: true }).click();
1210
+ await test.expect(await getLastAgentMessage()).toBeVisible({
1211
+ timeout: 8e3
1212
+ });
1213
+ await getFilterLikedButton({ liked: false }).click();
1214
+ await test.expect(await getLastAgentMessage()).not.toBeVisible({
1215
+ timeout: 8e3
1216
+ });
1217
+ await getFilterLikedButton({ liked: true }).click();
1218
+ await wait(4e3);
1219
+ }
1220
+ if (prompt.model) {
1221
+ credits -= getModelCredits(prompt.model);
1222
+ if (prompt.debateAgent) {
1223
+ credits -= getModelCredits(prompt.debateAgent);
1224
+ }
1225
+ }
1226
+ page.getByTestId("hourly-limit-info");
1227
+ if (hourlyLimit - hourlyUsage === 0) {
1228
+ willFail = true;
1229
+ return;
1230
+ }
1231
+ const hourlyUsageLeft = await getHourlyUsageLeft();
1232
+ test.expect(hourlyUsageLeft).toBe((hourlyLimit - hourlyUsage).toString());
1233
+ const creditsLeft = await getCreditsLeft();
1234
+ if (creditsLeft !== null) {
1235
+ test.expect(creditsLeft).toBe(credits.toString());
1236
+ console.log(
1237
+ `\u2705 Credits assertion: ${creditsLeft} left (expected: ${credits})`
1238
+ );
1239
+ }
1240
+ if (prompt.model === "flux") {
1241
+ const imageGenerationButton = page.getByTestId(
1242
+ "image-generation-button"
1243
+ );
1244
+ await imageGenerationButton.click();
1245
+ await test.expect.poll(getAgentName, { timeout: 5e3 }).not.toBe("flux");
1246
+ const expectedDefaultAgent = !isMember ? "deepSeek" : "chatGPT";
1247
+ test.expect(await getAgentName()).toBe(expectedDefaultAgent);
1248
+ await imageGenerationButton.click();
1249
+ await test.expect.poll(getAgentName, { timeout: 5e3 }).toBe("flux");
1250
+ await imageGenerationButton.click();
1251
+ await page.waitForTimeout(2e3);
1252
+ test.expect(await getAgentName()).toBe(!isMember ? "deepSeek" : "chatGPT");
1253
+ }
1254
+ }
1255
+ if (prompt.delete) {
1256
+ await deleteMessageButton.click();
1257
+ await wait(200);
1258
+ await deleteMessageButton.click();
1259
+ await wait(4e3);
1260
+ await test.expect(deleteMessageButton).not.toBeVisible();
1261
+ }
1262
+ }
1263
+ const getNthMenuThread = async (nth) => {
1264
+ const threads = page.getByTestId("menu-thread-item");
1265
+ await threads.count();
1266
+ return threads.nth(nth);
1267
+ };
1268
+ const getFirstMenuThread = async () => {
1269
+ return getNthMenuThread(0);
1270
+ };
1271
+ if (bookmark) {
1272
+ (await getFirstMenuThread()).hover();
1273
+ const bookmarkButton = page.getByTestId("thread-not-bookmarked");
1274
+ await test.expect(bookmarkButton).toBeVisible();
1275
+ await bookmarkButton.click();
1276
+ const menuBookmarked = page.getByTestId("menu-bookmarked");
1277
+ await test.expect(menuBookmarked).toBeVisible({
1278
+ timeout: 1e4
1279
+ });
1280
+ await menuBookmarked.click();
1281
+ const threadNotBookmarked = page.getByTestId("thread-not-bookmarked");
1282
+ await test.expect(threadNotBookmarked).toBeVisible({
1283
+ timeout: 1e4
1284
+ });
1285
+ (await getFirstMenuThread()).hover();
1286
+ const menuNotBookmarked = page.getByTestId("menu-not-bookmarked");
1287
+ await test.expect(menuNotBookmarked).toBeVisible();
1288
+ await threadNotBookmarked.click();
1289
+ await wait(2e3);
1290
+ }
1291
+ if (isNewChat) {
1292
+ await page.getByTestId("new-chat-button").click();
1293
+ await wait(5e3);
1294
+ await test.expect(
1295
+ isMember ? page.getByTestId("user-message") : page.getByTestId("guest-message")
1296
+ ).not.toBeVisible({
1297
+ timeout: 5e3
1298
+ });
1299
+ }
1300
+ };
1301
+ var signIn = async ({
1302
+ page,
1303
+ isOpened = false,
1304
+ signOut = false,
1305
+ register = false,
1306
+ email = process.env.VEX_TEST_EMAIL_2,
1307
+ password = process.env.VEX_TEST_PASSWORD_2
1308
+ }) => {
1309
+ const signInButton = page.getByTestId("login-button");
1310
+ if (!isOpened) {
1311
+ await test.expect(signInButton).toBeVisible({
1312
+ timeout: 15e3
1313
+ });
1314
+ await signInButton.click();
1315
+ }
1316
+ page.url().includes("extension");
1317
+ const modal = page.getByTestId("sign-in-modal");
1318
+ await test.expect(modal).toBeVisible();
1319
+ const emailInput = page.getByTestId("sign-in-email");
1320
+ await test.expect(emailInput).toBeVisible();
1321
+ await emailInput.fill(email);
1322
+ const passwordInput = page.getByTestId("sign-in-password");
1323
+ await test.expect(passwordInput).toBeVisible();
1324
+ await passwordInput.fill(password);
1325
+ await wait(2e3);
1326
+ const signInSubmit = page.getByTestId("login-submit");
1327
+ await test.expect(signInSubmit).toBeVisible();
1328
+ await signInSubmit.click({
1329
+ force: true
1330
+ });
1331
+ if (!!process.env.CI) {
1332
+ await page.waitForFunction(
1333
+ () => {
1334
+ const submitButton = document.querySelector(
1335
+ '[data-testid="login-submit"]'
1336
+ );
1337
+ return submitButton && submitButton.hasAttribute("data-redirect-url");
1338
+ },
1339
+ { timeout: 15e3 }
1340
+ );
1341
+ const redirectUrl = await signInSubmit.getAttribute("data-redirect-url");
1342
+ if (!redirectUrl) {
1343
+ throw new Error("Redirect URL not found");
1344
+ }
1345
+ await page.goto(redirectUrl);
1346
+ }
1347
+ await wait(4e3);
1348
+ await test.expect(signInButton).not.toBeVisible();
1349
+ const accountButton = page.getByTestId("account-button");
1350
+ await test.expect(accountButton).toBeVisible();
1351
+ if (signOut) {
1352
+ await accountButton.click();
1353
+ const email2 = page.getByTestId("account-email");
1354
+ await test.expect(email2).toBeVisible();
1355
+ const logoutButton = page.getByTestId("account-logout-button");
1356
+ await test.expect(logoutButton).toBeVisible();
1357
+ await logoutButton.click();
1358
+ await test.expect(signInButton).toBeVisible({
1359
+ timeout: 15e3
1360
+ });
1361
+ }
1362
+ };
1363
+
1364
+ // src/collaboration.ts
1365
+ async function collaboration({
1366
+ page,
1367
+ isLive = false,
1368
+ isMember = false,
1369
+ browser,
1370
+ withShareLink = true,
1371
+ fingerprint,
1372
+ collaborate = "feedbackwallet@gmail.com"
1373
+ }) {
1374
+ const TEST_URL2 = getURL({
1375
+ fingerprint,
1376
+ isLive,
1377
+ isMember
1378
+ });
1379
+ const getMemberUrl = (path2) => getURL({
1380
+ isLive,
1381
+ isMember: true,
1382
+ path: path2
1383
+ });
1384
+ const context1 = await browser.newContext();
1385
+ const page1 = page;
1386
+ await page1.goto(TEST_URL2, { waitUntil: "networkidle" });
1387
+ await chat({
1388
+ bookmark: false,
1389
+ page: page1,
1390
+ isNewChat: false,
1391
+ isMember,
1392
+ instruction: "Let's plan a trip together",
1393
+ prompts: [
1394
+ {
1395
+ text: "I want to visit Japan. What should I know?",
1396
+ model: "deepSeek"
1397
+ }
1398
+ ]
1399
+ });
1400
+ await page1.waitForTimeout(2e3);
1401
+ const threadUrl = page1.url();
1402
+ const threadId = threadUrl.split("/threads/")[1]?.split("?")[0];
1403
+ test.expect(threadId).toBeTruthy();
1404
+ console.log("Thread:", threadId);
1405
+ const threadShareButton = page1.getByTestId("thread-share-button");
1406
+ test.expect(threadShareButton).toBeVisible();
1407
+ const chatShareButton = page1.getByTestId("chat-share-button");
1408
+ await chatShareButton.click();
1409
+ await wait(1e3);
1410
+ const chatCollaborateButton = page1.getByTestId("chat-collaborate-button");
1411
+ test.expect(chatCollaborateButton).toBeVisible();
1412
+ await chatCollaborateButton.click();
1413
+ await wait(1e3);
1414
+ const shareInput = page1.getByTestId("chat-share-input");
1415
+ await test.expect(shareInput).toHaveValue(threadUrl);
1416
+ const shareCopyButton = page1.getByTestId("chat-share-copy-button");
1417
+ test.expect(shareCopyButton).toBeVisible();
1418
+ await shareCopyButton.click();
1419
+ await wait(1e3);
1420
+ const collaborateInput = page1.getByTestId("chat-collaborate-input");
1421
+ test.expect(collaborateInput).toBeVisible();
1422
+ await collaborateInput.fill("iliyan@chrry.ai");
1423
+ const collaborateAddButton = page1.getByTestId("chat-collaborate-add-button");
1424
+ await collaborateAddButton.click();
1425
+ const collaborateName = page1.getByTestId("chat-collaborator-name");
1426
+ await test.expect(collaborateName).toBeVisible({
1427
+ timeout: 8e3
1428
+ });
1429
+ const collaborateEmail = page1.getByTestId("chat-collaborator-email");
1430
+ await test.expect(collaborateEmail).toBeVisible();
1431
+ const collaborateStatus = page1.getByTestId("chat-collaborator-status");
1432
+ await test.expect(collaborateStatus).toHaveText("pending");
1433
+ const collaboratorRevokeButton = page1.getByTestId(
1434
+ "chat-collaborator-revoke-button"
1435
+ );
1436
+ await test.expect(collaboratorRevokeButton).toBeVisible();
1437
+ await collaboratorRevokeButton.click();
1438
+ await wait(1e3);
1439
+ await collaboratorRevokeButton.click();
1440
+ await wait(1e3);
1441
+ await test.expect(collaborateName).not.toBeVisible({
1442
+ timeout: 8e3
1443
+ });
1444
+ await test.expect(collaborateEmail).not.toBeVisible();
1445
+ await collaborateInput.fill(collaborate);
1446
+ await collaborateAddButton.click();
1447
+ await test.expect(collaborateName).toBeVisible({
1448
+ timeout: 8e3
1449
+ });
1450
+ await test.expect(collaborateEmail).toBeVisible();
1451
+ await test.expect(collaborateStatus).toHaveText("pending");
1452
+ await page1.getByTestId("chat-share-modal-close-button").click();
1453
+ await wait(1e3);
1454
+ const chatInput1 = page1.getByTestId("chat-textarea");
1455
+ const context2 = await browser.newContext();
1456
+ const page2 = await context2.newPage();
1457
+ await page2.goto(getMemberUrl(), {
1458
+ waitUntil: "networkidle"
1459
+ });
1460
+ await signIn({ page: page2 });
1461
+ await page2.goto(
1462
+ withShareLink ? `${getMemberUrl(`/threads/${threadId}`)}` : getMemberUrl(),
1463
+ {
1464
+ waitUntil: "networkidle"
1465
+ }
1466
+ );
1467
+ const chatInput2 = page2.getByTestId("chat-textarea");
1468
+ await test.expect(chatInput2).toBeDisabled();
1469
+ const acceptCollaborationButton = page2.getByTestId(
1470
+ "chat-accept-collaboration"
1471
+ );
1472
+ test.expect(acceptCollaborationButton).toBeVisible();
1473
+ const rejectCollaborationButton = page2.getByTestId(
1474
+ "chat-reject-collaboration"
1475
+ );
1476
+ test.expect(rejectCollaborationButton).toBeVisible();
1477
+ await acceptCollaborationButton.click();
1478
+ await test.expect(chatInput2).toBeEnabled({
1479
+ timeout: 8e3
1480
+ });
1481
+ await chat({
1482
+ page: page2,
1483
+ isNewChat: false,
1484
+ threadId,
1485
+ isMember: true,
1486
+ // Member user (signed in)
1487
+ prompts: [
1488
+ {
1489
+ text: "I've been to Tokyo before! The cherry blossoms are amazing in spring.",
1490
+ model: "deepSeek"
1491
+ }
1492
+ ]
1493
+ });
1494
+ await page1.bringToFront();
1495
+ await page1.waitForTimeout(3e3);
1496
+ const messages1 = page1.getByTestId("message");
1497
+ const count1 = await messages1.count();
1498
+ test.expect(count1).toBeGreaterThanOrEqual(3);
1499
+ await chat({
1500
+ page: page1,
1501
+ isNewChat: false,
1502
+ threadId,
1503
+ isMember,
1504
+ creditsConsumed: 1,
1505
+ prompts: [
1506
+ {
1507
+ text: "That's great! When is the best time to see cherry blossoms?",
1508
+ model: "deepSeek"
1509
+ }
1510
+ ]
1511
+ });
1512
+ await page2.bringToFront();
1513
+ await page2.waitForTimeout(3e3);
1514
+ const messages2 = page2.getByTestId("message");
1515
+ const count2 = await messages2.count();
1516
+ test.expect(count2).toBeGreaterThanOrEqual(5);
1517
+ await page1.bringToFront();
1518
+ await chatInput1.click();
1519
+ await chatInput1.fill("I'm typing...");
1520
+ await page2.bringToFront();
1521
+ await page2.waitForTimeout(2e3);
1522
+ test.expect(
1523
+ await page2.getByTestId("typing-indicator").count()
1524
+ ).toBeGreaterThanOrEqual(1);
1525
+ await page2.waitForTimeout(5e3);
1526
+ test.expect(await page2.getByTestId("typing-indicator").count()).toBe(0);
1527
+ await chatInput2.click();
1528
+ await chatInput2.fill("I'm typing too...");
1529
+ await page1.bringToFront();
1530
+ await page1.waitForTimeout(2e3);
1531
+ test.expect(
1532
+ await page1.getByTestId("typing-indicator").count()
1533
+ ).toBeGreaterThanOrEqual(1);
1534
+ await page1.waitForTimeout(3e3);
1535
+ test.expect(await page1.getByTestId("typing-indicator").count()).toBe(0);
1536
+ await context1.close();
1537
+ await context2.close();
1538
+ }
1539
+ var limit = async ({
1540
+ page,
1541
+ isMember,
1542
+ isSubscriber
1543
+ }) => {
1544
+ const hourlyLimit = isSubscriber ? 100 : isMember ? 30 : 10;
1545
+ console.log(
1546
+ `\u{1F3AF} Testing hourly limit: ${hourlyLimit} requests for ${isMember ? "member" : "guest"}`
1547
+ );
1548
+ const limitPrompts = Array.from({ length: hourlyLimit }, (_, i) => {
1549
+ const isFluxMessage = i % (isMember ? 5 : 3) === 0;
1550
+ const isClaudeMessage = isMember && i % 5 === 0;
1551
+ const isChatGPTMessage = isMember && i % 3 === 0;
1552
+ const isWebSearch = (isClaudeMessage || isChatGPTMessage) && !isFluxMessage && i % 2 === 0;
1553
+ const like = isWebSearch || isFluxMessage ? true : false;
1554
+ return {
1555
+ text: isFluxMessage ? `Create a beautiful ${faker.faker.color.human()} ${faker.faker.animal.type()} in a ${faker.faker.location.city()} setting, digital art style` : i === hourlyLimit ? `Find latest news about ${faker.faker.company.name()}` : `Test message ${i + 1} - ${faker.faker.lorem.sentence()}`,
1556
+ model: isFluxMessage ? "flux" : isClaudeMessage ? "claude" : isChatGPTMessage ? "chatGPT" : "deepSeek",
1557
+ agentMessageTimeout: isFluxMessage ? 6e4 : 3e4,
1558
+ // Flux needs more time
1559
+ webSearch: isWebSearch,
1560
+ shouldFail: i === hourlyLimit,
1561
+ // Only fail on last message
1562
+ like
1563
+ };
1564
+ });
1565
+ const failPrompt = {
1566
+ text: "This message should fail due to hourly limit",
1567
+ model: "deepSeek",
1568
+ agentMessageTimeout: 3e4,
1569
+ shouldFail: true,
1570
+ // Flag to indicate this should fail
1571
+ webSearch: true
1572
+ // Test web search on the failing request too
1573
+ };
1574
+ await chat({
1575
+ isNewChat: true,
1576
+ page,
1577
+ isMember,
1578
+ instruction: `Testing hourly limit of ${hourlyLimit} requests`,
1579
+ prompts: [...limitPrompts, failPrompt]
1580
+ });
1581
+ };
1582
+ var thread = async ({
1583
+ page,
1584
+ isMember,
1585
+ bookmark,
1586
+ createChat = true
1587
+ }) => {
1588
+ createChat && await chat({
1589
+ bookmark,
1590
+ isNewChat: true,
1591
+ page,
1592
+ isMember,
1593
+ instruction: "Help me write a short story",
1594
+ prompts: Array.from({ length: 3 }, (_, i) => {
1595
+ return {
1596
+ text: `Test message ${i + 1} - ${faker.faker.lorem.sentence()}`,
1597
+ model: "deepSeek",
1598
+ agentMessageTimeout: 3e4
1599
+ };
1600
+ })
1601
+ });
1602
+ const getNthThread = async (nth) => {
1603
+ const threads = page.getByTestId("threads-item");
1604
+ await threads.count();
1605
+ return threads.nth(nth);
1606
+ };
1607
+ const getFirstThread = async () => {
1608
+ return getNthThread(0);
1609
+ };
1610
+ const getSecondThread = async () => {
1611
+ return getNthThread(1);
1612
+ };
1613
+ const threadsContainer = page.getByTestId("threads-container");
1614
+ const loadMore = page.getByTestId("load-more-threads-menu");
1615
+ if (createChat) {
1616
+ await test.expect(loadMore).toBeVisible();
1617
+ await loadMore.click();
1618
+ await wait(5e3);
1619
+ }
1620
+ await test.expect(
1621
+ (await getFirstThread()).getByTestId("threads-bookmarked")
1622
+ ).toBeVisible({
1623
+ timeout: 15e3
1624
+ });
1625
+ await test.expect(
1626
+ (await getFirstThread()).getByTestId("threads-not-bookmarked")
1627
+ ).not.toBeVisible({
1628
+ timeout: 15e3
1629
+ });
1630
+ const threadsCount = page.getByTestId("threads-item");
1631
+ const count = await threadsCount.count();
1632
+ createChat ? test.expect(count).toBe(1) : test.expect(count).toBe(2);
1633
+ await test.expect(threadsContainer).toBeVisible();
1634
+ const search = page.getByTestId("threads-search");
1635
+ await test.expect(search).toBeVisible();
1636
+ const threadsCollaboration = page.getByTestId("threads-collaboration");
1637
+ await test.expect(threadsCollaboration).toBeVisible();
1638
+ const threadsSortButtonDate = page.getByTestId("threads-sort-button-date");
1639
+ await test.expect(threadsSortButtonDate).toBeVisible();
1640
+ await threadsSortButtonDate.click();
1641
+ const threadsSortButton = page.getByTestId("threads-sort-button-star");
1642
+ await test.expect(threadsSortButton).toBeVisible();
1643
+ await threadsSortButton.click();
1644
+ const editThreadButton = (await getFirstThread()).getByTestId(
1645
+ "edit-thread-button"
1646
+ );
1647
+ await test.expect(editThreadButton).toBeVisible();
1648
+ await editThreadButton.click();
1649
+ const editThreadTextarea = page.getByTestId("edit-thread-textarea");
1650
+ await editThreadTextarea.fill("New thread title");
1651
+ const editThreadSaveButton = page.getByTestId("edit-thread-save-button");
1652
+ await test.expect(editThreadSaveButton).toBeVisible();
1653
+ await editThreadSaveButton.click();
1654
+ const threadTitle = threadsContainer.getByText("New thread title");
1655
+ await test.expect(threadTitle).toBeVisible();
1656
+ await editThreadButton.click();
1657
+ const editThreadGenerateTitleButton = page.getByTestId(
1658
+ "edit-thread-generate-title-button"
1659
+ );
1660
+ await test.expect(editThreadGenerateTitleButton).toBeVisible();
1661
+ await editThreadGenerateTitleButton.click();
1662
+ await wait(2e3);
1663
+ await editThreadSaveButton.click();
1664
+ await wait(2e3);
1665
+ await test.expect(threadTitle).not.toBeVisible();
1666
+ const threadTitleGenerated2 = (await getFirstThread()).getByTestId(
1667
+ "threads-item-title"
1668
+ );
1669
+ await test.expect(threadTitleGenerated2).toBeVisible();
1670
+ const newTitle = await threadTitleGenerated2.textContent();
1671
+ if (!newTitle) {
1672
+ throw new Error("Thread title not found");
1673
+ }
1674
+ await editThreadButton.click();
1675
+ const deleteThreadButton = page.getByTestId("delete-thread-button");
1676
+ await test.expect(deleteThreadButton).toBeVisible();
1677
+ await deleteThreadButton.click();
1678
+ await wait(1e3);
1679
+ await deleteThreadButton.click();
1680
+ await wait(3e3);
1681
+ await test.expect(threadsContainer).toBeVisible();
1682
+ await test.expect(page.getByText(newTitle)).not.toBeVisible();
1683
+ if (createChat) {
1684
+ await chat({
1685
+ isNewChat: true,
1686
+ page,
1687
+ isMember,
1688
+ instruction: "Help me write a short story",
1689
+ bookmark,
1690
+ prompts: Array.from({ length: 3 }, (_, i) => {
1691
+ return {
1692
+ text: `Test message ${i + 1} - ${faker.faker.lorem.sentence()}`,
1693
+ model: "deepSeek",
1694
+ agentMessageTimeout: 3e4
1695
+ };
1696
+ })
1697
+ });
1698
+ const menuHomeButton = page.getByTestId("menu-home-button");
1699
+ await test.expect(menuHomeButton).toBeVisible();
1700
+ await menuHomeButton.click();
1701
+ await wait(3e3);
1702
+ await chat({
1703
+ isNewChat: false,
1704
+ creditsConsumed: 3,
1705
+ bookmark: false,
1706
+ page,
1707
+ isMember,
1708
+ instruction: "Help me write a short story",
1709
+ prompts: Array.from({ length: 3 }, (_, i) => {
1710
+ return {
1711
+ text: `Test message ${i + 1} - ${faker.faker.lorem.sentence()}`,
1712
+ model: "deepSeek",
1713
+ agentMessageTimeout: 3e4
1714
+ };
1715
+ })
1716
+ });
1717
+ await loadMore.click();
1718
+ await wait(1e3);
1719
+ await test.expect(
1720
+ (await getFirstThread()).getByTestId("threads-bookmarked")
1721
+ ).not.toBeVisible();
1722
+ await (await getFirstThread()).getByTestId("threads-not-bookmarked").click();
1723
+ await wait(1e3);
1724
+ await test.expect(
1725
+ (await getSecondThread()).getByTestId("threads-bookmarked")
1726
+ ).toBeVisible();
1727
+ await test.expect(
1728
+ (await getSecondThread()).getByTestId("threads-not-bookmarked")
1729
+ ).not.toBeVisible();
1730
+ await thread({
1731
+ page,
1732
+ isMember,
1733
+ createChat: false
1734
+ });
1735
+ }
1736
+ };
1737
+
1738
+ exports.LIVE_URL = LIVE_URL;
1739
+ exports.TEST_GUEST_FINGERPRINTS = TEST_GUEST_FINGERPRINTS;
1740
+ exports.TEST_MEMBER_EMAILS = TEST_MEMBER_EMAILS;
1741
+ exports.TEST_MEMBER_FINGERPRINTS = TEST_MEMBER_FINGERPRINTS;
1742
+ exports.TEST_URL = TEST_URL;
1743
+ exports.VEX_TEST_EMAIL = VEX_TEST_EMAIL;
1744
+ exports.VEX_TEST_EMAIL_2 = VEX_TEST_EMAIL_2;
1745
+ exports.VEX_TEST_EMAIL_3 = VEX_TEST_EMAIL_3;
1746
+ exports.VEX_TEST_FINGERPRINT = VEX_TEST_FINGERPRINT;
1747
+ exports.VEX_TEST_FINGERPRINT_2 = VEX_TEST_FINGERPRINT_2;
1748
+ exports.VEX_TEST_FINGERPRINT_3 = VEX_TEST_FINGERPRINT_3;
1749
+ exports.VEX_TEST_PASSWORD = VEX_TEST_PASSWORD;
1750
+ exports.VEX_TEST_PASSWORD_2 = VEX_TEST_PASSWORD_2;
1751
+ exports.VEX_TEST_PASSWORD_3 = VEX_TEST_PASSWORD_3;
1752
+ exports.capitalizeFirstLetter = capitalizeFirstLetter;
1753
+ exports.chat = chat;
1754
+ exports.collaboration = collaboration;
1755
+ exports.getURL = getURL;
1756
+ exports.isCI = isCI;
1757
+ exports.limit = limit;
1758
+ exports.signIn = signIn;
1759
+ exports.simulateInputPaste = simulateInputPaste;
1760
+ exports.simulatePaste = simulatePaste;
1761
+ exports.thread = thread;
1762
+ exports.wait = wait;
1763
+ //# sourceMappingURL=index.js.map
1764
+ //# sourceMappingURL=index.js.map