sqlite-hub 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +17 -196
  2. package/bin/sqlite-hub.js +7 -2
  3. package/frontend/js/api.js +60 -0
  4. package/frontend/js/app.js +201 -5
  5. package/frontend/js/components/dropdownButton.js +92 -0
  6. package/frontend/js/components/modal.js +991 -876
  7. package/frontend/js/components/queryEditor.js +24 -15
  8. package/frontend/js/components/queryHistoryDetail.js +20 -1
  9. package/frontend/js/components/queryHistoryHeader.js +3 -2
  10. package/frontend/js/components/queryResults.js +1 -1
  11. package/frontend/js/components/rowEditorPanel.js +53 -13
  12. package/frontend/js/components/sidebar.js +1 -0
  13. package/frontend/js/components/topNav.js +1 -4
  14. package/frontend/js/components/workspaceOpenDropdown.js +52 -0
  15. package/frontend/js/router.js +2 -0
  16. package/frontend/js/store.js +450 -38
  17. package/frontend/js/utils/emailPreview.js +28 -0
  18. package/frontend/js/utils/markdownDocuments.js +17 -1
  19. package/frontend/js/utils/riskySql.js +165 -0
  20. package/frontend/js/views/backups.js +204 -0
  21. package/frontend/js/views/charts.js +1 -1
  22. package/frontend/js/views/data.js +42 -16
  23. package/frontend/js/views/documents.js +184 -154
  24. package/frontend/js/views/settings.js +1 -0
  25. package/frontend/js/views/structure.js +47 -33
  26. package/frontend/js/views/tableDesigner.js +23 -0
  27. package/frontend/styles/components.css +133 -0
  28. package/frontend/styles/tailwind.generated.css +1 -1
  29. package/frontend/styles/tokens.css +1 -0
  30. package/frontend/styles/views.css +33 -21
  31. package/package.json +2 -1
  32. package/server/routes/backups.js +120 -0
  33. package/server/routes/connections.js +26 -3
  34. package/server/routes/externalApi.js +6 -2
  35. package/server/server.js +3 -1
  36. package/server/services/databaseCommandService.js +4 -3
  37. package/server/services/sqlite/backupService.js +497 -66
  38. package/server/services/sqlite/connectionManager.js +2 -2
  39. package/server/services/sqlite/importService.js +25 -0
  40. package/server/services/sqlite/sqlExecutor.js +2 -0
  41. package/server/services/storage/appStateStore.js +379 -88
  42. package/tests/api-token-auth.test.js +45 -2
  43. package/tests/backup-manager.test.js +140 -0
  44. package/tests/backups-view.test.js +70 -0
  45. package/tests/charts-height-preset-storage.test.js +60 -0
  46. package/tests/charts-route-state.test.js +144 -0
  47. package/tests/cli-service-delegation.test.js +97 -0
  48. package/tests/connection-removal.test.js +52 -0
  49. package/tests/database-command-service.test.js +37 -2
  50. package/tests/documents-view.test.js +132 -0
  51. package/tests/dropdown-button.test.js +101 -0
  52. package/tests/email-preview.test.js +89 -0
  53. package/tests/markdown-documents.test.js +24 -0
  54. package/tests/query-editor.test.js +28 -0
  55. package/tests/query-history-detail.test.js +37 -0
  56. package/tests/query-history-header.test.js +30 -0
  57. package/tests/risky-sql.test.js +30 -0
  58. package/tests/row-editor-null-values.test.js +53 -0
  59. package/tests/settings-view.test.js +1 -0
  60. package/tests/structure-view.test.js +60 -0
