Skip to content

Commit

Permalink
Add help for buttons on disk activation dialog
Browse files Browse the repository at this point in the history
Related to bsc#1098563
  • Loading branch information
dgdavid committed Sep 3, 2018
1 parent 123580d commit 8161a22
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 35 deletions.
50 changes: 43 additions & 7 deletions src/lib/installation/clients/inst_disks_activate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ def main

@want_fcoe = Linuxrc.InstallInf("WithFCoE") == "1"

# dialog caption
@caption = _("Disk Activation")

@help = ""

missing_part = [
VSpacing(0),
VSpacing(0)
Expand Down Expand Up @@ -169,9 +164,9 @@ def network_button

def show_base_dialog
Wizard.SetContents(
@caption,
_("Disk Activation"),
@contents,
@help,
help,
GetInstArgs.enable_back,
GetInstArgs.enable_next
)
Expand Down Expand Up @@ -204,5 +199,46 @@ def RestoreButtons(enable_back, enable_next)
enable_back ? Wizard.EnableBackButton : Wizard.DisableBackButton
enable_next ? Wizard.EnableNextButton : Wizard.DisableNextButton
end

def help
network_button_help +
dasd_button_help +
zfcp_button_help +
fcoe_button_help +
iscsi_button_help
end

def network_button_help
_("<h2>Network configuration</h2>") +
_("Launchs the Network configuration dialog.")
end

def dasd_button_help
return "" unless @have_dasd

_("<h2>Configure DASD Disks</h2>") +
_("Opens the dialog to configure the \
<b>D</b>irect <b>A</b>ccess <b>S</b>torage <b>D</b>isks.")
end

def zfcp_button_help
return "" unless @have_zfcp

_("<h2>Configure zFCP Disks</h2>") +
_("Allows to configure the Fibre Channel Attached SCSI Disks.")
end

def fcoe_button_help
return "" unless @want_fcoe

_("<h2>Configure FCoE Interfaces</h2>") +
_("Shows the dialog to manage the \
<b>F</b>ibre <b>C</b>hannel <b>o</b>ver <b>E</b>thernet interfaces.")
end

def iscsi_button_help
_("<h2>Configure iSCSI Disks</h2>") +
_("Executes the iSCSI initiator configuration.")
end
end
end
134 changes: 106 additions & 28 deletions test/inst_disks_activate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,139 @@

describe Yast::InstDisksActivateClient do
describe "#main" do
let(:probed_disks) { [] }
let(:s390) { false }
let(:probed_disks) { [] }
let(:dasd_disks) { [] }
let(:zfcp_disks) { [] }

before do
Y2Storage::StorageManager.create_test_instance

allow(Yast::Linuxrc).to receive(:InstallInf).with("WithFCoE").and_return("0")
allow(Yast::UI).to receive(:OpenDialog)
allow(Yast::UI).to receive(:CloseDialog)
allow(Yast::Popup).to receive(:ConfirmAbort).with(:painless).and_return(true)
allow(Yast::Arch).to receive(:s390).and_return(s390)
allow(Yast::GetInstArgs).to receive(:going_back) { going_back }
allow(Yast::Linuxrc).to receive(:InstallInf).with("WithFCoE").and_return("0")
allow(Yast::UI).to receive(:UserInput).and_return(:abort)

allow(Y2Storage::StorageManager.instance).to receive(:probe)

allow(Yast::SCR).to receive(:Read).with(path(".probe.disk"))
.and_return(dasd_disks)
allow(Yast::SCR).to receive(:Read).with(path(".probe.storage"))
.and_return(zfcp_disks)

allow(subject).to receive(:Id)
allow(subject).to receive(:PushButton)

stub_const("Yast::Packages", double(GetBaseSourceID: 0))
end

it "includes help for Network configuration button" do
expect(Yast::Wizard).to receive(:SetContents)
.with(anything, anything, /Network configuration/, any_args)

subject.main
end

it "includes help for iSCSI disks button" do
expect(Yast::Wizard).to receive(:SetContents)
.with(anything, anything, /Configure iSCSI Disks/, any_args)

subject.main
end

context "when architecture is s390" do
let(:s390) { true }
before do
allow(Yast::UI).to receive(:UserInput).and_return(:abort)
end

it "detects DASD disks" do
expect(Yast::SCR).to receive(:Read).with(path(".probe.disk"))
.and_return(probed_disks)
allow(Yast::SCR).to receive(:Read).with(path(".probe.storage"))
.and_return(probed_disks)
expect(subject).to receive(:show_base_dialog)
context "and DASD disks are detected" do
let(:dasd_disks) { [ { "device" => "DASD"} ] }

expect(subject.main).to eq(:abort)
end
before do
allow(subject).to receive(:Id).with(:dasd).and_return("dasd_button_id")
end

it "detects zFCP disks" do
allow(Yast::SCR).to receive(:Read).with(path(".probe.disk"))
.and_return(probed_disks)
expect(Yast::SCR).to receive(:Read).with(path(".probe.storage"))
.and_return(probed_disks)
expect(subject).to receive(:show_base_dialog)
it "includes button to configure them" do
expect(subject).to receive(:PushButton).with("dasd_button_id", any_args)

expect(subject.main).to eq(:abort)
subject.main
end

it "includes help for DASD button" do
expect(Yast::Wizard).to receive(:SetContents)
.with(anything, anything, /Configure DASD/, any_args)

subject.main
end

context "and DASD button is clicked" do
before do
allow(Yast::UI).to receive(:UserInput).and_return(:dasd, :abort)
end

it "calls inst_dasd client" do
expect(Yast::WFM).to receive(:call).with("inst_dasd")
expect(subject).to receive(:show_base_dialog).twice

subject.main
end
end
end
end

context "when dasd button is clicked" do
before do
allow(Yast::UI).to receive(:UserInput).and_return(:dasd, :abort)
context "and zFCP disks are detected" do
let(:zfcp_disks) { [ { "device" => "zFCP controller"} ] }

before do
allow(subject).to receive(:Id).with(:zfcp).and_return("zfcp_button_id")
end

it "includes button to configure them" do
expect(subject).to receive(:PushButton).with("zfcp_button_id", any_args)

subject.main
end

it "includes help for zFCP button" do
expect(Yast::Wizard).to receive(:SetContents)
.with(anything, anything, /Configure zFCP/, any_args)

subject.main
end

context "and zFCP button is clicked" do
before do
allow(Yast::UI).to receive(:UserInput).and_return(:zfcp, :abort)
end

it "calls inst_dasd client" do
expect(Yast::WFM).to receive(:call).with("inst_zfcp")
expect(subject).to receive(:show_base_dialog).twice

subject.main
end
end
end

it "calls inst_dasd client" do
expect(Yast::WFM).to receive(:call).with("inst_dasd")
expect(subject).to receive(:show_base_dialog).twice
context "and FCoE is available" do
before do
allow(Yast::Linuxrc).to receive(:InstallInf).with("WithFCoE").and_return("1")

subject.main
allow(subject).to receive(:Id).with(:fcoe).and_return("fcoe_button_id")
end

it "includes button to configure it" do
expect(subject).to receive(:PushButton).with("fcoe_button_id", any_args)

subject.main
end

it "includes help for FCoE button" do
expect(Yast::Wizard).to receive(:SetContents)
.with(anything, anything, /Configure FCoE/, any_args)

subject.main
end
end
end

Expand Down

0 comments on commit 8161a22

Please sign in to comment.