Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/debugger/debugviewcontroller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe("Debug View", () => {
beforeAll(() => {
jest.useFakeTimers()
jest.spyOn(DebugView, "render").mockImplementation()
jest.spyOn(DebugView, "setRootElement")
})

beforeEach(() => {
Expand Down Expand Up @@ -295,4 +296,38 @@ describe("Debug View", () => {
})
)
})

it("does not retain entries after hiding the view", () => {
const controller = new ViewController()
const chronicle = new Chronicle()
controller.showView()

chronicle.info("Only shown once")
controller.addEntries(chronicle.retrieve())
controller.hideView()
controller.showView()
controller.addEntries([])

jest.advanceTimersToNextTimer()

expect(DebugView.render).toHaveBeenLastCalledWith({ dynamic: [], static: [] })
})

it("uses the configured root element when showing the view for the second time", () => {
const rootElement = document.createElement("div")
const controller = new ViewController()

controller.setRootElement(rootElement)
controller.showView()
controller.hideView()
controller.showView()

const logBox = rootElement.querySelector("#logBox")
const staticBox = rootElement.querySelector("#staticBox")

expect(logBox).not.toBeNull()
expect(staticBox).not.toBeNull()
expect(logBox?.parentElement).toBe(rootElement)
expect(staticBox?.parentElement).toBe(rootElement)
})
})
4 changes: 4 additions & 0 deletions src/debugger/debugviewcontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ class DebugViewController {
public hideView(): void {
clearInterval(this.renderInterval)
DebugView.tearDown()
this.dynamicEntries = []
this.latestMetricByKey = {}
this.shouldRender = false
this.isVisible = false
}

Expand All @@ -579,6 +582,7 @@ class DebugViewController {
}

setRootElement(el: HTMLElement): void {
this.rootElement = el
DebugView.setRootElement(el)
}
}
Expand Down
Loading