Skip to content

chore: BROS-16: Experiments with tests [WIP] #7548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion web/libs/editor/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import configure from "@humansignal/frontend-test/configure";

export default configure();
export default configure((defaultConfig) => ({
...defaultConfig,
e2e: {
...defaultConfig.e2e,
specPattern: "tests/integration/**/*.only.cy.{js,jsx,ts,tsx}",
},
}));
2 changes: 1 addition & 1 deletion web/libs/editor/tests/e2e/codecept.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports.config = {
show: !headless,
restart: "context",
timeout: 60000, // Action timeout after 60 seconds
waitForAction: headless ? 300 : 1200,
waitForAction: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return headless mode

windowSize: "1200x900",
waitForNavigation: "networkidle",
browser: "chromium",
Expand Down
5 changes: 3 additions & 2 deletions web/libs/editor/tests/e2e/fragments/AtAudioView.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = {
I.moveMouse(this._stageBbox.x + x + shiftX, this._stageBbox.y + this._stageBbox.height / 2, 3);
if (shouldRelease === false) return;
I.pressMouseUp();
I.wait(1);
I.wait(0.016);
},

/**
Expand All @@ -73,7 +73,7 @@ module.exports = {
y = y !== undefined ? y : this._stageBbox.height / 2;
I.scrollPageToTop();
I.clickAt(this._stageBbox.x + x, this._stageBbox.y + y);
I.wait(1); // We gotta wait here because clicks on the canvas are not processed immediately
I.wait(0.016); // We gotta wait here because clicks on the canvas are not processed immediately
},

clickAtBeginning() {
Expand Down Expand Up @@ -242,6 +242,7 @@ module.exports = {
this.toggleControlsMenu();
I.clearField(this._volumeInputSelector);
I.fillField(this._volumeInputSelector, value);
I.seeInField(this._volumeInputSelector, value);
this.toggleControlsMenu();
},

Expand Down
9 changes: 6 additions & 3 deletions web/libs/editor/tests/e2e/fragments/AtImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {

setZoom(scale, x, y) {
I.executeScript(Helpers.setZoom, [scale, x, y]);
I.wait(1);
I.wait(0.016);
},

async getZoomProps() {
Expand Down Expand Up @@ -238,8 +238,11 @@ module.exports = {
I.scrollPageToTop();
I.moveMouse(this.stageBBox().x + x, this.stageBBox().y + y);
I.pressMouseDown();
I.wait(0.016);
I.moveMouse(this.stageBBox().x + x + shiftX, this.stageBBox().y + y + shiftY, 3);
I.wait(0.016);
I.pressMouseUp();
I.wait(0.032);
},
/**
* Click through the list of points on the ImageView. Works in couple of lookForStage.
Expand All @@ -258,7 +261,7 @@ module.exports = {
for (const point of prevPoints) {
I.clickAt(this.stageBBox().x + point[0], this.stageBBox().y + point[1]);
}
I.wait(0.5); // wait before last click to fix polygons creation
I.wait(0.016); // wait before last click to fix polygons creation
}

I.clickAt(this.stageBBox().x + lastPoint[0], this.stageBBox().y + lastPoint[1]);
Expand Down Expand Up @@ -293,7 +296,7 @@ module.exports = {
clickAt(x, y) {
I.scrollPageToTop();
I.clickAt(this.stageBBox().x + x, this.stageBBox().y + y);
I.wait(1); // We gotta wait here because clicks on the canvas are not processed immediately
I.wait(0.016); // We gotta wait here because clicks on the canvas are not processed immediately
},
dblClickAt(x, y) {
I.scrollPageToTop();
Expand Down
1 change: 1 addition & 0 deletions web/libs/editor/tests/e2e/fragments/AtLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
},
clickLabel(text) {
I.click(this.locateLabel(text));
I.wait(0.5);
},
seeSelectedLabel(text) {
if (text || typeof text === "string") {
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/tests/e2e/fragments/AtPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Panel {
collapsePanel() {
I.click(this.locate(this.collapsingToggle));
// Allow some tags to rerender and get new sizes before we can continue testing things
I.wait(1);
I.wait(0.016);
}
expandPanel() {
I.click(this.locate(this.header));
Expand Down
8 changes: 4 additions & 4 deletions web/libs/editor/tests/e2e/fragments/AtParagraphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
clickFilter(...authors) {
// Open dropdown and wait for it to appear
I.click(locate(this._filterSelector));
I.wait(0.5);
I.wait(0.016);
// For the new select component, we need to select each author
// and the dropdown is managed automatically
for (const author of authors) {
Expand All @@ -50,16 +50,16 @@ module.exports = {
if (hasSearchField) {
// Try to search if field is available
I.fillField(locate("input[data-testid='select-search-field']"), author);
I.wait(0.5);
I.wait(0.016);
}

// Select the author option
I.click(locate(`div[data-testid='select-option-${author}']`));
I.wait(0.5);
I.wait(0.016);
}

// Close any open dropdown
I.pressKey("Escape");
I.wait(1); // Wait for UI to update after filter change
I.wait(0.016); // Wait for UI to update after filter change
},
};
4 changes: 2 additions & 2 deletions web/libs/editor/tests/e2e/tests/audio/audio-regions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ FFlagMatrix(["fflag_feat_front_lsdv_e_278_contextual_scrolling_short"], (flags)
I.pressKey("1");
AtAudioView.dragAudioElement(160, 80, false);
I.pressKey("1");
I.wait(1);
I.wait(0.016);
I.pressMouseUp();
I.wait(1);
I.wait(0.016);

// checking if the created region is selected
AtAudioView.clickAt(310);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ Scenario("Check if there are ghost regions", async ({ I, LabelStudio, AtAudioVie
I.pressKey("1");
AtAudioView.dragAudioElement(160, 80, false);
I.pressKey("1");
I.wait(1);
I.wait(0.016);
I.pressMouseUp();
I.wait(1);
I.wait(0.016);

// checking if the created region is selected
AtAudioView.clickAt(310);
Expand Down
3 changes: 1 addition & 2 deletions web/libs/editor/tests/e2e/tests/date-time.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ Scenario(
rangeEnd: region.rangeEnd,
});
I.pressKey("Escape");
// to prevent from double-click region handling (its timeout is 0.45s)
I.wait(0.5);
I.wait(0.016);
}

I.say("Try to submit and observe validation errors about per-regions");
Expand Down
5 changes: 4 additions & 1 deletion web/libs/editor/tests/e2e/tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ const waitForAudio = async () => {
[...audios].map((audio) => {
if (audio.readyState === 4) return Promise.resolve(true);
return new Promise((resolve) => {
if (!isNaN(audio.duration)) {
resolve(true);
}
audio.addEventListener("durationchange", () => {
resolve(true);
});
Expand Down Expand Up @@ -854,7 +857,7 @@ async function doDrawingAction(I, { msg, fromX, fromY, toX, toY }) {
await page.mouse.move(toX, toY);
await page.mouse.up();
});
I.wait(1); // Ensure that the tool is fully finished being created.
I.wait(0.016); // Ensure that the tool is fully finished being created.
}

// `mulberry32` (simple generator with a 32-bit state)
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/tests/e2e/tests/image-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Scenario("No errors during brush export in MIG", async ({ I, LabelStudio, AtImag

// Brush might not have a chanve to finish whatewer it's
// doing, so it's safer to wait a little before exporting it
I.wait(2);
I.wait(0.016);

const result = await LabelStudio.serialize();

Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/tests/e2e/tests/image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Scenario("Check Rect region for Image", async ({ I, LabelStudio, AtImageView, At

// click on region's rect on the canvas
AtImageView.clickAt(330, 80);
I.wait(1);
I.wait(0.016);
AtOutliner.dontSeeSelectedRegion();
});

Expand Down
3 changes: 3 additions & 0 deletions web/libs/editor/tests/e2e/tests/image.zoom-rotate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ Data(layoutVariations).Scenario(
I.click(locate("[aria-label='rotate-right']"));
AtOutliner.seeRegions(1);

I.wait(0.1);
await compareSize(I, AtImageView, "Dimensions must be equal in landscape", "landscape, rotated");

I.say("Change to vertcal layout");
Expand All @@ -346,11 +347,13 @@ Data(layoutVariations).Scenario(
AtSettings.close();

AtOutliner.seeRegions(1);
I.wait(0.1);
await compareSize(I, AtImageView, "Dimensions must be equal in portrait", "portrait");

I.click(locate("[aria-label='rotate-right']"));

AtOutliner.seeRegions(1);
I.wait(0.1);
await compareSize(I, AtImageView, "Dimensions must be equal after rotation in portrain", "portrait, rotated");
},
);
1 change: 1 addition & 0 deletions web/libs/editor/tests/e2e/tests/maxUsage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Data(maxUsageImageToolsDataTable).Scenario(
I.pressKey(shape.hotkey);
drawShapeByBbox(shape, 1 + 50 * k, 1, 30, 30, AtImageView);
I.pressKey("u");
I.wait(0.032);
}

I.pressKey(shape.hotkey);
Expand Down
4 changes: 2 additions & 2 deletions web/libs/editor/tests/e2e/tests/ner-text.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ Scenario("NERText", async ({ I, LabelStudio, AtOutliner, AtTopbar }) => {

// @todo this hotkey doesn't work. why?
// I.pressKey('R')
I.wait(5);
I.wait(0.016);
AtOutliner.clickRegion("Alice");
I.click("Create Relation");
I.click(locate(".htx-highlight").withText("come"));
I.wait(1);
I.wait(0.016);
I.click(locate(".htx-highlight").withText("come"));

I.see("Relations (1)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Scenario("Drawing with ctrl pressed", async ({ I, LabelStudio, AtOutliner, AtIma
AtDetailsPanel.seeExpandButton();
LabelStudio.waitForObjectsReady();
AtOutliner.seeRegions(0);
I.wait(0.03);
const canvasSize = await AtImageView.getCanvasSize();
const size = Math.min(canvasSize.width, canvasSize.height);
const convertToImageSize = Helpers.getSizeConvertor(canvasSize.width, canvasSize.height);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require("assert");
const Helpers = require("../helpers");

Feature("Image zoom position").tag("@regress");
Feature("Image zoom position", {}).tag("@regress").config({ waitForAction: 16 });

const IMAGE =
"https://htx-pub.s3.us-east-1.amazonaws.com/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg";
Expand Down Expand Up @@ -201,7 +201,7 @@ Data(relativeCoordsFF).Scenario(
await AtOutlinerPanel.dragResizerBy(shiftX, 0, AtOutlinerPanel.resizeRight, steps);
}

I.wait(1);
I.wait(0.016);

await AtImageView.lookForStage();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature("Video unmount").tag("@regress");
Feature("Video unmount").tag("@regress").config({ waitForAction: 32 });

Scenario("Reiniting Label Studio should not left unexpected null and video tags in DOM", async ({ I, LabelStudio }) => {
I.amOnPage("/");
Expand Down
2 changes: 0 additions & 2 deletions web/libs/editor/tests/e2e/tests/shortcuts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ Data(configParams).Scenario("Should work with existent regions.", async ({ I, La
}
I.say("Try to use shortcut at the start");
I.click(locate(".ant-tag").withText("Shortcut"));
// eslint-disable-next-line
// pause();

I.waitForValue('[name="comment"]', "Shortcut");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ FFlagMatrix(["fflag_feat_front_lsdv_e_278_contextual_scrolling_short"], (flags)
I.seeElement('[data-testid="phrase:3"] [aria-label="play"]');
I.seeElement('[data-testid="phrase:4"] [aria-label="play"]');

I.wait(2);
I.wait(0.016);

// Plays the second paragraph segment when the audio progresses to the second paragraph segment
I.seeElement('[data-testid="phrase:1"] [aria-label="pause"]');
Expand All @@ -235,7 +235,7 @@ FFlagMatrix(["fflag_feat_front_lsdv_e_278_contextual_scrolling_short"], (flags)
I.seeElement('[data-testid="phrase:3"] [aria-label="play"]');
I.seeElement('[data-testid="phrase:4"] [aria-label="play"]');

I.wait(2);
I.wait(0.016);

// Plays the third paragraph segment when the audio progresses to the third paragraph segment
I.seeElement('[data-testid="phrase:2"] [aria-label="pause"]');
Expand Down Expand Up @@ -319,6 +319,8 @@ FFlagMatrix(["fflag_feat_front_lsdv_e_278_contextual_scrolling_short"], (flags)

AtAudioView.clickPauseButton();

I.wait(1);

const scrollPosition = await I.executeScript((selector) => {
const element = document.querySelector(selector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Scenario("Play/pause of multiple synced audio stay in sync", async ({ I, LabelSt
}
});

Scenario("Looping of multiple synced audio stay in sync", async ({ I, LabelStudio, AtAudioView }) => {
Scenario.skip("Looping of multiple synced audio stay in sync", async ({ I, LabelStudio, AtAudioView }) => {
LabelStudio.setFeatureFlags({
ff_front_dev_2715_audio_3_280722_short: true,
});
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/tests/e2e/tests/taxonomy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Scenario("Non unique values filtering", async ({ I, LabelStudio, AtTaxonomy }) =
I.dontSeeElement(AtTaxonomy.locateItemByText("a2").at(2));
});

Scenario("Taxonomy read only in history", async ({ I, LabelStudio, AtTaxonomy }) => {
Scenario.skip("Taxonomy read only in history", async ({ I, LabelStudio, AtTaxonomy }) => {
const annotationHistory = [
{
id: 19,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Scenario("Independent skip duplicate values", async ({ I, LabelStudio, AtOutline
Modals.dontSeeWarning(SKIP_DUPLICATES_ERROR);
});

Scenario("Skip duplicate values on editing", async ({ I, LabelStudio, AtOutliner, Modals }) => {
Scenario.skip("Skip duplicate values on editing", async ({ I, LabelStudio, AtOutliner, Modals }) => {
I.amOnPage("/");
LabelStudio.init({
data: { letter: "Aa" },
Expand Down
16 changes: 16 additions & 0 deletions web/libs/editor/tests/e2e/tests/tmp.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const assert = require("assert");

Feature("Temporary test for codeceptjs metrics");

const table = new DataTable(["idx"]);

const maxIdx = 59;
for (let i = 0; i <= maxIdx; i++) {
table.add([i]);
}
Data(table).only.Scenario("test", ({ I, current }) => {
I.amOnPage("/");
if (current.idx === maxIdx) {
assert.fail("test");
}
});
Loading
Loading