Skip to content
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

Test browsers hang intermittently when scrolling is present #8208

Open
ayemelyanenko-chegg opened this issue Jun 7, 2024 · 5 comments
Open
Assignees
Labels
STATE: Issue accepted An issue has been reproduced. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@ayemelyanenko-chegg
Copy link

ayemelyanenko-chegg commented Jun 7, 2024

What is your Scenario?

Would like to run tests with scroll event present without having the browsers hang

What is the Current behavior?

When running tests, the tests browsers intermittently hang without any further action and without timing out

If the scrollOccured is commented out (check test code), then there are seemingly no hanging issues

What is the Expected behavior?

Would like to run tests with scroll event present without having the browsers hang without ever exiting

What is the public URL of the test page? (attach your complete example)

https://github.com/ayemelyanenko-chegg/nextjs-nodejs-example

What is your TestCafe test code?

import * as path from "path";
import { ClientFunction, Selector, t } from "testcafe";
export const emailForSignIn = Selector('input[id*="email"]');
export const passForSignin = Selector('input[type="password"]');
export const signInButton = Selector("button").withText("Sign in");
export const getStartedButton = Selector("span").withExactText("Get started");
const upload = Selector('div[data-test="file-upload-area-upload-drop-zone"]');
const fileUploadStatusModal = Selector("#notes-upload-status-modal");
const frame = Selector('iframe[name="CodePen"]');
const btnWithText = Selector("button").withText("Upload a file...");
const uploadOntoCanvas = Selector(
  'input[data-test = "file-upload-area-hidden-input-area"]'
);
const pathToFile = path.resolve(__dirname, `./sample_image.jpeg`);
const nextModal = Selector('div[id="notes-upload-status-modal"]');

export const checkScrollEvent = ClientFunction(() => {
  return new Promise((resolve) => {
    window.addEventListener(
      "scroll",
      () => {
        resolve(true); // Resolve the Promise when scroll event occurs
      },
      { once: true }
    ); // Use { once: true } to remove the listener after the first scroll event
  });
});

// user log in
async function userLogInWithCredentials(
  email: string,
  password: string
): Promise<void> {
  await t.setNativeDialogHandler(() => true);
  await t.navigateTo(
    "https://www.chegg.com/auth?redirect=https%3A%2F%2Fwww.chegg.com%2F"
  );
  await t
    .typeText(emailForSignIn, email, { paste: true })
    .typeText(passForSignin, password, { paste: true })
    .click(signInButton)
    .wait(6000);
}

fixture`Tests should not hang`
  .meta({
    author: "PLA",
    app: "",
  })
  .beforeEach(async (t) => {
    await userLogInWithCredentials("[email protected]", "Password@1");
    await t.navigateTo("/pla/notesbychegg");
    await t.eval(() => {
      document.addEventListener("DOMContentLoaded", () => {
        const originalOpen = window.open;
        window.open = function (url, target, features) {
          return originalOpen.call(window, url, target, features);
        };
      });
    });
  });

test.meta({
  testID: "t-0001",
})("Tests should not hang", async (t) => {
  await t.click(getStartedButton);
  const scrollOccurred = await checkScrollEvent();
  // Assert that the scroll event occurred. Page should scroll to the upload container
  await t.expect(scrollOccurred).ok("Scroll event did not occur");
  await t.clearUpload(uploadOntoCanvas);

  await t.setFilesToUpload(uploadOntoCanvas, pathToFile);
  await t
    .expect(fileUploadStatusModal.exists)
    .ok()
    .expect(fileUploadStatusModal.visible)
    .ok();
});

test.meta({
  testID: "t-0002",
})("Tests should not hang", async (t) => {
  await t.click(getStartedButton);
  const scrollOccurred = await checkScrollEvent();
  // Assert that the scroll event occurred. Page should scroll to the upload container
  await t.expect(scrollOccurred).ok("Scroll event did not occur");
  await t.clearUpload(uploadOntoCanvas);
  await t.setFilesToUpload(uploadOntoCanvas, pathToFile);
  await t
    .expect(fileUploadStatusModal.exists)
    .ok()
    .expect(fileUploadStatusModal.visible)
    .ok();
});

