Skip to content

Commit f9c62ec

Browse files
CopilotLipata
andcommitted
Fix flickering test: Use retry logic instead of fixed delays in custom-strategy test
Co-authored-by: Lipata <[email protected]>
1 parent 9d52053 commit f9c62ec

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

projects/igniteui-angular-elements/src/app/custom-strategy.spec.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,31 @@ describe('Elements: ', () => {
4848
const columnEl = document.createElement("igc-column") as IgcNgElement;
4949
gridEl.appendChild(columnEl);
5050

51-
// TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
52-
await firstValueFrom(timer(10 /* SCHEDULE_DELAY */ * 2));
53-
51+
// Wait for both components to be fully initialized
5452
const gridComponent = (await gridEl.ngElementStrategy[ComponentRefKey]).instance as IgxGridComponent;
5553
const columnComponent = (await columnEl.ngElementStrategy[ComponentRefKey]).instance as IgxColumnComponent;
54+
55+
// Wait for the grid's columnList to contain the column component with retry logic
56+
let retries = 0;
57+
const maxRetries = 10;
58+
const retryDelay = 10;
59+
60+
while (retries < maxRetries && !gridComponent.columnList.toArray().includes(columnComponent)) {
61+
await firstValueFrom(timer(retryDelay));
62+
retries++;
63+
}
64+
5665
expect(gridComponent.columnList.toArray()).toContain(columnComponent);
5766

5867
columnEl.remove();
59-
await firstValueFrom(timer(10 /* SCHEDULE_DELAY: DESTROY + QUERY */ * 3));
68+
69+
// Wait for the column to be removed from the columnList with retry logic
70+
retries = 0;
71+
while (retries < maxRetries && gridComponent.columnList.toArray().includes(columnComponent)) {
72+
await firstValueFrom(timer(retryDelay));
73+
retries++;
74+
}
75+
6076
expect(gridComponent.columnList.toArray()).toEqual([]);
6177
});
6278

0 commit comments

Comments
 (0)