@@ -0,0 +1,132 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ let documentsViewModulePromise = null;
7
+
8
+ function loadDocumentsViewModule() {
9
+ if (!documentsViewModulePromise) {
10
+ documentsViewModulePromise = import(
11
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/views/documents.js")).href
12
+ );
13
+ }
14
+
15
+ return documentsViewModulePromise;
16
+ }
17
+
18
+ function buildDocumentsState() {
19
+ return {
20
+ connections: {
21
+ active: { id: "db-one", label: "Database One" },
22
+ },
23
+ documents: {
24
+ items: [],
25
+ selectedId: null,
26
+ selected: null,
27
+ searchQuery: "",
28
+ draftFilename: "",
29
+ draftContent: "",
30
+ dirty: false,
31
+ documentsVisible: true,
32
+ editorVisible: true,
33
+ previewVisible: true,
34
+ loading: false,
35
+ detailLoading: false,
36
+ saving: false,
37
+ deleting: false,
38
+ error: null,
39
+ saveError: null,
40
+ },
41
+ };
42
+ }
43
+
44
+ function buildSelectedDocumentsState(overrides = {}) {
45
+ const state = buildDocumentsState();
46
+ state.documents.items = [
47
+ {
48
+ contentLength: 11,
49
+ filename: "notes.md",
50
+ id: "doc-one",
51
+ title: "Notes",
52
+ updatedAt: "2026-06-21T10:00:00.000Z",
53
+ },
54
+ ];
55
+ state.documents.selectedId = "doc-one";
56
+ state.documents.selected = state.documents.items[0];
57
+ state.documents.draftFilename = "notes.md";
58
+ state.documents.draftContent = "# Notes";
59
+ Object.assign(state.documents, overrides);
60
+
61
+ return state;
62
+ }
63
+
64
+ test("documents view uses a new document dropdown for blank and markdown import", async () => {
65
+ const { renderDocumentsView } = await loadDocumentsViewModule();
66
+ const { main } = renderDocumentsView(buildDocumentsState());
67
+
68
+ assert.match(main, /data-dropdown-button/);
69
+ assert.match(main, /New Document/);
70
+ assert.match(main, /Blank Page/);
71
+ assert.match(main, /data-action="create-document"/);
72
+ assert.match(main, /Import \.md/);
73
+ assert.match(main, /data-action="import-document-markdown"/);
74
+ assert.match(main, /data-bind="document-import-file"/);
75
+ assert.doesNotMatch(main, /data-form="new-document"/);
76
+ });
77
+
78
+ test("documents panes keep both headers visible and move pane toggles into headers", async () => {
79
+ const { renderDocumentsView } = await loadDocumentsViewModule();
80
+ const { main } = renderDocumentsView(
81
+ buildSelectedDocumentsState({
82
+ editorVisible: false,
83
+ previewVisible: true,
84
+ }),
85
+ );
86
+
87
+ assert.match(main, /documents-workspace--editor-collapsed/);
88
+ assert.match(main, /documents-pane--editor documents-pane--collapsed/);
89
+ assert.match(main, /data-pane="editor"/);
90
+ assert.match(main, /Show Editor/);
91
+ assert.match(main, /data-pane="preview"/);
92
+ assert.match(main, /Hide Preview/);
93
+ assert.doesNotMatch(main, />Editor<\/span>/);
94
+ assert.doesNotMatch(main, />Preview<\/span>/);
95
+ });
96
+
97
+ test("documents subnavi can be hidden while the show documents button stays available", async () => {
98
+ const { renderDocumentsView } = await loadDocumentsViewModule();
99
+ const { main } = renderDocumentsView(
100
+ buildSelectedDocumentsState({
101
+ documentsVisible: false,
102
+ }),
103
+ );
104
+
105
+ assert.doesNotMatch(main, /documents-view__sidebar/);
106
+ assert.match(main, /data-action="toggle-documents-panel"/);
107
+ assert.match(main, /Show Documents/);
108
+ assert.match(main, /aria-pressed="true"/);
109
+ });
110
+
111
+ test("selected document actions render in one titlebar without a save button", async () => {
112
+ const { renderDocumentsView } = await loadDocumentsViewModule();
113
+ const { main } = renderDocumentsView(buildSelectedDocumentsState());
114
+ const orderedFragments = [
115
+ 'data-action="toggle-documents-panel"',
116
+ 'data-bind="document-field"',
117
+ "New Document",
118
+ "Insert",
119
+ "Export .md",
120
+ "Delete",
121
+ ];
122
+ const indexes = orderedFragments.map(fragment => main.indexOf(fragment));
123
+
124
+ indexes.forEach(index => assert.notEqual(index, -1));
125
+
126
+ for (let index = 1; index < indexes.length; index += 1) {
127
+ assert.ok(indexes[index - 1] < indexes[index]);
128
+ }
129
+
130
+ assert.doesNotMatch(main, /documents-toolbar/);
131
+ assert.doesNotMatch(main, /data-action="save-document"/);
132
+ });
@@ -0,0 +1,101 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ let dropdownButtonModulePromise = null;
7
+
8
+ function loadDropdownButtonModule() {
9
+ if (!dropdownButtonModulePromise) {
10
+ dropdownButtonModulePromise = import(
11
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/components/dropdownButton.js")).href
12
+ );
13
+ }
14
+
15
+ return dropdownButtonModulePromise;
16
+ }
17
+
18
+ test("dropdown button renders reusable action items", async () => {
19
+ const { renderDropdownButton } = await loadDropdownButtonModule();
20
+ const markup = renderDropdownButton({
21
+ icon: "add_box",
22
+ label: "Insert",
23
+ title: "Insert content",
24
+ items: [
25
+ {
26
+ action: "open-document-insert-table-modal",
27
+ dataAttributes: { sourceView: "documents" },
28
+ icon: "table_chart",
29
+ label: "Insert Table",
30
+ },
31
+ {
32
+ action: "open-document-insert-note-modal",
33
+ icon: "note_add",
34
+ label: "Insert Note",
35
+ },
36
+ ],
37
+ });
38
+
39
+ assert.match(markup, /data-dropdown-button/);
40
+ assert.match(markup, /dropdown-button__toggle/);
41
+ assert.match(markup, /dropdown-button__panel/);
42
+ assert.match(markup, /data-action="open-document-insert-table-modal"/);
43
+ assert.match(markup, /data-source-view="documents"/);
44
+ assert.match(markup, /Insert Note/);
45
+ });
46
+
47
+ test("dropdown button renders disabled as a real disabled button", async () => {
48
+ const { renderDropdownButton } = await loadDropdownButtonModule();
49
+ const markup = renderDropdownButton({
50
+ disabled: true,
51
+ label: "Insert",
52
+ items: [{ action: "noop", label: "Noop" }],
53
+ });
54
+
55
+ assert.doesNotMatch(markup, /<details/);
56
+ assert.match(markup, /disabled/);
57
+ assert.match(markup, /aria-disabled="true"/);
58
+ });
59
+
60
+ test("dropdown button supports local action attributes", async () => {
61
+ const { renderDropdownButton } = await loadDropdownButtonModule();
62
+ const markup = renderDropdownButton({
63
+ label: "Format",
64
+ items: [
65
+ {
66
+ action: "fit",
67
+ actionAttribute: "data-structure-graph-action",
68
+ label: "Fit Graph",
69
+ },
70
+ ],
71
+ });
72
+
73
+ assert.match(markup, /data-structure-graph-action="fit"/);
74
+ assert.doesNotMatch(markup, /data-action="fit"/);
75
+ });
76
+
77
+ test("workspace open dropdown renders navigation and SQL editor actions", async () => {
78
+ const { renderWorkspaceOpenDropdown } = await import(
79
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/components/workspaceOpenDropdown.js")).href
80
+ );
81
+ const markup = renderWorkspaceOpenDropdown({
82
+ tableName: "companies",
83
+ destinations: [
84
+ {
85
+ icon: "account_tree",
86
+ key: "structure",
87
+ label: "Structure",
88
+ target: tableName => `/structure/${encodeURIComponent(tableName)}`,
89
+ },
90
+ {
91
+ key: "sql-editor",
92
+ },
93
+ ],
94
+ });
95
+
96
+ assert.match(markup, /data-dropdown-button/);
97
+ assert.match(markup, /data-action="navigate"/);
98
+ assert.match(markup, /data-to="\/structure\/companies"/);
99
+ assert.match(markup, /data-action="open-table-in-sql-editor"/);
100
+ assert.match(markup, /data-table-name="companies"/);
101
+ });
@@ -0,0 +1,89 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ async function loadEmailPreviewModule() {
7
+ return import(pathToFileURL(path.resolve(__dirname, "../frontend/js/utils/emailPreview.js")).href);
8
+ }
9
+
10
+ async function loadDataViewModule() {
11
+ return import(pathToFileURL(path.resolve(__dirname, "../frontend/js/views/data.js")).href);
12
+ }
13
+
14
+ async function loadRowEditorPanelModule() {
15
+ return import(pathToFileURL(path.resolve(__dirname, "../frontend/js/components/rowEditorPanel.js")).href);
16
+ }
17
+
18
+ test("email preview detects simple email values only", async () => {
19
+ const { detectEmailValue } = await loadEmailPreviewModule();
20
+
21
+ assert.deepEqual(detectEmailValue("oli@example.com"), {
22
+ type: "email",
23
+ value: "oli@example.com",
24
+ localPart: "oli",
25
+ domain: "example.com",
26
+ });
27
+ assert.equal(detectEmailValue("https://example.com"), null);
28
+ assert.equal(detectEmailValue("not an email"), null);
29
+ assert.equal(detectEmailValue(null), null);
30
+ });
31
+
32
+ test("data table renders an email icon for email cells", async () => {
33
+ const { renderDataView } = await loadDataViewModule();
34
+ const rendered = renderDataView({
35
+ connections: {
36
+ active: { readOnly: false },
37
+ },
38
+ dataBrowser: {
39
+ error: null,
40
+ loading: false,
41
+ page: 1,
42
+ pageSize: 50,
43
+ selectedRowIndex: null,
44
+ selectedTable: "contacts",
45
+ tableSearchQuery: "",
46
+ tables: [{ name: "contacts", columnCount: 2 }],
47
+ tablesVisible: true,
48
+ table: {
49
+ name: "contacts",
50
+ columns: ["id", "email"],
51
+ columnMeta: [
52
+ { name: "id", visible: true, primaryKeyPosition: 1, affinity: "INTEGER" },
53
+ { name: "email", visible: true, affinity: "TEXT" },
54
+ ],
55
+ foreignKeys: [],
56
+ rows: [{ id: 1, email: "oli@example.com" }],
57
+ rowCount: 1,
58
+ page: 1,
59
+ pageCount: 1,
60
+ offset: 0,
61
+ limit: 50,
62
+ },
63
+ },
64
+ }).main;
65
+
66
+ assert.match(rendered, /alternate_email/);
67
+ assert.match(rendered, /oli@example\.com/);
68
+ });
69
+
70
+ test("row editor renders an email badge for email fields", async () => {
71
+ const { renderRowEditorPanel } = await loadRowEditorPanelModule();
72
+ const rendered = renderRowEditorPanel({
73
+ title: "contacts",
74
+ closeAction: "close",
75
+ formName: "save-data-row",
76
+ editableFields: [
77
+ {
78
+ name: "email",
79
+ label: "email",
80
+ badges: [{ label: "TEXT", tone: "type" }],
81
+ value: "oli@example.com",
82
+ rawValue: "oli@example.com",
83
+ },
84
+ ],
85
+ });
86
+
87
+ assert.match(rendered, /EMAIL/);
88
+ assert.match(rendered, /data-row-editor-email-field/);
89
+ });
@@ -60,6 +60,30 @@ test("markdown preview escapes raw html content", async () => {
60
60
  assert.match(html, /&lt;script&gt;/);
61
61
  });