test.meta({
  testID: "t-0002",
})("Tests should not hang", async (t) => {
  await t.click(getStartedButton);
  const scrollOccurred = await checkScrollEvent();
  // Assert that the scroll event occurred. Page should scroll to the upload container
  await t.expect(scrollOccurred).ok("Scroll event did not occur");
  await t.clearUpload(uploadOntoCanvas);

  await t.setFilesToUpload(uploadOntoCanvas, pathToFile);
  await t
    .expect(fileUploadStatusModal.exists)
    .ok()
    .expect(fileUploadStatusModal.visible)
    .ok();
});

Your complete configuration file

No response

Your complete test report

No response

Screenshots

Tests hang and the console sometimes displays this error related to [r2wc]

Screenshot 2024-06-07 at 3 07 05 PM

Steps to Reproduce

  1. Clone https://github.com/ayemelyanenko-chegg/nextjs-nodejs-example
  2. cd into repo
  3. cd into my-app
  4. yarn install
  5. yarn testcafe chrome tests/sampleUploadTest.ts -c 3 -L
  6. If tests pass and don't hang, exit live mode and then retrigger tests again with the command from step 5. Several attempts like this will eventually cause browsers to hang

TestCafe version

3.6

Node.js version

20.11

Command-line arguments

yarn testcafe chrome tests/sampleUploadTest.ts -c 3 -L

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

No response

@ayemelyanenko-chegg ayemelyanenko-chegg added the TYPE: bug The described behavior is considered as wrong (bug). label Jun 7, 2024
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 7, 2024
@Bayheck Bayheck added STATE: Issue accepted An issue has been reproduced. and removed STATE: Need response An issue that requires a response or attention from the team. labels Jun 10, 2024
Copy link

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

@Bayheck Bayheck self-assigned this Jun 28, 2024
@Bayheck
Copy link
Collaborator

Bayheck commented Jul 2, 2024

Hello,
We do not recommend using live mode and concurrency in combination.

It is difficult to work on the issue because of how unstable the usage scenario is.

Please try running your tests without concurrency and see if the tests fail.

@Bayheck Bayheck added the STATE: Need clarification An issue lacks information for further research. label Jul 2, 2024
@ayemelyanenko-chegg
Copy link
Author

ayemelyanenko-chegg commented Jul 2, 2024

@Bayheck Hello, the live mode with concurrency was an example so that the issue is easily reproducible is visible. This also happens without the live mode as our tests run in GitLab without live mode. If the same tests are run with just concurrency but scrolling is present, there is a chance that browsers will hang. We also tried running without concurrency but with scrolling present and the browsers hang intermittently still.

@github-actions github-actions bot removed the STATE: Need clarification An issue lacks information for further research. label Jul 2, 2024
@PavelMor25 PavelMor25 added the STATE: Need response An issue that requires a response or attention from the team. label Jul 4, 2024
@Bayheck
Copy link
Collaborator

Bayheck commented Jul 8, 2024

Hello,

I tried to run your example without concurrency and live mode and got browser hanging on 1 out of 10-11 runs. How often do you get this behavior? Is issue occurrence frequency different on your CI and local runs?

@Bayheck Bayheck added STATE: Need clarification An issue lacks information for further research. and removed STATE: Need response An issue that requires a response or attention from the team. labels Jul 8, 2024
@ayemelyanenko-chegg
Copy link
Author

Hello, it was a fairly common occurrence because we tended to run those tests quite often and in multiple PR instance. The issue with this is that this behavior causes browsers to freeze so the entire suite would time out and that would cause a hassle. At this point, we are alright because we no longer do the scroll as we commented out that portion of the tests.

@github-actions github-actions bot removed the STATE: Need clarification An issue lacks information for further research. label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Issue accepted An issue has been reproduced. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants