-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
Copy pathgeneralBugs-shard-9.spec.ts
147 lines (110 loc) · 4.52 KB
/
generalBugs-shard-9.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";
import { addLegacyComponents } from "../../utils/add-legacy-components";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
import { initialGPTsetup } from "../../utils/initialGPTsetup";
test(
"memory should work as expect",
{ tag: ["@release"] },
async ({ page }) => {
test.skip(
!process?.env?.OPENAI_API_KEY,
"OPENAI_API_KEY required to run this test",
);
if (!process.env.CI) {
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
}
await awaitBootstrapTest(page);
await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page.waitForSelector('[data-testid="fit_view"]', {
timeout: 2000,
});
await page.getByTestId("fit_view").click();
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("message history");
await addLegacyComponents(page);
// Locate the canvas element
const canvas = page.locator("#react-flow-id"); // Update the selector if needed
// Get the bounding box of the canvas to determine its position
const canvasBox = await canvas.boundingBox();
if (!canvasBox) {
throw new Error("Canvas element bounding box not found");
}
// Starting point (center of the canvas)
const startX = canvasBox.x + canvasBox.width / 2;
const startY = canvasBox.y + canvasBox.height / 2;
// End point (move 600 pixels to the right)
const endX = startX + 600;
const endY = startY;
// Hover over the canvas to focus it
await canvas.hover();
// Start the drag operation
await page.mouse.move(startX, startY);
await page.mouse.down();
// Move to the new position
await page.mouse.move(endX, endY);
// Release the mouse button to finish the drag
await page.mouse.up();
await page
.getByTestId("helpersMessage History")
.first()
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
targetPosition: { x: 200, y: 600 },
});
await initialGPTsetup(page, {
skipAdjustScreenView: true,
});
const prompt = `
{context}
User: {user_input}
AI:
`;
await page.getByTestId("title-Prompt").last().click();
await page.getByTestId("button_open_prompt_modal").nth(0).click();
await page.getByTestId("modal-promptarea_prompt_template").fill(prompt);
await page.getByText("Edit Prompt", { exact: true }).click();
await page.getByText("Check & Save").last().click();
await page.getByTestId("fit_view").click();
//connection 1
const elementChatMemoryOutput = await page
.getByTestId("handle-memory-shownode-message-right")
.first();
await elementChatMemoryOutput.hover();
await page.mouse.down();
const promptInput = await page.getByTestId(
"handle-prompt-shownode-context-left",
);
await promptInput.hover();
await page.mouse.up();
await page.locator('//*[@id="react-flow-id"]').hover();
await page.getByText("Playground", { exact: true }).last().click();
await page.waitForSelector('[data-testid="button-send"]', {
timeout: 100000,
});
await page
.getByPlaceholder("Send a message...")
.fill("hi, my car is blue and I like to eat pizza");
await page.getByTestId("button-send").click();
await page.waitForSelector("text=AI", { timeout: 30000 });
await page
.getByPlaceholder("Send a message...")
.fill("what color is my car and what do I like to eat?");
await page.getByTestId("button-send").click();
await page.waitForSelector("text=AI", { timeout: 30000 });
await page.waitForSelector('[data-testid="div-chat-message"]', {
timeout: 100000,
});
// Wait for the first chat message element to be available
const firstChatMessage = page.getByTestId("div-chat-message").nth(0);
await firstChatMessage.waitFor({ state: "visible", timeout: 10000 });
// Get the text from the second message (the response to the question about car color and food)
const secondChatMessage = page.getByTestId("div-chat-message").nth(1);
await secondChatMessage.waitFor({ state: "visible", timeout: 10000 });
const memoryResponseText = await secondChatMessage.textContent();
expect(memoryResponseText).not.toBeNull();
expect(memoryResponseText?.includes("pizza")).toBeTruthy();
expect(memoryResponseText?.includes("blue")).toBeTruthy();
},
);