-
Notifications
You must be signed in to change notification settings - Fork 102
Wait for export button to make test more reliable #6143
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,60 +32,52 @@ test( | |||||||||||||||
| }) | ||||||||||||||||
| await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||||||||||||||
|
|
||||||||||||||||
| page.on('console', console.log) | ||||||||||||||||
|
|
||||||||||||||||
| await test.step('on open of project', async () => { | ||||||||||||||||
| await expect(page.getByText(`bracket`)).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // open the project | ||||||||||||||||
| await page.getByText(`bracket`).click() | ||||||||||||||||
| // Open the project | ||||||||||||||||
| const projectName = page.getByText(`bracket`) | ||||||||||||||||
| await expect(projectName).toBeVisible() | ||||||||||||||||
| await projectName.click() | ||||||||||||||||
| await scene.waitForExecutionDone() | ||||||||||||||||
| await page.waitForTimeout(1_000) // wait for panel buttons to be available | ||||||||||||||||
|
|
||||||||||||||||
| // expect zero errors in guter | ||||||||||||||||
| // Expect zero errors in gutter | ||||||||||||||||
| await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // export the model | ||||||||||||||||
| // Click the export button | ||||||||||||||||
| const exportButton = page.getByTestId('export-pane-button') | ||||||||||||||||
| await expect(exportButton).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| await scene.waitForExecutionDone() | ||||||||||||||||
|
|
||||||||||||||||
| const gltfOption = page.getByText('glTF') | ||||||||||||||||
| const submitButton = page.getByText('Confirm Export') | ||||||||||||||||
| const exportingToastMessage = page.getByText(`Exporting...`) | ||||||||||||||||
| const errorToastMessage = page.getByText(`Error while exporting`) | ||||||||||||||||
| const engineErrorToastMessage = page.getByText(`Nothing to export`) | ||||||||||||||||
| const alreadyExportingToastMessage = page.getByText(`Already exporting`) | ||||||||||||||||
| // The open file's name is `main.kcl`, so the export file name should be `main.gltf` | ||||||||||||||||
| const exportFileName = `main.gltf` | ||||||||||||||||
|
|
||||||||||||||||
| // Click the export button | ||||||||||||||||
| await exportButton.click() | ||||||||||||||||
| 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` | ||||||||||||||||
| await expect(gltfOption).toBeVisible() | ||||||||||||||||
| await expect(page.getByText('STL')).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| await page.keyboard.press('Enter') | ||||||||||||||||
|
|
||||||||||||||||
| // Click the checkbox | ||||||||||||||||
| const submitButton = page.getByText('Confirm Export') | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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',
},
}) |
||||||||||||||||
| await expect(submitButton).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| await page.waitForTimeout(500) | ||||||||||||||||
|
|
||||||||||||||||
| await page.keyboard.press('Enter') | ||||||||||||||||
|
|
||||||||||||||||
| // Find the toast. | ||||||||||||||||
| // Look out for the toast message | ||||||||||||||||
| const exportingToastMessage = page.getByText(`Exporting...`) | ||||||||||||||||
| const alreadyExportingToastMessage = page.getByText(`Already exporting`) | ||||||||||||||||
| await expect(exportingToastMessage).toBeVisible() | ||||||||||||||||
| await expect(alreadyExportingToastMessage).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // Expect it to succeed. | ||||||||||||||||
| // Expect it to succeed | ||||||||||||||||
| const errorToastMessage = page.getByText(`Error while exporting`) | ||||||||||||||||
| const engineErrorToastMessage = page.getByText(`Nothing to export`) | ||||||||||||||||
| await expect(errorToastMessage).not.toBeVisible() | ||||||||||||||||
| await expect(engineErrorToastMessage).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| const successToastMessage = page.getByText(`Exported successfully`) | ||||||||||||||||
| await expect(successToastMessage).toBeVisible() | ||||||||||||||||
| await expect(exportingToastMessage).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // Check for the exported file | ||||||||||||||||
| const firstFileFullPath = path.resolve( | ||||||||||||||||
| getPlaywrightDownloadDir(tronApp.projectDirName), | ||||||||||||||||
| exportFileName | ||||||||||||||||
|
|
@@ -112,60 +104,53 @@ test( | |||||||||||||||
| const u = await getUtils(page) | ||||||||||||||||
| await u.openFilePanel() | ||||||||||||||||
|
|
||||||||||||||||
| // Click on the other file | ||||||||||||||||
| const otherKclButton = page.getByRole('button', { name: 'other.kcl' }) | ||||||||||||||||
|
|
||||||||||||||||
| // Click the file | ||||||||||||||||
| await otherKclButton.click() | ||||||||||||||||
|
|
||||||||||||||||
| // Close the file pane | ||||||||||||||||
| await u.closeFilePanel() | ||||||||||||||||
| await scene.waitForExecutionDone() | ||||||||||||||||
| await page.waitForTimeout(1_000) // wait for panel buttons to be available | ||||||||||||||||
|
|
||||||||||||||||
| // FIXME: await scene.waitForExecutionDone() does not work. The modeling indicator stays in -receive-reliable and not execution done | ||||||||||||||||
| await page.waitForTimeout(10000) | ||||||||||||||||
|
|
||||||||||||||||
| // expect zero errors in guter | ||||||||||||||||
| // Expect zero errors in gutter | ||||||||||||||||
| await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // export the model | ||||||||||||||||
| // Click the export button | ||||||||||||||||
| const exportButton = page.getByTestId('export-pane-button') | ||||||||||||||||
| await expect(exportButton).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| const gltfOption = page.getByText('glTF') | ||||||||||||||||
| const submitButton = page.getByText('Confirm Export') | ||||||||||||||||
| const exportingToastMessage = page.getByText(`Exporting...`) | ||||||||||||||||
| const errorToastMessage = page.getByText(`Error while exporting`) | ||||||||||||||||
| const engineErrorToastMessage = page.getByText(`Nothing to export`) | ||||||||||||||||
| const alreadyExportingToastMessage = page.getByText(`Already exporting`) | ||||||||||||||||
| // The open file's name is `other.kcl`, so the export file name should be `other.gltf` | ||||||||||||||||
| const exportFileName = `other.gltf` | ||||||||||||||||
|
|
||||||||||||||||
| // Click the export button | ||||||||||||||||
| await exportButton.click() | ||||||||||||||||
| await page.waitForTimeout(1_000) // wait for export options to be available | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 modeling-app/src/lib/commandBarConfigs/modelingCommandConfig.ts Lines 236 to 242 in bfdf8ba
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||||||||
|
|
||||||||||||||||
| // Select the first format option | ||||||||||||||||
| const gltfOption = page.getByText('glTF') | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This could be cmdBar.selectOption({ name: 'glTF' }) I think |
||||||||||||||||
| const exportFileName = `other.gltf` // source file is named `other.kcl` | ||||||||||||||||
| await expect(gltfOption).toBeVisible() | ||||||||||||||||
| await expect(page.getByText('STL')).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| await page.keyboard.press('Enter') | ||||||||||||||||
|
|
||||||||||||||||
| // Click the checkbox | ||||||||||||||||
| const submitButton = page.getByText('Confirm Export') | ||||||||||||||||
| await expect(submitButton).toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| await page.waitForTimeout(500) | ||||||||||||||||
| await page.keyboard.press('Enter') | ||||||||||||||||
|
Comment on lines
+132
to
135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd prefer |
||||||||||||||||
|
|
||||||||||||||||
| // Find the toast. | ||||||||||||||||
| // Look out for the toast message | ||||||||||||||||
| const exportingToastMessage = page.getByText(`Exporting...`) | ||||||||||||||||
| const alreadyExportingToastMessage = page.getByText(`Already exporting`) | ||||||||||||||||
| await expect(exportingToastMessage).toBeVisible() | ||||||||||||||||
| await expect(alreadyExportingToastMessage).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // Expect it to succeed | ||||||||||||||||
| const errorToastMessage = page.getByText(`Error while exporting`) | ||||||||||||||||
| const engineErrorToastMessage = page.getByText(`Nothing to export`) | ||||||||||||||||
| await expect(errorToastMessage).not.toBeVisible() | ||||||||||||||||
| await expect(engineErrorToastMessage).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| const successToastMessage = page.getByText(`Exported successfully`) | ||||||||||||||||
| await test.step('Check the success toast message shows and nothing else', async () => | ||||||||||||||||
| Promise.all([ | ||||||||||||||||
| expect(alreadyExportingToastMessage).not.toBeVisible(), | ||||||||||||||||
| expect(errorToastMessage).not.toBeVisible(), | ||||||||||||||||
| expect(engineErrorToastMessage).not.toBeVisible(), | ||||||||||||||||
| expect(successToastMessage).toBeVisible(), | ||||||||||||||||
| expect(exportingToastMessage).not.toBeVisible(), | ||||||||||||||||
| ])) | ||||||||||||||||
| await expect(successToastMessage).toBeVisible() | ||||||||||||||||
| await expect(exportingToastMessage).not.toBeVisible() | ||||||||||||||||
|
|
||||||||||||||||
| // Check for the exported file= | ||||||||||||||||
| const secondFileFullPath = path.resolve( | ||||||||||||||||
| getPlaywrightDownloadDir(tronApp.projectDirName), | ||||||||||||||||
| exportFileName | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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
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.