fix: blank screen in datasource view mode (#12145)

This commit is contained in:
Daniel 2022-03-23 13:30:38 +01:00 committed by GitHub
parent b4dfb6919f
commit 48685a850d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 4 deletions

View File

@ -44,5 +44,6 @@
"mockDatabaseName": "fakeapi", "mockDatabaseName": "fakeapi",
"mockDatabaseUsername": "fakeapi", "mockDatabaseUsername": "fakeapi",
"mockDatabasePassword": "LimitedAccess123#", "mockDatabasePassword": "LimitedAccess123#",
"readonly":"readonly" "readonly":"readonly",
"authenticatedApiUrl": "https://fakeapi.com"
} }

View File

@ -1,4 +1,5 @@
const apiwidget = require("../../../../locators/apiWidgetslocator.json"); const apiwidget = require("../../../../locators/apiWidgetslocator.json");
const datasourceFormData = require("../../../../fixtures/datasources.json");
describe("Authenticated API Datasource", function() { describe("Authenticated API Datasource", function() {
it("Can create New Authentication API datasource", function() { it("Can create New Authentication API datasource", function() {
@ -9,5 +10,9 @@ describe("Authenticated API Datasource", function() {
"response.body.responseMeta.status", "response.body.responseMeta.status",
201, 201,
); );
cy.fillAuthenticatedAPIForm();
cy.saveDatasource();
const URL = datasourceFormData["authenticatedApiUrl"];
cy.contains(URL);
}); });
}); });

View File

@ -6,7 +6,7 @@
"username": "input[name='datasourceConfiguration.authentication.username']", "username": "input[name='datasourceConfiguration.authentication.username']",
"password": "input[name='datasourceConfiguration.authentication.password']", "password": "input[name='datasourceConfiguration.authentication.password']",
"authenticationAuthtype": "[data-cy=datasourceConfiguration\\.authentication\\.authType]", "authenticationAuthtype": "[data-cy=datasourceConfiguration\\.authentication\\.authType]",
"url": "input[name='datasourceConfiguration.url']", "url": "input[name='url']",
"MongoDB": ".t--plugin-name:contains('MongoDB')", "MongoDB": ".t--plugin-name:contains('MongoDB')",
"RESTAPI": ".t--plugin-name:contains('REST API')", "RESTAPI": ".t--plugin-name:contains('REST API')",
"PostgreSQL": ".t--plugin-name:contains('PostgreSQL')", "PostgreSQL": ".t--plugin-name:contains('PostgreSQL')",

View File

@ -2323,6 +2323,11 @@ Cypress.Commands.add(
}, },
); );
Cypress.Commands.add("fillAuthenticatedAPIForm", () => {
const URL = datasourceFormData["authenticatedApiUrl"];
cy.get(datasourceEditor.url).type(URL);
});
Cypress.Commands.add( Cypress.Commands.add(
"fillPostgresDatasourceForm", "fillPostgresDatasourceForm",
(shouldAddTrailingSpaces = false) => { (shouldAddTrailingSpaces = false) => {

View File

@ -89,11 +89,12 @@ class DatasourceDBEditor extends JSONtoForm<Props> {
}; };
render() { render() {
const { formConfig } = this.props; const { formConfig, viewMode } = this.props;
// make sure this redux form has been initialized before rendering anything. // make sure this redux form has been initialized before rendering anything.
// the initialized prop below comes from redux-form. // the initialized prop below comes from redux-form.
if (!this.props.initialized) { // The viewMode condition is added to allow the conditons only run on the editMode
if (!this.props.initialized && !viewMode) {
return null; return null;
} }