darabos commited on
Commit
486cb5c
·
1 Parent(s): 4106710

It is still unreliable. Restore the retry loop.

Browse files
Files changed (1) hide show
  1. lynxkite-app/web/tests/lynxkite.ts +12 -3
lynxkite-app/web/tests/lynxkite.ts CHANGED
@@ -126,19 +126,28 @@ export class Workspace {
126
  await this.page.mouse.up();
127
  }
128
 
129
- async connectBoxes(sourceId: string, targetId: string) {
130
  const sourceHandle = this.getBoxHandle(sourceId, "right");
131
  const targetHandle = this.getBoxHandle(targetId, "left");
132
  await expect(sourceHandle).toBeVisible();
133
  await expect(targetHandle).toBeVisible();
134
  await sourceHandle.hover();
135
  await this.page.mouse.down();
136
- await expect(this.page.locator(".react-flow__connectionline")).toBeAttached();
137
  await targetHandle.hover();
138
  await this.page.mouse.up();
139
  await expect(
140
  this.page.locator(`.react-flow__edge[aria-label="Edge from ${sourceId} to ${targetId}"]`),
141
- ).toBeAttached();
 
 
 
 
 
 
 
 
 
142
  }
143
 
144
  async execute() {
 
126
  await this.page.mouse.up();
127
  }
128
 
129
+ async tryToConnectBoxes(sourceId: string, targetId: string) {
130
  const sourceHandle = this.getBoxHandle(sourceId, "right");
131
  const targetHandle = this.getBoxHandle(targetId, "left");
132
  await expect(sourceHandle).toBeVisible();
133
  await expect(targetHandle).toBeVisible();
134
  await sourceHandle.hover();
135
  await this.page.mouse.down();
136
+ await expect(this.page.locator(".react-flow__connectionline")).toBeAttached({ timeout: 1000 });
137
  await targetHandle.hover();
138
  await this.page.mouse.up();
139
  await expect(
140
  this.page.locator(`.react-flow__edge[aria-label="Edge from ${sourceId} to ${targetId}"]`),
141
+ ).toBeAttached({ timeout: 1000 });
142
+ }
143
+ async connectBoxes(sourceId: string, targetId: string) {
144
+ // The method above is unreliable. I gave up after a lot of debugging and added these retries.
145
+ while (true) {
146
+ try {
147
+ await this.tryToConnectBoxes(sourceId, targetId);
148
+ return;
149
+ } catch (e) {}
150
+ }
151
  }
152
 
153
  async execute() {