Skip to content

fix: BROS-14: Optimize yarn test:e2e #7530

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 6 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
2 changes: 1 addition & 1 deletion .github/workflows/tests-yarn-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
env:
HEADLESS: true
run: |
yarn test:e2e
yarn lsf:e2e:parallel

- uses: actions/upload-artifact@v4
if: always()
Expand Down
8 changes: 5 additions & 3 deletions web/libs/editor/tests/e2e/codecept.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ module.exports.config = {
url: `http://localhost:${port}`,
show: !headless,
restart: "context",
timeout: 60000, // Action timeout after 60 seconds
waitForAction: headless ? 300 : 1200,
timeout: 30000,
waitForAction: headless ? 100 : 500,
windowSize: "1200x900",
waitForNavigation: "networkidle",
waitForNavigation: "domcontentloaded",
waitForURL: "domcontentloaded",
browser: "chromium",
chromium: process.env.CHROMIUM_EXECUTABLE_PATH
? {
executablePath: process.env.CHROMIUM_EXECUTABLE_PATH,
args: ['--disable-dev-shm-usage', '--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu'],
}
: {},
// to test date shifts because of timezone. (see date-time.test.js)
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "codeceptjs run",
"test:ui": "codecept-ui run",
"test:local": "HEADLESS=true yarn test",
"test:parallel": "codeceptjs run-workers",
"test:parallel": "codeceptjs run-workers 4",
"test:ci": "HEADLESS=true COVERAGE=true yarn run test:parallel",
"test:ci:no-worker": "HEADLESS=true codeceptjs run",
"coverage:istanbul": "node ./coverage-to-istanbul.js",
Expand Down
38 changes: 31 additions & 7 deletions web/libs/editor/tests/e2e/tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,41 @@ const waitForImage = () => {
*/
const waitForAudio = async () => {
const audios = document.querySelectorAll("audio");


console.log(`Found ${audios.length} audio elements to wait for`);

await Promise.all(
[...audios].map((audio) => {
if (audio.readyState === 4) return Promise.resolve(true);
return new Promise((resolve) => {
audio.addEventListener("durationchange", () => {
[...audios].map((audio, index) => {
console.log(`Audio ${index} readyState: ${audio.readyState}, src: ${audio.src}`);

if (audio.readyState === 4) {
console.log(`Audio ${index} already loaded`);
return Promise.resolve(true);
}

return Promise.race([
new Promise((resolve) => {
audio.addEventListener("durationchange", () => {
console.log(`Audio ${index} durationchange event fired`);
resolve(true);
});

// Also listen for canplaythrough as a backup
audio.addEventListener("canplaythrough", () => {
console.log(`Audio ${index} canplaythrough event fired`);
resolve(true);
});
}),
// Add a timeout to prevent hanging indefinitely
new Promise(resolve => setTimeout(() => {
console.log(`Audio ${index} timeout reached, current readyState: ${audio.readyState}`);
resolve(true);
});
});
}, 5000))
]);
}),
);

console.log("All audio elements are ready or timed out");
};

/**
Expand Down
5 changes: 3 additions & 2 deletions web/libs/editor/tests/e2e/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ examples.slice(1).forEach((example) =>
// Check for regions count
AtOutliner.seeRegions(count);

await I.executeScript(() => {
window.LabelStudio.destroyAll();
await I.executeScript(async () => {
// await window.LabelStudio.destroyAll();
// return true;
});
},
),
Expand Down
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lsf:watch": "nx run editor:build:development --watch",
"lsf:serve": "FRONTEND_HOSTNAME=http://localhost:3000 MODE=standalone nx run editor:serve:development",
"lsf:e2e": "cd libs/editor/tests/e2e && yarn test",
"lsf:e2e:parallel": "cd libs/editor/tests/e2e && yarn test:parallel",
"lsf:integration": "nx run editor:integration",
"lsf:integration:watch": "nx run editor:integration --watch",
"lsf:unit": "nx run editor:unit",
Expand Down
Loading