justinpark commented on code in PR #34763:
URL: https://github.com/apache/superset/pull/34763#discussion_r2294787323
##########
superset-frontend/src/features/databases/UploadDataModel/UploadDataModal.test.tsx:
##########
@@ -661,3 +661,91 @@ describe('UploadDataModal Collapse Tabs', () => {
expect(generalInfoTab).toHaveAttribute('aria-expanded', 'true');
});
});
+
+test('Trino table name validation for table name with spaces', async () => {
+ fetchMock.get(
+
'glob:*api/v1/database/?q=(filters:!((col:allow_file_upload,opr:eq,value:!t)),page:0,page_size:100)',
+ {
+ result: [
+ {
+ id: 1,
+ database_name: 'Presto/Trino',
+ engine_name: 'trino',
+ },
+ {
+ id: 2,
+ database_name: 'Regular Database',
+ engine_name: 'postgresql',
+ },
+ ],
+ },
+ { overwriteRoutes: true },
+ );
+
+ render(<UploadDataModal {...csvProps} />, {
+ useRedux: true,
+ });
+ const selectDatabase = screen.getByRole('combobox', {
+ name: /select a database/i,
+ });
+ const inputTableName = screen.getByRole('textbox', {
+ name: /table name/i,
+ });
+ const uploadButton = screen.getByRole('button', {
+ name: 'Upload',
+ });
+
+ userEvent.click(selectDatabase);
+ await waitFor(() => screen.getByText('Presto/Trino'));
+ screen.getByText('Presto/Trino').click();
+ userEvent.type(inputTableName, 'table with spaces');
+ userEvent.click(uploadButton);
+ await waitFor(() =>
+ screen.getByText('Trino table names must not contain spaces'),
+ );
+});
+
+test('Trino table name passes for table name with no spaces', async () => {
+ fetchMock.get(
+
'glob:*api/v1/database/?q=(filters:!((col:allow_file_upload,opr:eq,value:!t)),page:0,page_size:100)',
+ {
+ result: [
+ {
+ id: 1,
+ database_name: 'Presto/Trino',
+ engine_name: 'trino',
+ },
+ {
+ id: 2,
+ database_name: 'Regular Database',
+ engine_name: 'postgresql',
+ },
+ ],
+ },
+ { overwriteRoutes: true },
+ );
Review Comment:
if you want the same mock each case, you could do with
```
beforeEach(() => {
fetchMock.get(...);
});
afterEach(() => {
fetchMock.reset();
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]