Fix onboarding example code loading (#2723)

* Add Playwright test to verify that example code loads

* Just let the loaded code be null if it's null
This commit is contained in:
Frank Noirot
2024-06-20 12:07:21 -04:00
committed by GitHub
parent 674d49e2ae
commit e7af064518
2 changed files with 94 additions and 68 deletions

View File

@ -1287,7 +1287,32 @@ test('Keyboard shortcuts can be viewed through the help menu', async ({
).toBeAttached()
})
test('Click through each onboarding step', async ({ page }) => {
test.describe('Onboarding tests', () => {
test('Onboarding code is shown in the editor', async ({ page }) => {
const u = await getUtils(page)
// Override beforeEach test setup
await page.addInitScript(
async ({ settingsKey }) => {
// Give no initial code, so that the onboarding start is shown immediately
localStorage.removeItem('persistCode')
localStorage.removeItem(settingsKey)
},
{ settingsKey: TEST_SETTINGS_KEY }
)
await page.setViewportSize({ width: 1200, height: 500 })
await page.goto('/')
await u.waitForAuthSkipAppStart()
// Test that the onboarding pane loaded
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
// *and* that the code is shown in the editor
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket')
})
test('Click through each onboarding step', async ({ page }) => {
const u = await getUtils(page)
// Override beforeEach test setup
@ -1324,9 +1349,9 @@ test('Click through each onboarding step', async ({ page }) => {
// Test that the onboarding pane is gone
await expect(page.getByTestId('onboarding-content')).not.toBeVisible()
await expect(page.url()).not.toContain('onboarding')
})
})
test('Onboarding redirects and code updating', async ({ page }) => {
test('Onboarding redirects and code updating', async ({ page }) => {
const u = await getUtils(page)
// Override beforeEach test setup
@ -1368,6 +1393,7 @@ test('Onboarding redirects and code updating', async ({ page }) => {
// Test that the code is not empty when you click on the next step
await page.locator('[data-testid="onboarding-next"]').click()
await expect(page.locator('.cm-content')).toHaveText(/.+/)
})
})
test.describe('Testing selections', () => {

View File

@ -22,7 +22,7 @@ export default class CodeManager {
return
}
const storedCode = safeLSGetItem(PERSIST_CODE_TOKEN) || ''
const storedCode = safeLSGetItem(PERSIST_CODE_TOKEN)
// TODO #819 remove zustand persistence logic in a few months
// short term migration, shouldn't make a difference for tauri app users
// anyway since that's filesystem based.