Skip to content

Commit

Permalink
feat: render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Mar 3, 2024
1 parent 4b7d156 commit b4447f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion @fiction/core/plugin-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { initializeResetUi, safeDirname, vue } from '../utils'
import type { FictionAppEntry, FictionEnv, ServiceConfig, ServiceList } from '../plugin-env'
import { FictionPlugin } from '../plugin'
import type { FictionBuild } from '../plugin-build'
import type { FictionRouter } from '../plugin-router'
import { AppRoute, type FictionRouter } from '../plugin-router'
import type { RunVars, StandardServices } from '../inject'
import { FictionRender } from './plugin-render'
import ElRoot from './ElRoot.vue'
Expand Down Expand Up @@ -96,6 +96,9 @@ export class FictionApp extends FictionPlugin<FictionAppSettings> {
})
}

// add testing routes
this.fictionRouter.update([new AppRoute({ name: 'renderTest', path: '/render-test', component: (): Promise<any> => import('./test/TestRunVars.vue') })])

this.addSchema()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type playwright from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { TestServerConfig } from '@fiction/core/test-utils/buildTest'
import { createTestServer } from '@fiction/core/test-utils/buildTest'
import { commands } from '@fiction/www/src/vars'
import { commands } from '@fiction/www/src/commands'

const require = createRequire(import.meta.url)
const cwd = path.dirname(require.resolve('@fiction/www/package.json'))
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('renders app code correctly', () => {
return `http://localhost:${appPort}${route}`
}

await page().goto(url('/testing'))
await page().goto(url('/render-test'))

await page().waitForSelector('#server-port')

Expand All @@ -50,6 +50,6 @@ describe('renders app code correctly', () => {
expect(appNameText).toMatchInlineSnapshot('"FictionJS"')

const appEmailText = await page().locator(`#app-email`).textContent()
expect(appEmailText).toMatchInlineSnapshot('"hi@fictionjs.org"')
expect(appEmailText).toMatchInlineSnapshot('"hello@fiction.com"')
}, 20_000)
})

0 comments on commit b4447f3

Please sign in to comment.