Skip to content

Commit 4a4ed26

Browse files
committed
Fix auto merge consequences
1 parent 53e5a72 commit 4a4ed26

File tree

1 file changed

+116
-5
lines changed

1 file changed

+116
-5
lines changed

web/libs/frontend-test/src/helpers/LSF/VideoView.ts

Lines changed: 116 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,123 @@ class VideoViewHelper extends withMedia(
318318

319319
// Get current frame number from timeline controls
320320
getCurrentFrame() {
321-
return this.framesControl.invoke("text").then((text) => {
322-
const match = text.match(/(\d+) of/);
323-
if (match) {
324-
return Number.parseInt(match[1], 10);
321+
return this.frameCounter.invoke("text").then((text) => Number.parseInt(text.split(" ")[0]));
322+
}
323+
324+
// Wait a couple of animation frames based on requestAnimationFrame pattern
325+
waitForStableState() {
326+
// This ensures React has completed its render cycle
327+
cy.window().then((win) => {
328+
return new Cypress.Promise((resolve) => {
329+
win.requestAnimationFrame(() => {
330+
// Wait one more frame to be extra sure
331+
win.requestAnimationFrame(resolve);
332+
});
333+
});
334+
});
335+
}
336+
337+
// Wait for region by index to be passed to Konva Stage
338+
// Gets region ID from store and checks if it exists in Konva
339+
waitForRegionInKonvaByIndex(regionIndex: number) {
340+
cy.log(`Wait for region at index ${regionIndex} to be available in Konva Stage`);
341+
342+
// First get the region ID from store
343+
cy.window().then((win) => {
344+
const store = (win as any).Htx || (win as any).store;
345+
if (!store?.annotationStore?.selected?.regionStore?.regions) {
346+
cy.log("No regions found in store");
347+
return;
325348
}
326-
throw new Error("Current frame number not found in frames control text");
349+
350+
const regions = store.annotationStore.selected.regionStore.regions;
351+
if (regionIndex >= regions.length) {
352+
cy.log(`Region index ${regionIndex} out of bounds (${regions.length} regions)`);
353+
return;
354+
}
355+
356+
const region = regions[regionIndex];
357+
const regionId = region.id;
358+
359+
cy.log(`Found region ID: ${regionId} for index ${regionIndex}`);
360+
361+
// Now wait for this region in Konva
362+
this.waitForRegionInKonva(regionId);
363+
});
364+
}
365+
366+
// Find specific Konva stage by DOM element and check for region
367+
waitForRegionInKonva(regionId: string) {
368+
cy.log(`Wait for region ${regionId} to be available in Konva Stage`);
369+
370+
cy.window().then((win) => {
371+
this.drawingArea.should(($drawingArea) => {
372+
// Get the specific Konva stage from this DOM element
373+
const drawingArea = $drawingArea[0];
374+
const stage = (win as any).Konva?.stages?.find((stage) => stage.content === drawingArea);
375+
376+
if (!stage) {
377+
throw new Error("Konva stage not found for this canvas");
378+
}
379+
380+
// Find region in this specific stage
381+
const elements = stage.find(`#${regionId}`);
382+
if (!elements || elements.length === 0) {
383+
throw new Error(`Region ${regionId} not found in Konva Stage`);
384+
}
385+
});
386+
});
387+
}
388+
389+
// Check that specific region is NOT in Konva Stage
390+
waitForRegionNotInKonva(regionId: string) {
391+
cy.log(`Wait for region ${regionId} to be NOT available in Konva Stage`);
392+
393+
cy.window().then((win) => {
394+
this.drawingArea.should(($drawingArea) => {
395+
// Get the specific Konva stage from this DOM element
396+
const drawingArea = $drawingArea[0];
397+
const stage = (win as any).Konva?.stages?.find((stage) => stage.content === drawingArea);
398+
399+
if (!stage) {
400+
// No stage means no regions - that's what we want
401+
return;
402+
}
403+
404+
// Find region in this specific stage
405+
const elements = stage.find(`#${regionId}`);
406+
if (elements && elements.length > 0) {
407+
throw new Error(`Region ${regionId} should NOT be in Konva Stage but it was found`);
408+
}
409+
});
410+
});
411+
}
412+
413+
// Check region by index is NOT in Konva Stage
414+
waitForRegionNotInKonvaByIndex(regionIndex: number) {
415+
cy.log(`Wait for region at index ${regionIndex} to be NOT available in Konva Stage`);
416+
417+
// First get the region ID from store
418+
cy.window().then((win) => {
419+
const store = (win as any).Htx || (win as any).store;
420+
if (!store?.annotationStore?.selected?.regionStore?.regions) {
421+
cy.log("No regions found in store - that's expected");
422+
return;
423+
}
424+
425+
const regions = store.annotationStore.selected.regionStore.regions;
426+
if (regionIndex >= regions.length) {
427+
cy.log(`Region index ${regionIndex} out of bounds (${regions.length} regions) - that's expected`);
428+
return;
429+
}
430+
431+
const region = regions[regionIndex];
432+
const regionId = region.id;
433+
434+
cy.log(`Checking that region ID: ${regionId} for index ${regionIndex} is NOT in Konva`);
435+
436+
// Now check this region is NOT in Konva
437+
this.waitForRegionNotInKonva(regionId);
327438
});
328439
}
329440

0 commit comments

Comments
 (0)