62
62
 
63
+ test("markdown preview keeps JSON code block quotes readable", async () => {
64
+ const { renderMarkdownPreview } = await loadMarkdownModule();
65
+ const previousMarked = globalThis.marked;
66
+ let parsedSource = "";
67
+
68
+ globalThis.marked = {
69
+ parse: source => {
70
+ parsedSource = source;
71
+ return `<pre><code>${source}</code></pre>`;
72
+ },
73
+ };
74
+
75
+ try {
76
+ const html = renderMarkdownPreview(['<img src=x onerror="alert(1)">', '', '```json', '{"id":"abc"}', '```'].join("\n"));
77
+
78
+ assert.match(parsedSource, /&lt;img/);
79
+ assert.match(parsedSource, /"id":"abc"/);
80
+ assert.doesNotMatch(parsedSource, /&quot;id&quot;/);
81
+ assert.match(html, /"id":"abc"/);
82
+ } finally {
83
+ globalThis.marked = previousMarked;
84
+ }
85
+ });
86
+
63
87
  test("markdown preview strips executable link targets from rendered markdown", async () => {
64
88
  const { renderMarkdownPreview } = await loadMarkdownModule();
65
89
  const previousMarked = globalThis.marked;
@@ -0,0 +1,28 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ let queryEditorModulePromise = null;
7
+
8
+ function loadQueryEditorModule() {
9
+ if (!queryEditorModulePromise) {
10
+ queryEditorModulePromise = import(
11
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/components/queryEditor.js")).href
12
+ );
13
+ }
14
+
15
+ return queryEditorModulePromise;
16
+ }
17
+
18
+ test("query editor groups editor actions in a reusable dropdown", async () => {
19
+ const { renderQueryEditor } = await loadQueryEditorModule();
20
+ const markup = renderQueryEditor({ query: "select * from companies;" });
21
+
22
+ assert.match(markup, /data-dropdown-button/);
23
+ assert.match(markup, /Editor actions/);
24
+ assert.match(markup, /data-action="format-current-query"/);
25
+ assert.match(markup, /data-action="clear-query"/);
26
+ assert.match(markup, /data-action="copy-current-query"/);
27
+ assert.match(markup, /Copy to Clipboard/);
28
+ });
@@ -0,0 +1,37 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ let queryHistoryDetailModulePromise = null;
7
+
8
+ function loadQueryHistoryDetailModule() {
9
+ if (!queryHistoryDetailModulePromise) {
10
+ queryHistoryDetailModulePromise = import(
11
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/components/queryHistoryDetail.js")).href
12
+ );
13
+ }
14
+
15
+ return queryHistoryDetailModulePromise;
16
+ }
17
+
18
+ test("query history detail delete button renders a trash icon", async () => {
19
+ const { renderQueryHistoryDetail } = await loadQueryHistoryDetailModule();
20
+ const html = renderQueryHistoryDetail({
21
+ item: {
22
+ id: 42,
23
+ displayTitle: "Recent Query",
24
+ rawSql: "select * from companies;",
25
+ queryType: "select",
26
+ isSaved: false,
27
+ isDestructive: false,
28
+ executionCount: 1,
29
+ createdAt: "2026-06-21T10:00:00.000Z",
30
+ updatedAt: "2026-06-21T10:00:00.000Z",
31
+ },
32
+ runs: [],
33
+ });
34
+
35
+ assert.match(html, /data-action="open-delete-query-history-modal"/);
36
+ assert.match(html, /<span class="material-symbols-outlined text-sm">delete<\/span>Delete/);
37
+ });
@@ -0,0 +1,30 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ let queryHistoryHeaderModulePromise = null;
7
+
8
+ function loadQueryHistoryHeaderModule() {
9
+ if (!queryHistoryHeaderModulePromise) {
10
+ queryHistoryHeaderModulePromise = import(
11
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/components/queryHistoryHeader.js")).href
12
+ );
13
+ }
14
+
15
+ return queryHistoryHeaderModulePromise;
16
+ }
17
+
18
+ test("query history search renders a magnifier icon", async () => {
19
+ const { renderQueryHistorySearch } = await loadQueryHistoryHeaderModule();
20
+ const markup = renderQueryHistorySearch({
21
+ bind: "charts-history-search",
22
+ value: "revenue",
23
+ });
24
+
25
+ assert.match(markup, /query-history-search/);
26
+ assert.match(markup, /query-history-search__icon/);
27
+ assert.match(markup, />search<\/span>/);
28
+ assert.match(markup, /data-bind="charts-history-search"/);
29
+ assert.match(markup, /value="revenue"/);
30
+ });
@@ -0,0 +1,30 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ async function loadModule() {
7
+ return import(pathToFileURL(path.resolve(__dirname, "../frontend/js/utils/riskySql.js")).href);
8
+ }
9
+
10
+ test("risky SQL detector ignores selects and detects schema changes", async () => {
11
+ const { detectRiskySqlOperations } = await loadModule();
12
+
13
+ assert.deepEqual(detectRiskySqlOperations("SELECT * FROM companies"), []);
14
+ assert.equal(detectRiskySqlOperations(" ALTER TABLE companies ADD COLUMN ticker TEXT")[0].type, "schema_change");
15
+ });
16
+
17
+ test("risky SQL detector handles comments, case, multiple statements, and drop table names", async () => {
18
+ const { detectRiskySqlOperations } = await loadModule();
19
+ const operations = detectRiskySqlOperations(`
20
+ -- DROP TABLE ignored;
21
+ select 1;
22
+ /* comment */ drop table if exists "users";
23
+ create index idx_users_name on users(name);
24
+ `);
25
+
26
+ assert.equal(operations.length, 2);
27
+ assert.equal(operations[0].type, "drop_table");
28
+ assert.equal(operations[0].tableName, "users");
29
+ assert.equal(operations[1].type, "migration");
30
+ });
@@ -82,6 +82,59 @@ test("row editor renders visible NULL and empty-string states", async () => {
82
82
  assert.doesNotMatch(html, /name="field:nullable_text"[\s\S]*?disabled/);
83
83
  });
84
84
 
85
+ test("row editor delete button renders a trash icon", async () => {
86
+ const { renderRowEditorPanel } = await loadFrontendModule(
87
+ "../frontend/js/components/rowEditorPanel.js"
88
+ );
89
+ const html = renderRowEditorPanel({
90
+ title: "Values",
91
+ closeAction: "close",
92
+ formName: "save-data-row",
93
+ deleteAction: "delete-data-row",
94
+ deleteEnabled: true,
95
+ deleteRowIndex: 0,
96
+ editableFields: [
97
+ {
98
+ name: "title",
99
+ label: "title",
100
+ value: "Acme",
101
+ },
102
+ ],
103
+ });
104
+
105
+ assert.match(html, /class="delete-button"[^>]*data-action="delete-data-row"/);
106
+ assert.match(html, /<span class="material-symbols-outlined text-sm">delete<\/span>\s*Delete Row/);
107
+ });
108
+
109
+ test("row editor JSON actions render as an export dropdown", async () => {
110
+ const { renderRowEditorPanel } = await loadFrontendModule(
111
+ "../frontend/js/components/rowEditorPanel.js"
112
+ );
113
+ const html = renderRowEditorPanel({
114
+ title: "Values",
115
+ closeAction: "close",
116
+ formName: "save-data-row",
117
+ jsonActionsEnabled: true,
118
+ editableFields: [
119
+ {
120
+ name: "title",
121
+ label: "title",
122
+ value: "Acme",
123
+ },
124
+ ],
125
+ });
126
+
127
+ assert.match(html, /data-dropdown-button/);
128
+ assert.match(html, /Export/);
129
+ assert.match(html, /data-action="copy-row-editor-json"/);
130
+ assert.match(html, /Copy to clipboard/);
131
+ assert.match(html, /data-action="export-row-editor-json"/);
132
+ assert.match(html, /JSON file/);
133
+ assert.match(html, /data-action="insert-row-editor-json-into-document"/);
134
+ assert.match(html, /Markdown document/);
135
+ assert.doesNotMatch(html, /Copy as JSON|Export as JSON/);
136
+ });
137
+
85
138
  test("data updates can change NULL to empty string and empty string to NULL", () => {
86
139
  const db = new Database(":memory:");
87
140
 
@@ -100,6 +100,7 @@ test("settings view scopes API token controls to the active database", async ()
100
100
  assert.match(rendered.main, /name="name"/);
101
101
  assert.match(rendered.main, /type="submit"/);
102
102
  assert.match(rendered.main, /data-action="open-delete-api-token-modal"/);
103
+ assert.match(rendered.main, /<span class="material-symbols-outlined text-sm">delete<\/span>\s*Delete/);
103
104
  assert.match(rendered.main, /bg-surface-container-lowest/);
104
105
  assert.doesNotMatch(rendered.main, /sqlite-hub --port:PORT/);
105
106
  assert.doesNotMatch(rendered.main, /Open Github/);
@@ -0,0 +1,60 @@
1
+ const assert = require("node:assert/strict");
2
+ const path = require("node:path");
3
+ const { pathToFileURL } = require("node:url");
4
+ const test = require("node:test");
5
+
6
+ let structureViewModulePromise = null;
7
+
8
+ function loadStructureViewModule() {
9
+ if (!structureViewModulePromise) {
10
+ structureViewModulePromise = import(
11
+ pathToFileURL(path.resolve(__dirname, "../frontend/js/views/structure.js")).href
12
+ );
13
+ }
14
+
15
+ return structureViewModulePromise;
16
+ }
17
+
18
+ function buildStructureState() {
19
+ return {
20
+ structure: {
21
+ data: {
22
+ grouped: {
23
+ tables: [{ name: "companies", type: "table" }],
24
+ views: [],
25
+ indexes: [],
26
+ triggers: [],
27
+ },
28
+ graph: {
29
+ relationshipCount: 0,
30
+ tables: [{ name: "companies", type: "table", columns: [], foreignKeys: [] }],
31
+ },
32
+ },
33
+ detail: null,
34
+ detailLoading: false,
35
+ error: null,
36
+ loading: false,
37
+ selectedName: "companies",
38
+ tableSearchQuery: "",
39
+ tablesVisible: true,
40
+ },
41
+ };
42
+ }
43
+
44
+ test("structure toolbar groups graph format actions in a dropdown", async () => {
45
+ const { renderStructureView } = await loadStructureViewModule();
46
+ const { main } = renderStructureView(buildStructureState());
47
+
48
+ assert.match(main, /data-dropdown-button/);
49
+ assert.match(main, /Open companies/);
50
+ assert.match(main, /data-to="\/data\/companies"/);
51
+ assert.match(main, /data-to="\/table-designer\/companies"/);
52
+ assert.match(main, /data-action="open-table-in-sql-editor"/);
53
+ assert.match(main, /Format graph/);
54
+ assert.match(main, /Fit Graph/);
55
+ assert.match(main, /data-structure-graph-action="fit"/);
56
+ assert.match(main, /Recalculate Layout/);
57
+ assert.match(main, /data-structure-graph-action="relayout"/);
58
+ assert.match(main, /Clear Selection/);
59
+ assert.match(main, /data-structure-graph-action="clear"/);
60
+ });