Skip to content

Commit

Permalink
Resource publish
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Dec 21, 2024
1 parent 23e743a commit 491d2ef
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
17 changes: 16 additions & 1 deletion helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,22 @@ def ensure_test_repository_exists

visit STAFF_URL
end

select_test_repository
rescue Capybara::ElementNotFound
# Continue
select_test_repository
end

def select_test_repository
click_on 'Select Repository'
within '.dropdown-menu' do
find('select').select 'repository_test'
click_on 'Select Repository'
end
expect(find('.alert.alert-success').text).to eq 'The Repository repository_test is now active'

click_on 'repository_test'
@repository_id = current_url.split('/').pop
end

def ensure_test_user_exists
Expand Down Expand Up @@ -175,6 +189,7 @@ def find_user_table_row_in_manage_user_access_page(username)
def create_resource(uuid)
fill_in 'resource_title_', with: "Resource #{uuid}"
fill_in 'resource_id_0_', with: "Resource #{uuid}"
find('#resource_publish_').check
select 'Class', from: 'resource_level_'
element = find('#resource_lang_materials__0__language_and_script__language_')
element.send_keys('AU')
Expand Down
8 changes: 4 additions & 4 deletions staff_features/resources/resource_publish.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Resource Publish
Scenario: Publish the Resource record from toolbar
Given the Resource is opened in edit mode
When the user clicks on 'Publish All'
And the user clicks on 'Publish All' in the confirm popup
And the user clicks on 'Publish All' in the modal
Then the 'Resource' published message is displayed
And the 'View Published' button is available
And the 'View Published' button is displayed
Scenario: Publish the Resource record from the Publish checkbox in the Basic Information section
Given the Resource is opened in edit mode
When the user checks 'Publish'
And the user clicks on 'Save'
Then the 'Resource' updated message is displayed
And the 'View Published' button is available
And the 'View Published' button is displayed
Scenario: View a published Resource Record in the public interface
Given the Resource is opened in edit mode
And the Resource is published
When the user clicks on 'View Published'
Then a new tab is opened with the record as it displays in the public interface
Then the Resource opens on a new tab in the public interface
5 changes: 0 additions & 5 deletions staff_features/resources/step_definitions/resource_edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
visit "#{STAFF_URL}/resources/#{@resource_id}"
end

Given 'the Resource is opened in edit mode' do
visit "#{STAFF_URL}/resources/#{@resource_id}/edit"
wait_for_ajax
end

Given 'the Resource has one Language' do
languages = all('#resource_lang_materials_ .subrecord-form-list .subrecord-form-wrapper')

Expand Down
22 changes: 22 additions & 0 deletions staff_features/resources/step_definitions/resource_shared.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

Given 'the Resource is opened in edit mode' do
visit "#{STAFF_URL}/resources/#{@resource_id}/edit"
wait_for_ajax
end

Given 'the Resource is published' do
expect(find('#resource_publish_').checked?).to eq true
end

Given 'the {string} button is displayed' do |button_text|
expect(page).to have_css('a', text: button_text)
end

Then 'the Resource opens on a new tab in the public interface' do
expect(page.windows.size).to eq 2
switch_to_window(window)

expect(current_url).to eq "#{PUBLIC_URL}/repositories/#{@repository_id}/resources/#{@resource_id}"
expect(page).to have_text "Resource #{@uuid}"
end
4 changes: 4 additions & 0 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
end

Then('the {string} published message is displayed') do |string|
expect(find('.alert.alert-success.with-hide-alert').text).to match(/#{string} .* its subrecords and components have been published.*$/i)
end

Then 'the following message is displayed' do |messages|
messages.raw.each do |message|
expect(page).to have_text message[0]
Expand Down

0 comments on commit 491d2ef

Please sign in to comment.