test(native): open a document before editor fixtures
The Home tab exposes an editor store without a mounted canvas or text editor. Open New design during fixture setup and await actual editor readiness before populating nodes or starting text input. Reuse already-open documents and keep WebDriver input assertions unchanged. Full check passes. Native WebKit text input, fixture reuse and Settings checks pass (4 tests); Windows-only layer dragging skips on macOS. Upstream Tauri service bridge/teardown warnings remain; this does not claim IME or native clipboard coverage.
This commit is contained in:
parent
c6e475daac
commit
f4f3736034
|
|
@ -10,10 +10,6 @@ import { nativeDrag, readElementClientGeometry } from '#tests/helpers/tauri/wind
|
|||
describe('native layer dragging', () => {
|
||||
it('delivers a WebView drag sequence and reorders once', async function () {
|
||||
if (process.platform !== 'win32') this.skip()
|
||||
await browser.waitUntil(
|
||||
async () => browser.execute(() => Boolean(window.openPencil?.getStore?.())),
|
||||
{ timeout: 30_000, timeoutMsg: 'OpenPencil editor did not initialize' }
|
||||
)
|
||||
const ids = await createNativeLayerFixture()
|
||||
const source = await $(`[data-node-id="${ids.third}"] [data-test-id="layers-item"]`)
|
||||
const target = await $(`[data-node-id="${ids.first}"] [data-test-id="layers-item"]`)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@ import { withNativeEventRecorder } from '#tests/helpers/tauri/event-recorder'
|
|||
|
||||
describe('native text editing', () => {
|
||||
it('commits ordinary WebView input exactly once', async () => {
|
||||
await browser.waitUntil(
|
||||
async () => browser.execute(() => Boolean(window.openPencil?.getStore?.())),
|
||||
{ timeout: 30_000, timeoutMsg: 'OpenPencil editor did not initialize' }
|
||||
)
|
||||
await createNativeTextFixture('Replace me')
|
||||
const textarea = await $('textarea[aria-hidden="true"]')
|
||||
await textarea.waitForExist()
|
||||
|
|
@ -42,4 +38,18 @@ describe('native text editing', () => {
|
|||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('reuses the open document when preparing another text fixture', async () => {
|
||||
const tabCount = await browser.execute(() => document.querySelectorAll('[role="tab"]').length)
|
||||
const id = await createNativeTextFixture('Another fixture')
|
||||
const snapshot = await readNativeEditorSnapshot()
|
||||
|
||||
assert.equal(snapshot.editingTextId, id)
|
||||
assert.equal(snapshot.editingText, 'Another fixture')
|
||||
assert.equal(snapshot.textNodeCount, 1)
|
||||
assert.equal(
|
||||
await browser.execute(() => document.querySelectorAll('[role="tab"]').length),
|
||||
tabCount
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,33 @@ export type NativeLayerFixture = {
|
|||
third: string
|
||||
}
|
||||
|
||||
// Home has an editor store too, but no mounted canvas or text-input session.
|
||||
async function ensureNativeEditorReady(): Promise<void> {
|
||||
await browser.waitUntil(
|
||||
async () => browser.execute(() => Boolean(window.openPencil?.getStore?.())),
|
||||
{ timeout: 30_000, timeoutMsg: 'OpenPencil store did not initialize' }
|
||||
)
|
||||
await browser.execute(() => {
|
||||
const store = window.openPencil?.getStore?.()
|
||||
if (document.querySelector('canvas') && store?.textEditor) return
|
||||
const newDesign = [...document.querySelectorAll('button')].find(
|
||||
(button) => button.textContent?.trim() === 'New design'
|
||||
)
|
||||
// Setup only: input assertions still use WebDriver after the document is ready.
|
||||
newDesign?.click()
|
||||
})
|
||||
await browser.waitUntil(
|
||||
async () =>
|
||||
browser.execute(() => {
|
||||
const store = window.openPencil?.getStore?.()
|
||||
return Boolean(document.querySelector('canvas') && store?.textEditor)
|
||||
}),
|
||||
{ timeout: 30_000, timeoutMsg: 'Native canvas and text editor did not initialize' }
|
||||
)
|
||||
}
|
||||
|
||||
export async function createNativeLayerFixture(): Promise<NativeLayerFixture> {
|
||||
await ensureNativeEditorReady()
|
||||
return browser.execute(() => {
|
||||
const store = window.openPencil?.getStore?.()
|
||||
if (!store) throw new Error('OpenPencil editor is not ready')
|
||||
|
|
@ -59,6 +85,7 @@ export async function readNativeEditorSnapshot(): Promise<NativeEditorSnapshot>
|
|||
}
|
||||
|
||||
export async function createNativeTextFixture(text = ''): Promise<string> {
|
||||
await ensureNativeEditorReady()
|
||||
return browser.execute((initialText) => {
|
||||
const store = window.openPencil?.getStore?.()
|
||||
if (!store) throw new Error('OpenPencil editor is not ready')
|
||||
|
|
|
|||
Loading…
Reference in a new issue