@chrryai/waffles 1.2.80 → 1.2.84

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