Skip to content

Commit

Permalink
Complete feature testing for adding a document to document collection…
Browse files Browse the repository at this point in the history
… group
  • Loading branch information
minhngocd committed Sep 25, 2023
1 parent 0dea505 commit 3bc9433
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 6 additions & 3 deletions features/document-collections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Feature: Grouping documents into a collection
@design-system-only
Scenario: Deleting a group
Given a document collection "May 2012 Update" exists
And a the document collection "May 2012 Update" has a group with the heading "Temporary group"
And the document collection "May 2012 Update" has a group with the heading "Temporary group"
When I delete the group "Temporary group"
Then I can see that the group "Temporary group" has been deleted

Expand All @@ -63,16 +63,19 @@ Feature: Grouping documents into a collection
@design-system-only
Scenario: Editing a group
Given a document collection "May 2012 Update" exists
And a the document collection "May 2012 Update" has a group with the heading "Group to be edited"
And the document collection "May 2012 Update" has a group with the heading "Group to be edited"
When I edit the group "Group to be edited"'s heading to "Interesting new heading"
Then I can see that the heading has been updated to "Interesting new heading"

@design-system-only
Scenario: Adding a document to a group via slug
Given a document collection "Collection" exists
And a the document collection "Collection" has a group with the heading "Group"
And the document collection "Collection" has a group with the heading "Group"
And a published document "Document 1" exists
When I select to add a new document to the collection group through "Search via title or slug"
And I search by "title or slug" for "Document 1"
And I add "Document 1" to the document collection
Then I should see "Document 1" in the list for the collection group "Group"

@design-system-only
Scenario: Removing a document from a group
Expand Down
13 changes: 12 additions & 1 deletion features/step_definitions/document_collection_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
expect(body.index(doc_title1) < body.index(doc_title2)).to be(true)
end

And(/^a the document collection "([^"]*)" has a group with the heading "([^"]*)"$/) do |collection_title, heading|
And(/^the document collection "([^"]*)" has a group with the heading "([^"]*)"$/) do |collection_title, heading|
document_collection = DocumentCollection.find_by!(title: collection_title)
@group = create(:document_collection_group, heading:, document_collection:)
end
Expand Down Expand Up @@ -261,3 +261,14 @@
fill_in "Search by #{search_type.downcase}", with: search_term
click_button "Search"
end

And(/^I add "([^"]*)" to the document collection$/) do |document_title|
expect(page).to have_content document_title
click_button "Add"
end

Then(/^I should see "([^"]*)" in the list for the collection group "([^"]*)"$/) do |document_title, collection_title|
expect(page).to have_content "'#{document_title}' added to '#{collection_title}'"
documents = all(".govuk-table__cell").map(&:text)
expect(documents).to include document_title
end

0 comments on commit 3bc9433

Please sign in to comment.