Skip to content

Commit 7ff54f5

Browse files
authored
Merge pull request #9700 from Fryguy/fix_diagnostics_database
Fix diagnostics database page
2 parents 9fb9287 + 3764ff8 commit 7ff54f5

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

app/helpers/ops_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ def row_data(label, value)
2222
end
2323

2424
def database_details
25-
@database_details = ActiveRecord::Base.configurations[Rails.env]
25+
@database_details = ActiveRecord::Base.configurations.configs_for(:env_name => Rails.env).first.configuration_hash
2626
@database_display_name =
27-
if @database_details["host"].in?([nil, "", "localhost", "127.0.0.1"])
27+
if @database_details[:host].in?([nil, "", "localhost", "127.0.0.1"])
2828
_("Internal Database")
2929
else
3030
_("External Database")
3131
end
3232
@data = {:title => _('Basic Information')}
3333
@data[:rows] = [
3434
row_data(_('Name'), @database_display_name),
35-
row_data(_('Hostname'), @database_details["host"]),
36-
row_data(_('Database name'), @database_details["database"]),
37-
row_data(_('Username'), @database_details["username"])
35+
row_data(_('Hostname'), @database_details[:host]),
36+
row_data(_('Database name'), @database_details[:database]),
37+
row_data(_('Username'), @database_details[:username])
3838
]
3939
end
4040

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* eslint-disable no-undef */
2+
3+
// Menu options
4+
const SETTINGS_MENU_OPTION = 'Settings';
5+
const APP_SETTINGS_MENU_OPTION = 'Application Settings';
6+
7+
// Accordion items
8+
const DIAGNOSTICS_ACCORDION_ITEM = 'Diagnostics';
9+
const MANAGEIQ_REGION_ACCORDION_ITEM = /^ManageIQ Region:/;
10+
11+
// Tab names
12+
const DATABASE_TAB_LABEL = 'Database';
13+
14+
describe('Settings > Application Settings > Diagnostics', () => {
15+
beforeEach(() => {
16+
cy.login();
17+
cy.menu(SETTINGS_MENU_OPTION, APP_SETTINGS_MENU_OPTION);
18+
cy.accordion(DIAGNOSTICS_ACCORDION_ITEM);
19+
});
20+
21+
describe('ManageIQ Region', () => {
22+
beforeEach(() => {
23+
cy.selectAccordionItem([MANAGEIQ_REGION_ACCORDION_ITEM]);
24+
});
25+
26+
it('should navigate to the Database tab', () => {
27+
// Intercept the API call when clicking on the Database tab
28+
cy.interceptApi({
29+
alias: 'getDatabaseTabInfo',
30+
urlPattern: '/ops/change_tab?tab_id=diagnostics_database',
31+
triggerFn: () => cy.tabs({ tabLabel: DATABASE_TAB_LABEL }),
32+
});
33+
34+
// Verify the Database tab content is loaded
35+
cy.get(`@getDatabaseTabInfo`).then((getCall) => {
36+
expect(getCall.state).to.equal('Complete');
37+
});
38+
39+
// Verify we're on the Database tab
40+
cy.get('.tab-content').contains(DATABASE_TAB_LABEL).should('be.visible');
41+
});
42+
});
43+
});

spec/helpers/ops_helper_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
describe OpsHelper do
2+
it "#database_details" do
3+
db_config = ActiveRecord::Base.configurations.configs_for(:env_name => Rails.env).first.configuration_hash
4+
5+
expect(helper.database_details).to match_array(
6+
[
7+
{:cells => a_hash_including(:label => "Name", :value => a_string_matching(/ Database$/))},
8+
{:cells => {:label => "Hostname", :value => db_config[:host]}},
9+
{:cells => {:label => "Database name", :value => db_config[:database]}},
10+
{:cells => {:label => "Username", :value => db_config[:username]}},
11+
]
12+
)
13+
end
14+
215
describe '#auth_mode_name' do
316
modes = %w[amazon httpd database]
417
modes_pretty = %w[Amazon External\ Authentication Database]

0 commit comments

Comments
 (0)