Skip to content

Commit

Permalink
Merge pull request #1476 from sparc-request/kg-accordion_specs
Browse files Browse the repository at this point in the history
KG - Accordion Specs
  • Loading branch information
Stuart-Johnson committed Aug 13, 2018
2 parents f343498 + b13874c commit ade1567
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- program.cores.where(is_available: availability).order(Arel.sql("`order`, `name`")).each do |core|
.panel-heading.no-padding-y
.col-sm-1.no-padding-y
= link_to folder_glyphicon(), 'javascript:void(0)', class: "load_core_accordion fix_spec_overlap", data: {core_id: core.id, show_available_only: availability[0], toggle: 'collapse', target: "#core-#{core.id}-collapse", parent: "program-#{program.id}"}
= link_to folder_glyphicon(), 'javascript:void(0)', id: "core-#{core.id}", class: "load_core_accordion fix_spec_overlap", data: {core_id: core.id, show_available_only: availability[0], toggle: 'collapse', target: "#core-#{core.id}-collapse", parent: "program-#{program.id}"}
.col-sm-11.no-padding-y
= link_to accordion_link_text(core, !core.is_available), edit_catalog_manager_organization_path(core), class: 'org-form-label panel-title', remote: true
.panel-collapse.collapse{ id: "core-#{core.id}-collapse" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright © 2011-2018 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe 'User loads a core accordion', js: true do
let_there_be_lane
fake_login_for_each_test

before :each do
@institution = create(:institution)
@provider = create(:provider, parent: @institution)
@program = create(:program, parent: @provider)
@core = create(:core, parent: @program)
@service = create(:service, organization: @core)
create(:catalog_manager, organization: @institution, identity: jug2)

visit catalog_manager_catalog_index_path
wait_for_javascript_to_finish

find("#institution-#{@institution.id} .glyphicon").click
find("#provider-#{@provider.id} .glyphicon").click
find("#program-#{@program.id} .glyphicon").click
wait_for_javascript_to_finish
find("#core-#{@core.id} .glyphicon").click
wait_for_javascript_to_finish
end

it 'should load the core\'s services' do
expect(page).to have_selector('.text-service', text: @service.name)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright © 2011-2018 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe 'User loads a program accordion', js: true do
let_there_be_lane
fake_login_for_each_test

before :each do
@institution = create(:institution)
@provider = create(:provider, parent: @institution)
@program = create(:program, parent: @provider)
@core = create(:core, parent: @program)
@service = create(:service, organization: @program)
create(:catalog_manager, organization: @institution, identity: jug2)

visit catalog_manager_catalog_index_path
wait_for_javascript_to_finish

find("#institution-#{@institution.id} .glyphicon").click
find("#provider-#{@provider.id} .glyphicon").click
find("#program-#{@program.id} .glyphicon").click
wait_for_javascript_to_finish
end

it 'should load the program\'s cores and services' do
expect(page).to have_selector('.text-core', text: @core.name)
expect(page).to have_selector('.text-service', text: @service.name)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Copyright © 2011-2018 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe 'User searches for services and organizations', js: true do
let_there_be_lane
fake_login_for_each_test

before :each do
@institution = create(:institution)
@provider = create(:provider, parent: @institution)
@program = create(:program, parent: @provider)
@core = create(:core, parent: @program)
@service = create(:service, organization: @core)
create(:catalog_manager, organization: @available, identity: jug2)

visit catalog_manager_catalog_index_path
wait_for_javascript_to_finish
end

context 'Institution' do
before :each do
fill_in 'organization-query', with: @institution.name
page.execute_script %Q{ $('organization-query').trigger("keydown") }
wait_for_javascript_to_finish

find('.tt-suggestion').click
wait_for_javascript_to_finish
end

it 'should show the institution form' do
expect(page).to have_selector("h3", text: @institution.name)
end
end

context 'Provider' do
before :each do
fill_in 'organization-query', with: @provider.name
page.execute_script %Q{ $('organization-query').trigger("keydown") }
wait_for_javascript_to_finish

find('.tt-suggestion').click
wait_for_javascript_to_finish
end

it 'should show the provider form' do
expect(page).to have_selector("h3", text: @provider.name)
end
end

context 'Program' do
before :each do
fill_in 'organization-query', with: @program.name
page.execute_script %Q{ $('organization-query').trigger("keydown") }
wait_for_javascript_to_finish

find('.tt-suggestion').click
wait_for_javascript_to_finish
end

it 'should show the program form' do
expect(page).to have_selector("h3", text: @program.name)
end
end

context 'Core' do
before :each do
fill_in 'organization-query', with: @core.name
page.execute_script %Q{ $('organization-query').trigger("keydown") }
wait_for_javascript_to_finish

find('.tt-suggestion').click
wait_for_javascript_to_finish
end

it 'should show the core form' do
expect(page).to have_selector("h3", text: @core.name)
end
end

context 'Service' do
before :each do
fill_in 'organization-query', with: @service.name
page.execute_script %Q{ $('organization-query').trigger("keydown") }
wait_for_javascript_to_finish

find('.tt-suggestion').click
wait_for_javascript_to_finish
end

it 'should show the service form' do
expect(page).to have_selector("h3", text: @service.name)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright © 2011-2018 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe 'User toggles the "Show Available" button', js: true do
let_there_be_lane
fake_login_for_each_test

before :each do
@available = create(:institution)
@unavailable = create(:institution, is_available: false)
create(:catalog_manager, organization: @available, identity: jug2)

visit catalog_manager_catalog_index_path
wait_for_javascript_to_finish
end

it 'should show organizations and services corresponding to the button' do
expect(page).to have_content(@available.name)
expect(page).to_not have_content(@unavailable.name)

find('.toggle-on').click
wait_for_javascript_to_finish

expect(page).to have_content(@available.name)
expect(page).to have_content(@unavailable.name)

find('.toggle-off').click
wait_for_javascript_to_finish

expect(page).to have_content(@available.name)
expect(page).to_not have_content(@unavailable.name)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright © 2011-2018 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe 'User views an organization', js: true do
let_there_be_lane
fake_login_for_each_test

before :each do
@institution = create(:institution)
@provider = create(:provider, parent: @institution)
@program = create(:program, parent: @provider)
@core = create(:core, parent: @program)
create(:catalog_manager, organization: @institution, identity: jug2)

visit catalog_manager_catalog_index_path
wait_for_javascript_to_finish
end

context 'Institution' do
before :each do
click_link @institution.name
wait_for_javascript_to_finish
end

it 'should show the institution form' do
expect(page).to have_selector("h3", text: @institution.name)
end
end

context 'Provider' do
before :each do
find("#institution-#{@institution.id} .glyphicon").click
click_link @provider.name
wait_for_javascript_to_finish
end

it 'should show the provider form' do
expect(page).to have_selector("h3", text: @provider.name)
end
end

context 'Program' do
before :each do
find("#institution-#{@institution.id} .glyphicon").click
find("#provider-#{@provider.id} .glyphicon").click
click_link @program.name
wait_for_javascript_to_finish
end

it 'should show the program form' do
expect(page).to have_selector("h3", text: @program.name)
end
end

context 'Core' do
before :each do
find("#institution-#{@institution.id} .glyphicon").click
find("#provider-#{@provider.id} .glyphicon").click
find("#program-#{@program.id} .glyphicon").click
wait_for_javascript_to_finish
click_link @core.name
wait_for_javascript_to_finish
end

it 'should show the core form' do
expect(page).to have_selector("h3", text: @core.name)
end
end
end

0 comments on commit ade1567

Please sign in to comment.