Skip to content

Commit

Permalink
Merge pull request #8539 from alphagov/remove_preview_design_from_tests
Browse files Browse the repository at this point in the history
Remove preview design from tests
  • Loading branch information
minhngocd authored Nov 23, 2023
2 parents a7b7ac1 + c098c9d commit 9ca9af5
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 266 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cucumber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node_rake_task: ["cucumber:ok", "cucumber:preview_design_system"]
node_rake_task: ["cucumber:ok"]
steps:
- name: Setup MySQL
id: setup-mysql
Expand Down
9 changes: 0 additions & 9 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ def worldwide_office_type_options
end
end

def legacy_worldwide_office_type_options
WorldwideOfficeType.legacy_by_grouping.map do |grouping, types|
[
grouping,
types.map { |t| [t.name, t.id] },
]
end
end

def role_type_options
RoleTypePresenter.options
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/worldwide_office_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def self.in_listing_order
all.sort_by(&:listing_order)
end

def self.legacy_by_grouping
in_listing_order.group_by(&:grouping)
end

def self.by_grouping
in_listing_order
end
Expand Down
6 changes: 1 addition & 5 deletions config/cucumber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun = rerun.strip.gsub /\s/, ' '
rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags 'not @wip'"
default_tags = "--tags 'not @design-system-only'"
design_system_tags = "--tags 'not @bootstrap-only'"
%>
default: <%= std_opts %> <%= default_tags %> features --publish-quiet
preview_design_system: <%= std_opts %> <%= design_system_tags %> CUCUMBER_PREVIEW_DESIGN_SYSTEM=true features --publish-quiet
default: <%= std_opts %> features --publish-quiet
wip: --tags @wip:3 --wip features --publish-quiet
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip' --publish-quiet
1 change: 0 additions & 1 deletion features/admin-history-pagination.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@design-system-only
Feature: Viewing a document's history

Background:
Expand Down
1 change: 0 additions & 1 deletion features/destroy-draft.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Feature: Discarding a draft of a document
I can discard the draft of a document
So that the document will not appear in the list of draft documents

@design-system-only
Scenario: Unwithdrawing a withdrawn document
Given I am a writer
When I draft a new publication "My Publication"
Expand Down
8 changes: 0 additions & 8 deletions features/document-collections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@ Feature: Grouping documents into a collection
Background:
Given I am a writer in the organisation "Government Department"

@design-system-only
Scenario: Deleting a group
Given a document collection "May 2012 Update" exists
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

@design-system-only
Scenario: Adding a new group
When I draft a new document collection called "May 2012 Update"
And I add the group "Brand new group"
Then I can see that the group "Brand new group" has been added

@design-system-only
Scenario: Editing a group
Given a document collection "May 2012 Update" exists
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 title
Given a document collection "Collection" exists
And the document collection "Collection" has a group with the heading "Group"
Expand All @@ -36,7 +32,6 @@ Feature: Grouping documents into a collection
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: Adding and Removing a document to a group via URL
Given a document collection "Collection" exists
And the document collection "Collection" has a group with the heading "Group"
Expand All @@ -47,13 +42,11 @@ Feature: Grouping documents into a collection
When I remove the document "Document 1" from the group
Then I can see that "Document 1" has been removed from the group

@design-system-only
Scenario: Removing a document from a group
Given a published publication called "Document to be removed" in a published document collection
When I remove the document "Document to be removed" from the group
Then I can see that "Document to be removed" has been removed from the group

@design-system-only
Scenario: Reordering groups
Given a document collection "May 2012 Update" exists
And the following groups exist within "May 2012 Update":
Expand All @@ -71,7 +64,6 @@ Feature: Grouping documents into a collection
| Group 2 |
| Group 1 |

@design-system-only
Scenario: Reordering documents within a group
Given a document collection "Collection" exists
And the document collection "Collection" has a group with the heading "Group"
Expand Down
1 change: 0 additions & 1 deletion features/edition-needs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Feature: Managing needs on editions
Background:
Given I am an editor

@design-system-only
Scenario: Adding and removing needs
Given a submitted publication "Extended goatee for the modern man" with a PDF attachment
When I visit the list of documents awaiting review
Expand Down
6 changes: 1 addition & 5 deletions features/step_definitions/destroy_draft_steps.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
When("I discard the draft publication") do
@publication = Publication.last
visit confirm_destroy_admin_edition_path(@publication)
if using_design_system?
click_on "Delete"
else
click_on "Discard"
end
click_on "Delete"
end

Then("the publication is deleted") do
Expand Down
14 changes: 3 additions & 11 deletions features/step_definitions/needs_steps.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
When(/^I start editing the needs from the .*? page$/) do
if using_design_system?
click_link "Modify associated user needs"
else
click_on "Add/remove needs"
end
click_link "Modify associated user needs"
end

