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

Fixing E2E tests #319

Merged
merged 1 commit into from
Dec 29, 2024
Merged

Fixing E2E tests #319

merged 1 commit into from
Dec 29, 2024

Conversation

remi-guan
Copy link
Collaborator

@remi-guan remi-guan commented Dec 26, 2024

User description

Description

After we've changed the parser location from /sandbox to /anyparser, we can't pass the login test.

This PR fixes this problem.

However, currently there are other tests are failed which haven't been fixed yet. Let's work on them soon.

Related Issue

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement

How Has This Been Tested?

Screenshots (if applicable)

Problem fixed

image

Problem awaiting to be fixed

image

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes


PR Type

Bug fix, Tests


Description

  • Fixed E2E tests by updating the parser location from /sandbox to /anyparser in the login and signup functions.
  • Ensured the page.goto and page.waitForURL calls in the test file reflect the new path.
  • This resolves the login test issue caused by the parser location change.

Changes walkthrough 📝

Relevant files
Bug fix
coreTests.ts
Update E2E test paths to `/anyparser`                                       

tests/coreTests.ts

  • Updated the page.goto and page.waitForURL calls to replace /sandbox
    with /anyparser.
  • Adjusted login and signup functions to reflect the new parser
    location.
  • +4/-4     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @lingjiekong lingjiekong marked this pull request as ready for review December 29, 2024 18:32
    @Copilot Copilot bot review requested due to automatic review settings December 29, 2024 18:32

    Choose a reason for hiding this comment

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

    Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

    Comments suppressed due to low confidence (4)

    tests/coreTests.ts:11

    • The change in URL path from '/sandbox' to '/anyparser' should be covered by tests to ensure the new behavior is verified.
    await page.goto('/anyparser');
    

    tests/coreTests.ts:18

    • The change in URL path from '/sandbox' to '/anyparser' should be covered by tests to ensure the new behavior is verified.
    await page.waitForURL('**/anyparser', { timeout: 5000 });
    

    tests/coreTests.ts:22

    • The change in URL path from '/sandbox' to '/anyparser' should be covered by tests to ensure the new behavior is verified.
    await page.goto('/anyparser');
    

    tests/coreTests.ts:43

    • The change in URL path from '/sandbox' to '/anyparser' should be covered by tests to ensure the new behavior is verified.
    await page.waitForURL('**/anyparser', { timeout: 5000 });
    
    Copy link
    Member

    @lingjiekong lingjiekong left a comment

    Choose a reason for hiding this comment

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

    LGTM

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Possible Timeout Issue

    The added await page.waitForURL('**/anyparser', { timeout: 5000 }); might cause timeout issues if the page takes longer than 5 seconds to load. Consider increasing the timeout or handling potential errors gracefully.

    await page.waitForURL('**/anyparser', { timeout: 5000 });
    Hardcoded Path Update

    The hardcoded path /anyparser has been added multiple times in the code. Consider refactoring to use a constant or configuration variable to improve maintainability and reduce duplication.

      await page.goto('/anyparser');
      await page.click('text=Login');
      await page.waitForURL(`https://${process.env.AUTH0_DOMAIN}/**`, { timeout: 5000 });
      await page.fill('input[name="username"]', username);
      await page.fill('input[name="password"]', password);
      await page.click('button[type="submit"]');
    
      await page.waitForURL('**/anyparser', { timeout: 5000 });
    }
    
    async function signup(page: Page, username: string, password: string) {
      await page.goto('/anyparser');
      await page.click('text=Login');
    
      await page.waitForURL(`https://${process.env.AUTH0_DOMAIN}/**`, { timeout: 5000 });
    
      await page.click('a[href*="/u/signup"]');
    
      // Fill out the email and password
      await page.fill('input[name="email"]', username);
      await page.fill('input[name="password"]', password);
    
      // Click the Continue button
      await page.click('button[value="default"]');
    
      // Wait for the next page to load (optional)
      await page.waitForTimeout(2000);
    
      // Click the Accept button
      await page.click('button[value="accept"]');
    
      // Wait for the final URL after acceptance
      await page.waitForURL('**/anyparser', { timeout: 5000 });

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Verify the correctness and accessibility of the /anyparser URL used in the test

    Ensure that the URL /anyparser is correct and accessible in the test environment, as
    incorrect URLs can cause test failures or unexpected behavior.

    tests/coreTests.ts [11]

    -await page.goto('/anyparser');
    +await page.goto('/anyparser'); // Ensure this URL is correct and accessible
    Suggestion importance[1-10]: 3

    Why: While ensuring the correctness of the URL is important, the suggestion is not actionable and only prompts verification without providing a concrete improvement. This limits its impact.

    3
    General
    Confirm the URL pattern and timeout for waitForURL to avoid test failures

    Validate that the await page.waitForURL('/anyparser', { timeout: 5000 }); call
    will not cause unnecessary test failures due to strict URL matching or insufficient
    timeout.**

    tests/coreTests.ts [18]

    -await page.waitForURL('**/anyparser', { timeout: 5000 });
    +await page.waitForURL('**/anyparser', { timeout: 5000 }); // Confirm URL pattern and timeout are appropriate
    Suggestion importance[1-10]: 3

    Why: The suggestion raises a valid point about potential issues with strict URL matching or timeout settings, but it is not actionable and only asks for verification. This reduces its overall usefulness.

    3

    Copy link
    Collaborator

    @goldmermaid goldmermaid left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @lingjiekong lingjiekong merged commit 9f7a306 into main Dec 29, 2024
    1 check passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants