From 3eb6db8e150e2d7f6424d1d4c4fce5103a2989c4 Mon Sep 17 00:00:00 2001
From: Lyndsi Kay Williams <55605634+lyndsiWilliams@users.noreply.github.com>
Date: Tue, 29 Jun 2021 15:44:26 -0500
Subject: [PATCH] fix: Database connection modal touch up (#15463)
* Removed unnecessary TODO and named the remaining ones
* Added translation functionality
* Fixed typo in Database Modal RTL test
---
.../integration/database/modal.test.ts | 1 -
.../DatabaseModal/DatabaseConnectionForm.tsx | 20 +++++++++----------
.../database/DatabaseModal/index.test.jsx | 10 +++++-----
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/superset-frontend/cypress-base/cypress/integration/database/modal.test.ts b/superset-frontend/cypress-base/cypress/integration/database/modal.test.ts
index 5a5a97ef47817..57453650f196f 100644
--- a/superset-frontend/cypress-base/cypress/integration/database/modal.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/database/modal.test.ts
@@ -17,7 +17,6 @@
* under the License.
*/
import { DATABASE_LIST } from './helper';
-// TODO: Add new tests with the modal
describe('Add database', () => {
beforeEach(() => {
cy.login();
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
index 8a9945d95065f..80527f0c0ae68 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
@@ -85,7 +85,7 @@ const CredentialsInfo = ({
{!isEditMode && (
<>
- How do you want to enter service account credentials?
+ `${t('How do you want to enter service account credentials?')}`
>
@@ -106,7 +106,7 @@ const CredentialsInfo = ({
isEditMode ||
editNewDb ? (
- Service Account
+ `${t('Service Account')}`
- Copy and paste the entire service account .json file here
+ `${t('Copy and paste the entire service account .json file here')}`
- Upload Credentials
+ `${t('Upload Credentials')}` document?.getElementById('selectedFile')?.click()}
>
- Choose File
+ `${t('Choose File')}`
)}
{fileToUpload && (
@@ -257,7 +257,7 @@ const databaseField = ({
placeholder="e.g. world_population"
label="Database name"
onChange={changeMethods.onParametersChange}
- helpText="Copy the name of the database you are trying to connect to."
+ helpText={t('Copy the name of the database you are trying to connect to.')}
/>
);
const usernameField = ({
@@ -316,7 +316,7 @@ const displayField = ({
placeholder=""
label="Display Name"
onChange={changeMethods.onChange}
- helpText="Pick a nickname for this database to display as in Superset."
+ helpText={t('Pick a nickname for this database to display as in Superset.')}
/>
);
@@ -337,7 +337,7 @@ const queryField = ({
placeholder="e.g. additional parameters"
label="Additional Parameters"
onChange={changeMethods.onParametersChange}
- helpText="Add additional custom parameters"
+ helpText={t('Add additional custom parameters')}
/>
);
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx
index 7b8d822cbcae5..012368f6b5121 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx
@@ -266,13 +266,13 @@ describe('DatabaseModal', () => {
hidden: true,
});
- // ---------- TODO: Selector options, can't seem to get these to render properly.
+ // ---------- TODO (lyndsiWilliams): Selector options, can't seem to get these to render properly.
// renderAvailableSelector() => - Supported databases alert
const alertIcon = screen.getByRole('img', { name: /info icon/i });
const alertMessage = screen.getByText(/want to add a new database\?/i);
const alertDescription = screen.getByText(
- /any databases that allow connetions via sql alchemy uris can be added\. learn about how to connect a database driver \./i,
+ /any databases that allow connections via sql alchemy uris can be added\. learn about how to connect a database driver \./i,
);
const alertLink = screen.getByRole('link', { name: /here/i });
@@ -901,7 +901,7 @@ describe('DatabaseModal', () => {
});
it('runs fetchResource when "Connect" is clicked', () => {
- /* ---------- 🐞 TODO: function mock is not currently working 🐞 ----------
+ /* ---------- 🐞 TODO (lyndsiWilliams): function mock is not currently working 🐞 ----------
// Mock useSingleViewResource
const mockUseSingleViewResource = jest.fn();
@@ -935,7 +935,7 @@ describe('DatabaseModal', () => {
});
it('runs testDatabaseConnection when "TEST CONNECTION" is clicked', () => {
- /* ---------- 🐞 TODO: function mock is not currently working 🐞 ----------
+ /* ---------- 🐞 TODO (lyndsiWilliams): function mock is not currently working 🐞 ----------
// Mock testDatabaseConnection
const mockTestDatabaseConnection = jest.fn();
@@ -995,7 +995,7 @@ describe('DatabaseModal', () => {
expect(usernameField).toHaveValue('testdb');
expect(passwordField).toHaveValue('demoPassword');
- /* ---------- 🐞 TODO: function mock is not currently working 🐞 ----------
+ /* ---------- 🐞 TODO (lyndsiWilliams): function mock is not currently working 🐞 ----------
// Mock useSingleViewResource
const mockUseSingleViewResource = jest.fn();