When(/^I choose the first need in the dropdown$/) do
option = first("#need_ids option").text
select option, from: "need_ids"
click_button using_design_system? ? "Save" : "Save needs"
click_button "Save"
end

Then(/^I should see the first need in the list of associated needs$/) do
find("h2:contains('Associated user needs')")
if using_design_system?
expect(first(".app-view-summary__section-user-needs .govuk-table__cell").text).to eq("As a x, I need to y, So that z")
else
expect(first("td.description").text).to eq("As a x, I need to y, So that z")
end
expect(first(".app-view-summary__section-user-needs .govuk-table__cell").text).to eq("As a x, I need to y, So that z")
end
11 changes: 0 additions & 11 deletions features/support/preview_design_system.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
if ENV["CUCUMBER_PREVIEW_DESIGN_SYSTEM"] == "true"
Before do
# Enable 'Preview design system' flag
Admin::BaseController.any_instance.stubs(:preview_design_system?).returns(true)
end
end

module DesignSystemHelper
def using_design_system?
ENV["CUCUMBER_PREVIEW_DESIGN_SYSTEM"] == "true"
end

def within_conditional_reveal(label, &block)
input = find_field(label)
conditional_reveal_id = input["aria-controls"] || input["data-aria-controls"]
Expand Down
1 change: 0 additions & 1 deletion features/topical_event_featurings.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@design-system-only
Feature:
As an Editor.
I want to be able to create and manage topical_event_featurings.
Expand Down
1 change: 0 additions & 1 deletion features/topical_event_organisations.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@design-system-only
Feature:
As an Editor.
I want to be able to view and manage topical_event_organisations.
Expand Down
1 change: 0 additions & 1 deletion features/world-location-news.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@design-system-only
Feature: Administering world location news information
Background:
Given I am a GDS admin
Expand Down
8 changes: 1 addition & 7 deletions lib/tasks/cucumber.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ unless Rails.env.production?
t.fork = true # You may get faster startup if you set this to false
t.profile = "default"
end

Cucumber::Rake::Task.new({ preview_design_system: "test:prepare" }, "Run features with the 'Preview design system' feature flag enabled") do |t|
t.fork = true # You may get faster startup if you set this to false
t.profile = "preview_design_system"
end
end

desc "Run all feature tests"
# preview_design_system comes first because it's more likely to break tests, so we'll get a faster feedback loop
task cucumber: ["cucumber:preview_design_system", "cucumber:ok"]
task cucumber: ["cucumber:ok"]

task default: :cucumber
end
98 changes: 0 additions & 98 deletions test/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
uid
permissions { [User::Permissions::SIGNIN] }

trait(:with_preview_design_system) do
permissions { [User::Permissions::SIGNIN, User::Permissions::PREVIEW_DESIGN_SYSTEM] }
end

trait(:with_use_non_legacy_endpoints) do
permissions { [User::Permissions::SIGNIN, User::Permissions::USE_NON_LEGACY_ENDPOINTS] }
end
Expand All @@ -35,45 +31,14 @@

factory :vip_editor, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::VIP_EDITOR] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::VIP_EDITOR,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :departmental_editor, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::DEPARTMENTAL_EDITOR] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::GDS_EDITOR,
User::Permissions::DEPARTMENTAL_EDITOR,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :managing_editor, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::MANAGING_EDITOR] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::MANAGING_EDITOR,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :scheduled_publishing_robot, parent: :user do
Expand All @@ -90,73 +55,22 @@
User::Permissions::GDS_ADMIN,
]
end

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::GDS_EDITOR,
User::Permissions::GDS_ADMIN,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :gds_editor, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::GDS_EDITOR] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::GDS_EDITOR,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :world_editor, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::WORLD_EDITOR] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::WORLD_EDITOR,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :world_writer, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::WORLD_WRITER] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::WORLD_WRITER,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :export_data_user, parent: :user do
permissions { [User::Permissions::SIGNIN, User::Permissions::EXPORT_DATA] }

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::EXPORT_DATA,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end

factory :gds_team_user, parent: :user do
Expand All @@ -170,17 +84,5 @@
User::Permissions::FORCE_PUBLISH_ANYTHING,
]
end

trait(:with_preview_design_system) do
permissions do
[
User::Permissions::SIGNIN,
User::Permissions::DEPARTMENTAL_EDITOR,
User::Permissions::GDS_EDITOR,
User::Permissions::FORCE_PUBLISH_ANYTHING,
User::Permissions::PREVIEW_DESIGN_SYSTEM,
]
end
end
end
end
Loading

0 comments on commit 9ca9af5

Please sign in to comment.