fix(tab_bar): empty tabs not properly removed at app start

This commit is contained in:
Elian Doran 2025-04-02 21:13:41 +03:00
parent 0c5cd66eae
commit a8319fcbdf
No known key found for this signature in database
2 changed files with 19 additions and 1 deletions

View File

@ -82,3 +82,21 @@ test("Tabs are restored in right order", async ({ page, context }) => {
// Check the note tree has the right active node. // Check the note tree has the right active node.
await expect(app.noteTreeActiveNote).toContainText("Text notes"); await expect(app.noteTreeActiveNote).toContainText("Text notes");
}); });
test("Empty tabs are cleared out", async ({ page, context }) => {
const app = new App(page, context);
await app.goto();
// Open three tabs.
await app.closeAllTabs();
await app.addNewTab();
await app.goToNoteInNewTab("Code notes");
await app.addNewTab();
await app.addNewTab();
// Refresh the page and check the order.
await app.goto({ preserveTabs: true });
// Expect no empty tabs.
expect(await app.tabBar.locator(".note-tab-wrapper").count()).toBe(1);
});

View File

@ -75,7 +75,7 @@ export default class TabManager extends Component {
const filteredNoteContexts = noteContextsToOpen.filter((openTab: NoteContextState) => { const filteredNoteContexts = noteContextsToOpen.filter((openTab: NoteContextState) => {
const noteId = treeService.getNoteIdFromUrl(openTab.notePath); const noteId = treeService.getNoteIdFromUrl(openTab.notePath);
if (noteId && !(noteId in froca.notes)) { if (!noteId || !(noteId in froca.notes)) {
// note doesn't exist so don't try to open tab for it // note doesn't exist so don't try to open tab for it
return false; return false;
} }