-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement bootstrap monitor page feature specs
Introducing a page object to improve code quality.
- Loading branch information
Showing
4 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/api/spec/bootstrap/features/webui/projects/monitor_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require 'browser_helper' | ||
require 'bootstrap/support/page/monitor_page' | ||
|
||
RSpec.feature 'Monitor', type: :feature, js: true do | ||
describe 'monitor' do | ||
let(:admin_user) { create(:admin_user) } | ||
let!(:project) { create(:project, name: 'TestProject') } | ||
let!(:package1) { create(:package, project: project, name: 'TestPackage') } | ||
let!(:package2) { create(:package, project: project, name: 'SecondPackage') } | ||
let!(:repository1) { create(:repository, project: project, name: 'openSUSE_Tumbleweed', architectures: ['x86_64', 'i586']) } | ||
let!(:repository2) { create(:repository, project: project, name: 'openSUSE_Leap_42.3', architectures: ['x86_64', 'i586']) } | ||
let!(:repository3) { create(:repository, project: project, name: 'openSUSE_Leap_42.2', architectures: ['x86_64', 'i586']) } | ||
|
||
let(:build_results_xml) do | ||
<<-XML | ||
<resultlist state="dc66a487ea4d97b4f157d075a0e747b9"> | ||
<result project="TestProject" repository="openSUSE_Tumbleweed" arch="x86_64" code="published" state="published"> | ||
<status package="SecondPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
<status package="TestPackage" code="succeeded"> | ||
<details>no source uploaded</details> | ||
</status> | ||
</result> | ||
<result project="TestProject" repository="openSUSE_Leap_42.3" arch="x86_64" code="published" state="published"> | ||
<status package="SecondPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
<status package="TestPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
</result> | ||
<result project="TestProject" repository="openSUSE_Leap_42.2" arch="x86_64" code="published" state="published"> | ||
<status package="SecondPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
<status package="TestPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
</result> | ||
<result project="TestProject" repository="openSUSE_Tumbleweed" arch="i586" code="published" state="published"> | ||
<status package="SecondPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
<status package="TestPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
</result> | ||
<result project="TestProject" repository="openSUSE_Leap_42.3" arch="i586" code="published" state="published"> | ||
<status package="SecondPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
<status package="TestPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
</result> | ||
<result project="TestProject" repository="openSUSE_Leap_42.2" arch="i586" code="published" state="published"> | ||
<status package="SecondPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
<status package="TestPackage" code="broken"> | ||
<details>no source uploaded</details> | ||
</status> | ||
</result> | ||
</resultlist> | ||
XML | ||
end | ||
|
||
before do | ||
login admin_user | ||
allow(Backend::Api::BuildResults::Status).to receive(:result_swiss_knife).and_return(build_results_xml) | ||
visit project_monitor_path(project.name) | ||
expect(page).to have_text('Monitor') | ||
end | ||
|
||
scenario 'filtering build results by architecture' do | ||
page = Page::MonitorPage.new(:architectures) | ||
page.filter('i586') | ||
|
||
expect(page).to have_column('i586') | ||
expect(page).not_to have_column('x86_64') | ||
end | ||
|
||
scenario 'filtering build results by repository' do | ||
page = Page::MonitorPage.new(:repositories) | ||
page.filter('openSUSE_Leap_42.2') | ||
page.filter('openSUSE_Leap_42.3') | ||
|
||
expect(page).to have_column('openSUSE_Leap_42.2') | ||
expect(page).to have_column('openSUSE_Leap_42.3') | ||
expect(page).not_to have_column('Tumbleweed') | ||
end | ||
|
||
scenario 'filtering build results by status' do | ||
page = Page::MonitorPage.new(:status) | ||
page.filter('succeeded') | ||
|
||
expect(page).to have_row('TestPackage') | ||
expect(page).not_to have_row('SecondPackage') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Page | ||
class MonitorPage | ||
include Capybara::DSL | ||
|
||
def initialize(filter_name) | ||
@filter_name = filter_name | ||
end | ||
|
||
def filter(element) | ||
find("#project-monitor-#{filter_name}-dropdown").click | ||
find(:css, "label[for='#{element.parameterize}-checkbox']").click | ||
end | ||
|
||
def has_column?(column) | ||
header.has_text?(column) | ||
end | ||
|
||
def has_row?(row) | ||
rows.has_text?(row) | ||
end | ||
|
||
private | ||
|
||
attr_reader :filter_name | ||
|
||
def rows | ||
find('table#project-monitor-table') | ||
end | ||
|
||
def header | ||
find('.dataTables_scrollHead') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters