@@ -33,6 +33,18 @@ function renderApp(): HTMLElement {
|
||||
function rowWithText(container: HTMLElement, selector: string, text: string): HTMLElement | undefined {
|
||||
return Array.from(container.querySelectorAll<HTMLElement>(selector)).find((el) => el.textContent?.includes(text))
|
||||
}
|
||||
// The tree opens fully collapsed, so expand each ancestor folder before reaching
|
||||
// a nested file. Each folder is clicked exactly once (a second click collapses).
|
||||
async function expandTo(c: HTMLElement, ...folders: string[]): Promise<void> {
|
||||
for (const name of folders) {
|
||||
const row = await waitFor(() => {
|
||||
const r = rowWithText(c, '.tree-row', name)
|
||||
if (!r) throw new Error(`folder ${name} not ready`)
|
||||
return r
|
||||
})
|
||||
fireEvent.click(row)
|
||||
}
|
||||
}
|
||||
|
||||
describe('App (mock data, jsdom)', () => {
|
||||
it('renders the four-column workbench with the git change list', async () => {
|
||||
@@ -62,6 +74,7 @@ describe('App (mock data, jsdom)', () => {
|
||||
|
||||
it('makes an edited buffer dirty (breadcrumb dot)', async () => {
|
||||
const c = renderApp()
|
||||
await expandTo(c, 'public', 'assets')
|
||||
const treeRow = await waitFor(() => {
|
||||
const r = rowWithText(c, '.tree-row', 'store.js')
|
||||
if (!r) throw new Error('tree not ready')
|
||||
|
||||
Reference in New Issue
Block a user