|
1 | 1 | import {expect, test} from '@playwright/test'; |
2 | 2 |
|
3 | | -import {dsVslotsSchema, dsVslotsTableName, tenantName} from '../../../utils/constants'; |
| 3 | +import {wait} from '../../../../src/utils'; |
| 4 | +import { |
| 5 | + backend, |
| 6 | + dsStoragePoolsTableName, |
| 7 | + dsVslotsSchema, |
| 8 | + dsVslotsTableName, |
| 9 | + tenantName, |
| 10 | +} from '../../../utils/constants'; |
4 | 11 | import {TenantPage} from '../TenantPage'; |
5 | 12 | import {QueryEditor} from '../queryEditor/models/QueryEditor'; |
| 13 | +import {UnsavedChangesModal} from '../queryEditor/models/UnsavedChangesModal'; |
6 | 14 |
|
7 | 15 | import {ObjectSummary, ObjectSummaryTab} from './ObjectSummary'; |
8 | 16 | import {RowTableAction} from './types'; |
@@ -81,4 +89,75 @@ test.describe('Object Summary', async () => { |
81 | 89 | await expect(queryEditor.editorTextArea).toBeVisible(); |
82 | 90 | await expect(queryEditor.editorTextArea).not.toBeEmpty(); |
83 | 91 | }); |
| 92 | + |
| 93 | + test('Select and Upsert actions show loading state', async ({page}) => { |
| 94 | + await page.route(`${backend}/viewer/json/describe?*`, async (route) => { |
| 95 | + await wait(1000); |
| 96 | + await route.continue(); |
| 97 | + }); |
| 98 | + |
| 99 | + const objectSummary = new ObjectSummary(page); |
| 100 | + await expect(objectSummary.isTreeVisible()).resolves.toBe(true); |
| 101 | + |
| 102 | + // Open actions menu |
| 103 | + await objectSummary.clickActionsButton(dsStoragePoolsTableName); |
| 104 | + await expect(objectSummary.isActionsMenuVisible()).resolves.toBe(true); |
| 105 | + |
| 106 | + // Verify loading states |
| 107 | + await expect(objectSummary.isActionItemLoading(RowTableAction.SelectQuery)).resolves.toBe( |
| 108 | + true, |
| 109 | + ); |
| 110 | + await expect(objectSummary.isActionItemLoading(RowTableAction.UpsertQuery)).resolves.toBe( |
| 111 | + true, |
| 112 | + ); |
| 113 | + }); |
| 114 | + |
| 115 | + test('Monaco editor shows column list after select query loading completes', async ({page}) => { |
| 116 | + const objectSummary = new ObjectSummary(page); |
| 117 | + const queryEditor = new QueryEditor(page); |
| 118 | + |
| 119 | + await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.SelectQuery); |
| 120 | + |
| 121 | + const selectContent = await queryEditor.editorTextArea.inputValue(); |
| 122 | + expect(selectContent).toContain('SELECT'); |
| 123 | + expect(selectContent).toContain('FROM'); |
| 124 | + expect(selectContent).toMatch(/`\w+`,\s*`\w+`/); // At least two backticked columns |
| 125 | + }); |
| 126 | + |
| 127 | + test('Monaco editor shows column list after upsert query loading completes', async ({page}) => { |
| 128 | + const objectSummary = new ObjectSummary(page); |
| 129 | + const queryEditor = new QueryEditor(page); |
| 130 | + |
| 131 | + await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.UpsertQuery); |
| 132 | + |
| 133 | + const upsertContent = await queryEditor.editorTextArea.inputValue(); |
| 134 | + expect(upsertContent).toContain('UPSERT INTO'); |
| 135 | + expect(upsertContent).toContain('VALUES'); |
| 136 | + expect(upsertContent).toMatch(/\(\s*`\w+`\s*(,\s*`\w+`\s*)*\)/); // Backticked columns in parentheses |
| 137 | + }); |
| 138 | + |
| 139 | + test('Different tables show different column lists in Monaco editor', async ({page}) => { |
| 140 | + const objectSummary = new ObjectSummary(page); |
| 141 | + const queryEditor = new QueryEditor(page); |
| 142 | + const unsavedChangesModal = new UnsavedChangesModal(page); |
| 143 | + |
| 144 | + // Get columns for first table |
| 145 | + await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.SelectQuery); |
| 146 | + const vslotsColumns = await queryEditor.editorTextArea.inputValue(); |
| 147 | + |
| 148 | + // Get columns for second table |
| 149 | + await objectSummary.clickActionMenuItem( |
| 150 | + dsStoragePoolsTableName, |
| 151 | + RowTableAction.SelectQuery, |
| 152 | + ); |
| 153 | + |
| 154 | + await page.waitForTimeout(500); |
| 155 | + // Click Don't save in the modal |
| 156 | + await unsavedChangesModal.clickDontSave(); |
| 157 | + |
| 158 | + const storagePoolsColumns = await queryEditor.editorTextArea.inputValue(); |
| 159 | + |
| 160 | + // Verify the column lists are different |
| 161 | + expect(vslotsColumns).not.toEqual(storagePoolsColumns); |
| 162 | + }); |
84 | 163 | }); |
0 commit comments