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

Electron tests: external links open an external browser #3373

Open
lf94 opened this issue Aug 12, 2024 · 3 comments
Open

Electron tests: external links open an external browser #3373

lf94 opened this issue Aug 12, 2024 · 3 comments
Labels
desktop-app Issues from the desktop app. tests Pull requests that update or improve our test suite

Comments

@lf94
Copy link
Contributor

lf94 commented Aug 12, 2024

When an external link is clicked it should start the system browser and not another electron window.

The test can click one of the following to test this:

out

This test may be unnecessary because the "failure" state looks like an electron window opening instead with the content, which isn't so bad. There are a lot of links in the application and it'd be high cost to maintain a test suite just for those alone.

@Irev-Dev or @jessfraz feel free to close

@jessfraz jessfraz added tests Pull requests that update or improve our test suite desktop-app Issues from the desktop app. labels Aug 12, 2024
@Irev-Dev
Copy link
Collaborator

I'm going to give this a quick try, but I don't think this is something we can test, once it opens an external browser it's out of our hands.

@Irev-Dev Irev-Dev assigned Irev-Dev and unassigned Irev-Dev Aug 14, 2024
@Irev-Dev
Copy link
Collaborator

I didn't have any luck, in case it's useful here's the code I tried

test(
  'external links',
  { tag: '@electron' },
  async ({ browserName }, testInfo) => {
    test.skip(
      browserName === 'webkit',
      'Skip on Safari because `window.tearDown` does not work'
    )
    const { electronApp, page } = await setupElectron({
      testInfo,
      folderSetupFn: async (dir) => {
        await fsp.mkdir(`${dir}/router-template-slate`, { recursive: true })
        await fsp.copyFile(
          'src/wasm-lib/tests/executor/inputs/router-template-slate.kcl',
          `${dir}/router-template-slate/main.kcl`
        )
      },
    })
    await page.goto('http://localhost:3000/')
    await page.setViewportSize({ width: 1200, height: 500 })

    page.on('console', console.log)

    await expect(page.getByTestId('user-sidebar-toggle')).toBeVisible()
    await page.getByTestId('user-sidebar-toggle').click()

    // await page.getByText('Request a feature').click()

    const [newPage] = await Promise.all([
      page.waitForEvent('popup'),
      page.getByText('Request a feature').click()
    ])
    await newPage.waitForLoadState()
    
    // can I verify it open it in the the default browser?
    // await page.waitForTimeout(5000)



    await electronApp.close()
  }
)

Maybe @ryanrosello-og will have an idea?

@ryanrosello-og
Copy link
Contributor

I'll have to try this locally and see the error being logged

@jessfraz jessfraz changed the title Electron tests: external links open an external browser (potentially unnecessary) Electron tests: external links open an external browser Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop-app Issues from the desktop app. tests Pull requests that update or improve our test suite
Projects
None yet
Development

No branches or pull requests

4 participants