Skip to content

Commit 42eb5f4

Browse files
committed
✨ (stop-building.spec.ts): Add new utility functions to improve code modularity and readability
🔧 (stop-building.spec.ts): Refactor drag and drop operations to use utility functions for better maintainability 🔧 (stop-building.spec.ts): Refactor zoom out operations to use utility function for consistency 🔧 (stop-building.spec.ts): Refactor component positioning operations to use utility functions for clarity 🔧 (stop-building.spec.ts): Refactor outdated components and filled API keys handling to use utility functions for reusability 🔧 (stop-building.spec.ts): Refactor fit view operation to use utility function for consistency
1 parent 925b417 commit 42eb5f4

File tree

1 file changed

+18
-72
lines changed

1 file changed

+18
-72
lines changed

src/frontend/tests/core/features/stop-building.spec.ts

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { test } from "@playwright/test";
22
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
3-
3+
import { removeOldApiKeys } from "../../utils/remove-old-api-keys";
4+
import { updateOldComponents } from "../../utils/update-old-components";
5+
import { zoomOut } from "../../utils/zoom-out";
46
// TODO: fix this test
57
test(
68
"user must be able to stop a building",
@@ -16,18 +18,11 @@ test(
1618

1719
await page
1820
.getByTestId("inputsText Input")
19-
.dragTo(page.locator('//*[@id="react-flow-id"]'));
20-
21-
await page.getByTestId("zoom_out").click();
22-
await page
23-
.locator('//*[@id="react-flow-id"]')
24-
.hover()
25-
.then(async () => {
26-
await page.mouse.down();
27-
await page.mouse.move(-800, 300);
21+
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
22+
targetPosition: { x: 0, y: 0 },
2823
});
2924

30-
await page.mouse.up();
25+
await zoomOut(page, 3);
3126

3227
//second component
3328

@@ -36,97 +31,50 @@ test(
3631

3732
await page
3833
.getByTestId("dataURL")
39-
.dragTo(page.locator('//*[@id="react-flow-id"]'));
40-
41-
await page.getByTestId("zoom_out").click();
42-
await page
43-
.locator('//*[@id="react-flow-id"]')
44-
.hover()
45-
.then(async () => {
46-
await page.mouse.down();
47-
await page.mouse.move(-800, 300);
34+
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
35+
targetPosition: { x: 100, y: 200 },
4836
});
4937

50-
await page.mouse.up();
51-
5238
//third component
5339

5440
await page.getByTestId("sidebar-search-input").click();
5541
await page.getByTestId("sidebar-search-input").fill("split text");
5642

5743
await page
5844
.getByTestId("processingSplit Text")
59-
.dragTo(page.locator('//*[@id="react-flow-id"]'));
60-
61-
await page.getByTestId("zoom_out").click();
62-
await page
63-
.locator('//*[@id="react-flow-id"]')
64-
.hover()
65-
.then(async () => {
66-
await page.mouse.down();
67-
await page.mouse.move(-800, 300);
45+
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
46+
targetPosition: { x: 300, y: 300 },
6847
});
6948

70-
await page.mouse.up();
71-
7249
//fourth component
7350

7451
await page.getByTestId("sidebar-search-input").click();
7552
await page.getByTestId("sidebar-search-input").fill("parse data");
7653

7754
await page
7855
.getByTestId("processingParse Data")
79-
.dragTo(page.locator('//*[@id="react-flow-id"]'));
80-
81-
await page.getByTestId("zoom_out").click();
82-
await page
83-
.locator('//*[@id="react-flow-id"]')
84-
.hover()
85-
.then(async () => {
86-
await page.mouse.down();
87-
await page.mouse.move(-800, 300);
56+
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
57+
targetPosition: { x: 100, y: 400 },
8858
});
8959

90-
await page.mouse.up();
91-
9260
//fifth component
9361

9462
await page.getByTestId("sidebar-search-input").click();
9563
await page.getByTestId("sidebar-search-input").fill("chat output");
9664

9765
await page
9866
.getByTestId("outputsChat Output")
99-
.dragTo(page.locator('//*[@id="react-flow-id"]'));
100-
101-
await page.getByTestId("zoom_out").click();
102-
await page
103-
.locator('//*[@id="react-flow-id"]')
104-
.hover()
105-
.then(async () => {
106-
await page.mouse.down();
107-
await page.mouse.move(-800, 300);
67+
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
68+
targetPosition: { x: 600, y: 300 },
10869
});
10970

110-
await page.mouse.up();
111-
112-
let outdatedComponents = await page
113-
.getByTestId("icon-AlertTriangle")
114-
.count();
115-
116-
while (outdatedComponents > 0) {
117-
await page.getByTestId("icon-AlertTriangle").first().click();
118-
outdatedComponents = await page.getByTestId("icon-AlertTriangle").count();
119-
}
120-
121-
let filledApiKey = await page.getByTestId("remove-icon-badge").count();
122-
while (filledApiKey > 0) {
123-
await page.getByTestId("remove-icon-badge").first().click();
124-
await page.waitForTimeout(1000);
125-
filledApiKey = await page.getByTestId("remove-icon-badge").count();
126-
}
71+
await updateOldComponents(page);
72+
await removeOldApiKeys(page);
12773

12874
await page.getByTestId("fit_view").click();
12975

76+
await zoomOut(page, 2);
77+
13078
//connection 1
13179
const urlOutput = await page
13280
.getByTestId("handle-url-shownode-data-right")
@@ -151,8 +99,6 @@ test(
15199
await splitTextInput.hover();
152100
await page.mouse.up();
153101

154-
await page.getByTestId("fit_view").click();
155-
156102
//connection 3
157103
const splitTextOutput = await page
158104
.getByTestId("handle-splittext-shownode-chunks-right")

0 commit comments

Comments
 (0)