Skip to content

Commit

Permalink
test to validate subrouting (#927)
Browse files Browse the repository at this point in the history
* test to validate subrouting

* Update test expectations [skip ci]

* core tests need to prep the page

* Update test expectations [skip ci]

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
mcmonkey4eva and github-actions authored Sep 23, 2024
1 parent 9aa976f commit 6a3dbe0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
8 changes: 8 additions & 0 deletions browser_tests/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ export class ComfyPage {

async setup() {
await this.goto()
await this.prepPage()
}

async prepPage() {
await this.page.evaluate(() => {
localStorage.clear()
sessionStorage.clear()
Expand Down Expand Up @@ -312,6 +316,10 @@ export class ComfyPage {
await this.page.goto(this.url)
}

async gotoPath(url: string) {
await this.page.goto(this.url + url)
}

async nextFrame() {
await this.page.evaluate(() => {
return new Promise<number>(requestAnimationFrame)
Expand Down
24 changes: 24 additions & 0 deletions browser_tests/core.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { expect } from '@playwright/test'
import { comfyPageFixture as test } from './ComfyPage'

test.describe('basic frontend page', () => {
test('Basic front page loads and renders at all', async ({ comfyPage }) => {
await comfyPage.gotoPath('/')
await comfyPage.prepPage()
await expect(comfyPage.canvas).toHaveScreenshot(
'basic-frontend-page-content.png'
)
})
})

test.describe('subrouting validation', () => {
test('subrouted installs of the comfy frontend load as intended', async ({
comfyPage
}) => {
await comfyPage.gotoPath('/testsubrouteindex')
await comfyPage.prepPage()
await expect(comfyPage.canvas).toHaveScreenshot(
'subrouted-frontend-page-content.png'
)
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'

const router = createRouter({
history: createWebHistory(),
history: createWebHistory(window.location.pathname),
routes: [
{
path: '/',
Expand Down
5 changes: 5 additions & 0 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export default defineConfig({
'/ws': {
target: DEV_SERVER_COMFYUI_URL,
ws: true
},

'/testsubrouteindex': {
target: 'http://localhost:5173',
rewrite: (path) => path.substring('/testsubrouteindex'.length)
}
}
},
Expand Down

0 comments on commit 6a3dbe0

Please sign in to comment.