mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 01:47:47 +08:00
Restore authorized rule reveal, explicit full HTTP capture and retention, video task business fields, and valid payment URLs. Add opt-in credential preservation for trusted recovery, fix frontend type contracts and async races, and eliminate PostgreSQL test fixture resource leaks. Document audit coverage and successful fmt and CI-scoped Clippy checks.
62 lines
2.5 KiB
TypeScript
62 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { createApp, defineComponent, h, nextTick, ref } from 'vue'
|
|
|
|
import JsonImportInput from '@/components/common/JsonImportInput.vue'
|
|
import { createI18n } from '@/i18n'
|
|
|
|
describe('JsonImportInput', () => {
|
|
it('keeps both mode panels in one layout track while switching modes', async () => {
|
|
const value = ref('')
|
|
const Host = defineComponent({
|
|
setup() {
|
|
return () => h(JsonImportInput, {
|
|
modelValue: value.value,
|
|
'onUpdate:modelValue': (nextValue: string) => {
|
|
value.value = nextValue
|
|
},
|
|
})
|
|
},
|
|
})
|
|
const root = document.createElement('div')
|
|
document.body.appendChild(root)
|
|
const app = createApp(Host)
|
|
app.use(createI18n())
|
|
app.mount(root)
|
|
|
|
const panels = root.querySelector<HTMLElement>('[data-testid="json-import-mode-panels"]')
|
|
const filePanel = root.querySelector<HTMLElement>('[data-testid="json-import-file-panel"]')
|
|
const manualPanel = root.querySelector<HTMLElement>('[data-testid="json-import-manual-panel"]')
|
|
expect(panels?.classList.contains('grid')).toBe(true)
|
|
expect(filePanel?.getAttribute('aria-hidden')).toBe('false')
|
|
expect(filePanel?.hasAttribute('inert')).toBe(false)
|
|
expect(manualPanel?.getAttribute('aria-hidden')).toBe('true')
|
|
expect(manualPanel?.hasAttribute('inert')).toBe(true)
|
|
|
|
root.querySelector<HTMLButtonElement>('[data-testid="json-import-mode-toggle"]')?.click()
|
|
await nextTick()
|
|
|
|
expect(root.querySelector('[data-testid="json-import-file-panel"]')).toBe(filePanel)
|
|
expect(root.querySelector('[data-testid="json-import-manual-panel"]')).toBe(manualPanel)
|
|
expect(filePanel?.getAttribute('aria-hidden')).toBe('true')
|
|
expect(filePanel?.hasAttribute('inert')).toBe(true)
|
|
expect(manualPanel?.getAttribute('aria-hidden')).toBe('false')
|
|
expect(manualPanel?.hasAttribute('inert')).toBe(false)
|
|
|
|
const textarea = root.querySelector<HTMLTextAreaElement>('textarea')
|
|
if (!textarea) throw new Error('Expected manual textarea')
|
|
textarea.value = 'credential-value'
|
|
textarea.dispatchEvent(new Event('input', { bubbles: true }))
|
|
await nextTick()
|
|
expect(value.value).toBe('credential-value')
|
|
|
|
root.querySelector<HTMLButtonElement>('[data-testid="json-import-mode-toggle"]')?.click()
|
|
await nextTick()
|
|
expect(value.value).toBe('')
|
|
expect(filePanel?.hasAttribute('inert')).toBe(false)
|
|
expect(manualPanel?.hasAttribute('inert')).toBe(true)
|
|
|
|
app.unmount()
|
|
root.remove()
|
|
})
|
|
})
|