Pass testing-selections.spec.ts

This commit is contained in:
49lf
2024-11-21 10:07:47 -05:00
parent 05baf9884d
commit 765e27c02b
4 changed files with 1284 additions and 1298 deletions

View File

@ -41,7 +41,9 @@ export class HomePageFixture {
this.projectButtonNew = this.page.getByTestId('home-new-file')
this.projectTextName = this.page.getByTestId('cmd-bar-arg-value')
this.projectButtonContinue = this.page.getByRole('button', { name: 'Continue' })
this.projectButtonContinue = this.page.getByRole('button', {
name: 'Continue',
})
this.sortByDateBtn = this.page.getByTestId('home-sort-by-modified')
this.sortByNameBtn = this.page.getByTestId('home-sort-by-name')
@ -116,7 +118,7 @@ export class HomePageFixture {
await projectCard.click()
}
goToModelingScene = async (name?: string = "testDefault") => {
goToModelingScene = async (name?: string = 'testDefault') => {
await this.createAndGoToProject(name)
}
}

View File

@ -99,7 +99,8 @@ async function removeCurrentCode(page: Page) {
export async function sendCustomCmd(page: Page, cmd: EngineCommand) {
await page.getByTestId('custom-cmd-input').fill(JSON.stringify(cmd))
await page.getByTestId('custom-cmd-send-button').click()
await page.getByTestId('custom-cmd-send-button').scrollIntoViewIfNeeded()
await page.getByTestId('custom-cmd-send-button').click({ delay: 1000 })
}
async function clearCommandLogs(page: Page) {
@ -165,6 +166,9 @@ async function closeKclCodePanel(page: Page) {
async function openDebugPanel(page: Page) {
await openPane(page, 'debug-pane-button')
// The debug pane needs time to load everything.
await page.waitForTimeout(3000)
}
export async function closeDebugPanel(page: Page) {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,9 @@
import { test as playwrightTestFn } from '@playwright/test'
import { fixtures, Fixtures, AuthenticatedTronApp } from './fixtures/fixtureSetup'
import {
fixtures,
Fixtures,
AuthenticatedTronApp,
} from './fixtures/fixtureSetup'
export { expect, Page, BrowserContext, TestInfo } from '@playwright/test'
// Our custom decorated Zoo test object. Makes it easier to add fixtures, and
@ -10,41 +14,58 @@ export function test(desc, objOrFn, fnMaybe) {
const hasTestConf = typeof objOrFn === 'object'
const fn = hasTestConf ? fnMaybe : objOrFn
return pwTestFnWithFixtures(desc, hasTestConf ? objOrFn : {}, async ({ page, context, cmdBar, editor, toolbar, scene, homePage }, testInfo) => {
// To switch to web, change this to AuthenticatedApp from fixtureSetup.ts
const tronApp = new AuthenticatedTronApp(
context,
page,
return pwTestFnWithFixtures(
desc,
hasTestConf ? objOrFn : {},
async (
{ page, context, cmdBar, editor, toolbar, scene, homePage },
testInfo
)
) => {
// To switch to web, change this to AuthenticatedApp from fixtureSetup.ts
const tronApp = new AuthenticatedTronApp(context, page, testInfo)
const fixtures: Fixtures = { cmdBar, editor, toolbar, scene, homePage }
await tronApp.initialise({ fixtures })
const fixtures: Fixtures = { cmdBar, editor, toolbar, scene, homePage }
await tronApp.initialise({ fixtures })
// We need to patch this because addInitScript will bind too late in our
// electron tests, never running. We need to call reload() after each call
// to guarantee it runs.
const oldContextAddInitScript = tronApp.context.addInitScript
tronApp.context.addInitScript = async function(a, b) {
await oldContextAddInitScript.apply(this, [a, b])
await tronApp.page.reload()
// We need to patch this because addInitScript will bind too late in our
// electron tests, never running. We need to call reload() after each call
// to guarantee it runs.
const oldContextAddInitScript = tronApp.context.addInitScript
tronApp.context.addInitScript = async function (a, b) {
await oldContextAddInitScript.apply(this, [a, b])
await tronApp.page.reload()
}
// No idea why we mix and match page and context's addInitScript but we do
const oldPageAddInitScript = tronApp.page.addInitScript
tronApp.page.addInitScript = async function (a, b) {
await oldPageAddInitScript.apply(this, [a, b])
await tronApp.page.reload()
}
// Create a consistent way to resize the page across electron and web.
tronApp.page.setBodyDimensions = async function (dims: {
width: number
height: number
}) {
return this.evaluate((dims) => {
window.document.body.style.width = dims.width + 'px'
window.document.body.style.height = dims.height + 'px'
}, dims)
}
await fn(
{
context: tronApp.context,
page: tronApp.page,
...fixtures,
},
testInfo
)
testInfo.tronApp = tronApp
}
// No idea why we mix and match page and context's addInitScript but we do
const oldPageAddInitScript = tronApp.page.addInitScript
tronApp.page.addInitScript = async function(a, b) {
await oldPageAddInitScript.apply(this, [a, b])
await tronApp.page.reload()
}
await fn({
context: tronApp.context,
page: tronApp.page,
...fixtures
}, testInfo)
testInfo.tronApp = tronApp
})
)
}
test.describe = pwTestFnWithFixtures.describe
@ -52,3 +73,4 @@ test.beforeEach = pwTestFnWithFixtures.beforeEach
test.afterEach = pwTestFnWithFixtures.afterEach
test.step = pwTestFnWithFixtures.step
test.skip = pwTestFnWithFixtures.skip
test.setTimeout = pwTestFnWithFixtures.setTimeout