Skip to content

Comments

Wait for export button to make test more reliable#6143

Merged
jacebrowning merged 1 commit intomainfrom
wait-for-export-button
Apr 4, 2025
Merged

Wait for export button to make test more reliable#6143
jacebrowning merged 1 commit intomainfrom
wait-for-export-button

Conversation

@jacebrowning
Copy link
Contributor

@jacebrowning jacebrowning commented Apr 4, 2025

The main source of flakiness in the export works on the first try test seems to be the export button in the panel not always being available right after the scene execution finishes. Adding a short delay ensures that clicking the button actually opens up the export menu.


yarn test:playwright:electron:local --grep="export works on the first try" --repeat-each=10

@jacebrowning jacebrowning self-assigned this Apr 4, 2025
@qa-wolf
Copy link

qa-wolf bot commented Apr 4, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@vercel
Copy link

vercel bot commented Apr 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Apr 4, 2025 3:29pm

@codecov
Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.37%. Comparing base (1aa27bd) to head (672bde0).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6143   +/-   ##
=======================================
  Coverage   85.37%   85.37%           
=======================================
  Files         110      110           
  Lines       44215    44215           
=======================================
  Hits        37750    37750           
  Misses       6465     6465           
Flag Coverage Δ
rust 85.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jacebrowning jacebrowning marked this pull request as ready for review April 4, 2025 16:27
@jacebrowning jacebrowning requested review from a team and nadr0 April 4, 2025 16:28
@jacebrowning jacebrowning enabled auto-merge (squash) April 4, 2025 16:46
Copy link
Contributor

@pierremtb pierremtb left a comment

Choose a reason for hiding this comment

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

Looks good generally and frankly we need this sorted out. Noted down a few common fixtures you could use around the cmd bar that should make it more consistent with other tests (potentially better, maybe not haha!)


// Click the export button
await exportButton.click()
await page.waitForTimeout(1_000) // wait for export options to be available
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a little sus no? Considering that the options are all hardcoded there

options: [
{ name: 'glTF', isCurrent: true, value: 'gltf' },
{ name: 'OBJ', isCurrent: false, value: 'obj' },
{ name: 'STL', isCurrent: false, value: 'stl' },
{ name: 'STEP', isCurrent: false, value: 'step' },
{ name: 'PLY', isCurrent: false, value: 'ply' },
],

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd prefer to see a cmdBar.expectState call here. It's probably because this test is very old that it wasn't there

await page.waitForTimeout(1_000) // wait for export options to be available

// Select the first format option
const gltfOption = page.getByText('glTF')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This could be cmdBar.selectOption({ name: 'glTF' }) I think

Comment on lines +132 to 135
const submitButton = page.getByText('Confirm Export')
await expect(submitButton).toBeVisible()

await page.waitForTimeout(500)
await page.keyboard.press('Enter')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd prefer await cmdBar.progressCmdBar() here for all these

@jacebrowning jacebrowning merged commit 6993893 into main Apr 4, 2025
38 checks passed
@jacebrowning jacebrowning deleted the wait-for-export-button branch April 4, 2025 20:53
Copy link
Contributor

@Irev-Dev Irev-Dev left a comment

Choose a reason for hiding this comment

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

Had a few comments, I could have made more, but they'de all be nits where this old test doesn't use some of our newer fixture methods.

Comment on lines +50 to +54
await page.waitForTimeout(1_000) // wait for export options to be available

// Select the first format option
const gltfOption = page.getByText('glTF')
const exportFileName = `main.gltf` // source file is named `main.kcl`
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't await expect(gltfOption).toBeVisible() be better than an arbitary wait?

Suggested change
await page.waitForTimeout(1_000) // wait for export options to be available
// Select the first format option
const gltfOption = page.getByText('glTF')
const exportFileName = `main.gltf` // source file is named `main.kcl`
// Select the first format option
const gltfOption = page.getByText('glTF')
await expect(gltfOption).toBeVisible()
const exportFileName = `main.gltf` // source file is named `main.kcl`

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually on second thought we have fixture tooling for the cmdbar.

example use

await cmdBar.expectState({
        stage: 'arguments',
        commandName: 'Import file from URL',
        currentArgKey: 'method',
        currentArgValue: '',
        headerArguments: {
          Method: '',
          Name: 'test',
          Code: '1 line',
        },
        highlightedHeaderArg: 'method',
      })

This second comment is more of a nit, understand you're just trying to make it more reliable, not refactor the code to match our newer patterns.

await page.keyboard.press('Enter')

// Click the checkbox
const submitButton = page.getByText('Confirm Export')
Copy link
Contributor

Choose a reason for hiding this comment

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

Again nit, the same tool can do an assertion for the review stage of the cmdbar

await cmdBar.expectState({
        stage: 'review',
        commandName: 'Import file from URL',
        headerArguments: {
          Method: 'Existing project',
          ProjectName: 'testProjectDir',
          Name: 'test',
          Code: '1 line',
        },
      })

@Irev-Dev
Copy link
Contributor

Irev-Dev commented Apr 4, 2025

Pierre and I were on the same wave length.

jessfraz added a commit that referenced this pull request Apr 5, 2025
* origin/main: (26 commits)
  attempt to import win-ca on windows (#6136)
  Upgrade e2e-tests windows runner from 4 cores to 8 (#6166)
  Follow-up fixes after bearing sample rename (#6164)
  Add test for #5799: "Only showing axis planes when there are no errors" (#6007)
  Wait for export button to make test more reliable (#6143)
  sketching on a mirror2d thats been extruded fixed! (#6149)
  Bump vite from 5.4.16 to 5.4.17 in /packages/codemirror-lang-kcl in the security group (#6150)
  Bump vite from 5.4.16 to 5.4.17 in the security group (#6151)
  Update all KCL-Samples to be more ME friendly (#6132)
  Shorten feedback cycle for legitimate failures (#6146)
  Remove the camera projection toggle from the UI (#6077)
  Use all available CPUs to run tests on CI (#6138)
  [fix] Get rid of risky useEffect in restart onboarding flow (#6133)
  Feature: Traditional menu actions in desktop application part II (#6030)
  [Bug] fix some UI friction from imports (#6139)
  Use scene fixture to make test more reliable on macOS (#6140)
  Fix: function composition during playwright setup created a massive page.reload loop (#6137)
  Alternative way to make appMachine spawned children type safe (#5890)
  [BUG] mutate ast to keep comments for pipe split ast-mod (#6128)
  Rename the app to Zoo Design Studio (#5974)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants