@@ -10,21 +10,24 @@ const tables = [
10
10
"gitlog" ,
11
11
] ;
12
12
13
+ const materializedViews = [ "btc_trades_mv" ] ;
14
+
13
15
describe ( "questdb schema with working tables" , ( ) => {
14
16
before ( ( ) => {
15
17
cy . loadConsoleWithAuth ( ) ;
16
18
17
19
tables . forEach ( ( table ) => {
18
20
cy . createTable ( table ) ;
19
21
} ) ;
22
+ cy . expandTables ( ) ;
20
23
cy . refreshSchema ( ) ;
21
24
} ) ;
22
25
it ( "should show all the tables when there are no suspended" , ( ) => {
23
26
tables . forEach ( ( table ) => {
24
27
cy . getByDataHook ( "schema-table-title" ) . should ( "contain" , table ) ;
25
28
} ) ;
26
29
cy . getByDataHook ( "schema-filter-suspended-button" ) . should ( "not.exist" ) ;
27
- cy . getByDataHook ( "schema-suspension-popover-trigger " ) . should ( "not.exist" ) ;
30
+ cy . getByDataHook ( "schema-row-error-icon " ) . should ( "not.exist" ) ;
28
31
} ) ;
29
32
30
33
it ( "should filter the table with input field" , ( ) => {
@@ -75,6 +78,7 @@ describe("questdb schema with suspended tables with Linux OS error codes", () =>
75
78
} ) ;
76
79
beforeEach ( ( ) => {
77
80
cy . loadConsoleWithAuth ( ) ;
81
+ cy . expandTables ( ) ;
78
82
} ) ;
79
83
80
84
it ( "should work with 2 suspended tables, btc_trades and ecommerce_stats" , ( ) => {
@@ -97,9 +101,11 @@ describe("questdb schema with suspended tables with Linux OS error codes", () =>
97
101
cy . getByDataHook ( "schema-filter-suspended-button" ) . click ( ) ;
98
102
} ) ;
99
103
100
- it ( "should show the suspension dialog on click with details for btc_trades" , ( ) => {
101
- cy . get ( 'input[name="table_filter"]' ) . click ( ) . type ( "btc_trades" ) ;
102
- cy . getByDataHook ( "schema-suspension-dialog-trigger" ) . click ( ) ;
104
+ it ( "should show the suspension dialog on context menu click with details for btc_trades" , ( ) => {
105
+ cy . getByDataHook ( "schema-table-title" ) . contains ( "btc_trades" ) . rightclick ( ) ;
106
+ cy . getByDataHook ( "table-context-menu-resume-wal" )
107
+ . filter ( ":visible" )
108
+ . click ( ) ;
103
109
cy . getByDataHook ( "schema-suspension-dialog" ) . should (
104
110
"have.attr" ,
105
111
"data-table-name" ,
@@ -117,8 +123,10 @@ describe("questdb schema with suspended tables with Linux OS error codes", () =>
117
123
} ) ;
118
124
119
125
it ( "should resume WAL for btc_trades from the suspension popover" , ( ) => {
120
- cy . get ( 'input[name="table_filter"]' ) . click ( ) . type ( "btc_trades" ) ;
121
- cy . contains ( "Suspended" ) . click ( ) ;
126
+ cy . getByDataHook ( "schema-table-title" ) . contains ( "btc_trades" ) . rightclick ( ) ;
127
+ cy . getByDataHook ( "table-context-menu-resume-wal" )
128
+ . filter ( ":visible" )
129
+ . click ( ) ;
122
130
cy . getByDataHook ( "schema-suspension-dialog-restart-transaction" ) . click ( ) ;
123
131
cy . getByDataHook ( "schema-suspension-dialog-dismiss" ) . click ( ) ;
124
132
cy . getByDataHook ( "schema-suspension-dialog" ) . should ( "not.exist" ) ;
@@ -144,6 +152,7 @@ describe("table select UI", () => {
144
152
} ) ;
145
153
beforeEach ( ( ) => {
146
154
cy . loadConsoleWithAuth ( ) ;
155
+ cy . expandTables ( ) ;
147
156
} ) ;
148
157
149
158
it ( "should show select ui on click" , ( ) => {
@@ -208,3 +217,95 @@ describe("questdb schema in read-only mode", () => {
208
217
cy . getByDataHook ( "create-table-panel" ) . should ( "not.exist" ) ;
209
218
} ) ;
210
219
} ) ;
220
+
221
+ describe ( "materialized views" , ( ) => {
222
+ before ( ( ) => {
223
+ cy . loadConsoleWithAuth ( ) ;
224
+
225
+ tables . forEach ( ( table ) => {
226
+ cy . createTable ( table ) ;
227
+ } ) ;
228
+ materializedViews . forEach ( ( mv ) => {
229
+ cy . createMaterializedView ( mv ) ;
230
+ } ) ;
231
+ cy . refreshSchema ( ) ;
232
+ } ) ;
233
+
234
+ afterEach ( ( ) => {
235
+ cy . collapseTables ( ) ;
236
+ cy . collapseMatViews ( ) ;
237
+ } ) ;
238
+
239
+ it ( "should create materialized views" , ( ) => {
240
+ cy . getByDataHook ( "expand-tables" ) . contains ( `Tables (${ tables . length } )` ) ;
241
+ cy . getByDataHook ( "expand-materialized-views" ) . contains (
242
+ `Materialized views (${ materializedViews . length } )`
243
+ ) ;
244
+
245
+ cy . expandTables ( ) ;
246
+ cy . getByDataHook ( "schema-table-title" ) . should ( "contain" , "btc_trades" ) ;
247
+ cy . expandMatViews ( ) ;
248
+ cy . getByDataHook ( "schema-matview-title" ) . should ( "contain" , "btc_trades_mv" ) ;
249
+ } ) ;
250
+
251
+ it ( "should show the base table and copy DDL for a materialized view" , ( ) => {
252
+ cy . expandMatViews ( ) ;
253
+ cy . getByDataHook ( "schema-matview-title" ) . contains ( "btc_trades_mv" ) . click ( ) ;
254
+ cy . getByDataHook ( "base-table-name" ) . contains ( "btc_trades" ) . should ( "exist" ) ;
255
+ cy . getByDataHook ( "schema-matview-title" )
256
+ . contains ( "btc_trades_mv" )
257
+ . rightclick ( ) ;
258
+ cy . getByDataHook ( "table-context-menu-copy-schema" )
259
+ . filter ( ":visible" )
260
+ . click ( ) ;
261
+
262
+ if ( Cypress . isBrowser ( "electron" ) ) {
263
+ cy . window ( )
264
+ . its ( "navigator.clipboard" )
265
+ . invoke ( "readText" )
266
+ . should (
267
+ "match" ,
268
+ / ^ C R E A T E M A T E R I A L I Z E D V I E W .* ' b t c _ t r a d e s _ m v ' W I T H B A S E ' b t c _ t r a d e s ' /
269
+ ) ;
270
+ }
271
+ } ) ;
272
+
273
+ it ( "should show a warning icon and tooltip when the view is invalidated" , ( ) => {
274
+ cy . intercept ( {
275
+ method : "GET" ,
276
+ pathname : "/exec" ,
277
+ query : {
278
+ query : "materialized_views()" ,
279
+ } ,
280
+ } ,
281
+ ( req ) => {
282
+ req . continue ( ( res ) => {
283
+ // [view_name, refresh_type, base_table_name, last_refresh_timestamp, view_sql, view_table_dir_name, invalidation_reason, view_status, base_table_txn, applied_base_table_txn]
284
+ res . body . dataset [ 0 ] [ 6 ] = "this is an invalidation reason" ;
285
+ res . body . dataset [ 0 ] [ 7 ] = "invalid" ;
286
+ return res ;
287
+ } ) ;
288
+ }
289
+ ) ;
290
+ cy . refreshSchema ( ) ;
291
+ cy . expandMatViews ( ) ;
292
+ cy . getByDataHook ( "schema-row-error-icon" ) . trigger ( "mouseover" ) ;
293
+
294
+ cy . getByDataHook ( "tooltip" ) . should (
295
+ "contain" ,
296
+ "Materialized view is invalid: this is an invalidation reason"
297
+ ) ;
298
+ } ) ;
299
+
300
+ after ( ( ) => {
301
+ cy . loadConsoleWithAuth ( ) ;
302
+
303
+ materializedViews . forEach ( ( mv ) => {
304
+ cy . dropMaterializedView ( mv ) ;
305
+ } ) ;
306
+
307
+ tables . forEach ( ( table ) => {
308
+ cy . dropTableIfExists ( table ) ;
309
+ } ) ;
310
+ } ) ;
311
+ } ) ;
0 commit comments