Skip to content

Commit

Permalink
test: Revert changes and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gondragos committed Mar 5, 2025
1 parent b94c95e commit 59fdfe0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
28 changes: 14 additions & 14 deletions web/libs/editor/tests/integration/e2e/audio/audio_regions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ describe("Audio regions", () => {
LabelStudio.waitForObjectsReady();
AudioView.isReady();

const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

AudioView.clickAtRelative(0.38, 0.5);
const selectedRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const selectedRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

selectedRegionColor.then((color) => {
baseRegionColor.should("not.deep.equal", color);
});
// unselecting
cy.get("body").type("{esc}");
const unselectedRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const unselectedRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);
unselectedRegionColor.then((color) => {
baseRegionColor.should("deep.equal", color);
});
Expand All @@ -38,19 +38,19 @@ describe("Audio regions", () => {
LabelStudio.waitForObjectsReady();
AudioView.isReady();

const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

// moving the cursor
AudioView.seekCurrentTimebox(38);
const activeRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const activeRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

activeRegionColor.then((color) => {
baseRegionColor.should("not.deep.equal", color);
});

// deactivating
AudioView.seekCurrentTimebox(0);
const inactiveRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const inactiveRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

inactiveRegionColor.then((color) => {
baseRegionColor.should("deep.equal", color);
Expand All @@ -67,7 +67,7 @@ describe("Audio regions", () => {
LabelStudio.waitForObjectsReady();
AudioView.isReady();

const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

// highlighting in relations mode
Labels.select("Music");
Expand All @@ -77,7 +77,7 @@ describe("Audio regions", () => {

AudioView.hoverAtRelative(0.4, 0.5);

const highlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const highlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

highlightedRegionColor.then((color) => {
baseRegionColor.should("not.deep.equal", color);
Expand All @@ -86,7 +86,7 @@ describe("Audio regions", () => {
// unhighlighting
AudioView.container.trigger("mouseleave");

const unhighlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const unhighlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

unhighlightedRegionColor.then((color) => {
baseRegionColor.should("deep.equal", color);
Expand All @@ -103,7 +103,7 @@ describe("Audio regions", () => {
LabelStudio.waitForObjectsReady();
AudioView.isReady();

const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const baseRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

// highlighting in relations mode
Labels.select("Music");
Expand All @@ -113,15 +113,15 @@ describe("Audio regions", () => {

AudioView.hoverAtRelative(0.4, 0.5);

const highlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const highlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

highlightedRegionColor.then((color) => {
baseRegionColor.should("not.deep.equal", color);
});

// moving the cursor
AudioView.seekCurrentTimebox(38);
const activeRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const activeRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

activeRegionColor.then((color) => {
baseRegionColor.should("not.deep.equal", color);
Expand All @@ -130,7 +130,7 @@ describe("Audio regions", () => {

// deactivating
AudioView.seekCurrentTimebox(0);
const inactiveRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const inactiveRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

// should still be highlighted
inactiveRegionColor.then((color) => {
Expand All @@ -141,7 +141,7 @@ describe("Audio regions", () => {
// unhighlighting
AudioView.container.trigger("mouseleave");

const unhighlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.85);
const unhighlightedRegionColor = AudioView.getPixelColorRelative(0.36, 0.9);

unhighlightedRegionColor.then((color) => {
baseRegionColor.should("deep.equal", color);
Expand Down
9 changes: 8 additions & 1 deletion web/libs/frontend-test/src/helpers/LSF/AudioView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ export const AudioView = {
isReady() {
LabelStudio.waitForObjectsReady();
this.loadingBar.should("not.exist");
cy.wait(32); // wait for render
/**
* In `AudioUltra` version of the `Audio` tag isReady was missed.
* It's fixed right now, but it was done in the easiest way it could be done.
* In that case, there is still a time gap between setting `isReady` to `true` and getting the last initial draw at the canvas,
* which for now we are going to compensate by waiting approximately 2 frames of render (16 * 2 = 32 milliseconds)
* @todo: remove wait when `isReady` in audio become more precise
*/
cy.wait(32);
},
get playButton() {
return cy.get(`[data-testid="playback-button:play"]`);
Expand Down

0 comments on commit 59fdfe0

Please sign in to comment.