diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0686d4970..b4ef19cb2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-02-10 17:04:48 UTC using RuboCop version 1.44.1. +# on 2024-03-26 11:13:57 UTC using RuboCop version 1.62.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -9,12 +9,19 @@ # Offense count: 1 # Configuration parameters: EnforcedStyle, AllowedGems, Include. # SupportedStyles: Gemfile, gems.rb, gemspec -# AllowedGems: bundler # Include: **/*.gemspec, **/Gemfile, **/gems.rb Gemspec/DevelopmentDependencies: Exclude: - 'spec/fixture/Gemfile' +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'swedbank-pay-design-guide-jekyll-theme.gemspec' + # Offense count: 1 # Configuration parameters: Severity, Include. # Include: **/*.gemspec @@ -22,17 +29,8 @@ Gemspec/RequiredRubyVersion: Exclude: - 'swedbank-pay-design-guide-jekyll-theme.gemspec' -# Offense count: 5 -# Configuration parameters: AllowComments, AllowEmptyLambdas. -Lint/EmptyBlock: - Exclude: - - 'spec/sidebar_after_payment_spec.rb' - - 'spec/sidebar_checkin_file_spec.rb' - - 'spec/sidebar_front_page_spec.rb' - - 'spec/sidebar_super_secret_file_spec.rb' - -# Offense count: 6 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. +# Offense count: 7 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 29 @@ -42,12 +40,12 @@ Metrics/ClassLength: Max: 135 # Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 9 # Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 10 @@ -68,78 +66,35 @@ RSpec/ContextWording: - 'spec/spec_helper.rb' # Offense count: 3 -# Configuration parameters: IgnoredMetadata. -RSpec/DescribeClass: - Exclude: - - '**/spec/features/**/*' - - '**/spec/requests/**/*' - - '**/spec/routing/**/*' - - '**/spec/system/**/*' - - '**/spec/views/**/*' - - 'spec/card_checkout_core_features_spec.rb' - - 'spec/card_overview_spec.rb' - - 'spec/sidebar_spec.rb' - -# Offense count: 25 -# Configuration parameters: CountAsOne. -RSpec/ExampleLength: - Max: 25 - -# Offense count: 16 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. # Include: **/*_spec*rb*, **/spec/**/* RSpec/FilePath: - Enabled: false + Exclude: + - 'spec/read_time_filter_spec.rb' + - 'spec/regex_capture_filter.spec' + - 'spec/rspec_description_parser_spec.rb' -# Offense count: 15 +# Offense count: 1 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: - - 'spec/card_checkout_core_features_spec.rb' - - 'spec/card_overview_spec.rb' - - 'spec/sidebar_after_payment_spec.rb' - - 'spec/sidebar_checkin_file_spec.rb' - - 'spec/sidebar_checkout_core_features_file_spec.rb' - - 'spec/sidebar_checkout_more_file_spec.rb' - - 'spec/sidebar_features_file_spec.rb' - - 'spec/sidebar_front_page_spec.rb' - - 'spec/sidebar_index_file_spec.rb' - - 'spec/sidebar_po_file_spec.rb' - - 'spec/sidebar_redirect_file_spec.rb' - - 'spec/sidebar_resource_file_spec.rb' - - 'spec/sidebar_search_file_spec.rb' - - 'spec/sidebar_super_secret_file_spec.rb' - 'spec/spec_helper.rb' # Offense count: 2 -RSpec/MultipleExpectations: - Max: 2 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - '**/spec/routing/**/*' + - 'spec/read_time_filter_spec.rb' + - 'spec/rspec_description_parser_spec.rb' -# Offense count: 43 -# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. -# SupportedStyles: always, named_only -RSpec/NamedSubject: +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/SpecFilePathSuffix: Exclude: - - 'spec/card_checkout_core_features_spec.rb' - - 'spec/card_overview_spec.rb' - - 'spec/sidebar_after_payment_spec.rb' - - 'spec/sidebar_checkin_file_spec.rb' - - 'spec/sidebar_checkout_core_features_file_spec.rb' - - 'spec/sidebar_checkout_more_file_spec.rb' - - 'spec/sidebar_features_file_spec.rb' - - 'spec/sidebar_front_page_spec.rb' - - 'spec/sidebar_index_file_spec.rb' - - 'spec/sidebar_po_file_spec.rb' - - 'spec/sidebar_redirect_file_spec.rb' - - 'spec/sidebar_resource_file_spec.rb' - - 'spec/sidebar_search_file_spec.rb' - - 'spec/sidebar_spec.rb' - - 'spec/sidebar_super_secret_file_spec.rb' - -# Offense count: 13 -# Configuration parameters: AllowedGroups. -RSpec/NestedGroups: - Max: 7 + - 'spec/regex_capture_filter.spec' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -149,15 +104,22 @@ Style/CaseEquality: - 'lib/sidebar_html_builder.rb' # Offense count: 1 -# Configuration parameters: AllowedMethods. -# AllowedMethods: respond_to_missing? -Style/OptionalBooleanParameter: +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: Exclude: - - 'spec/card_checkout_core_features_spec.rb' + - 'lib/sidebar_tree_builder.rb' -# Offense count: 8 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantCurrentDirectoryInPath: + Exclude: + - 'swedbank-pay-design-guide-jekyll-theme.gemspec' + +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: Max: 142 diff --git a/README.md b/README.md index 61670ef62..20715d404 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ the changes in the browser after a refresh, just like normal. When the theme is released, only the files in `_layouts`, `_includes`, `_sass` and `assets` tracked with Git will be bundled. To add a custom directory to your theme-gem, please edit the regexp in `swedbankpay.gemspec` accordingly. - ### Docker (recommended) 1. [Clone this repository][clone]. @@ -35,7 +34,6 @@ theme-gem, please edit the regexp in `swedbankpay.gemspec` accordingly. 3. Open a console window at the root of the repository and run `docker-compose up`. This will create a docker container and spin it up with everything that's specified in the repository gemfile. 4. Open `http://localhost:4000` in a browser. - ### Manual install @@ -45,19 +43,17 @@ theme-gem, please edit the regexp in `swedbankpay.gemspec` accordingly. that. Note: If you're installing on Windows, choose Ruby+Devkit Installers. 4. Open VSC and open the repository -5. Verify that Git is installed by running `git status` in VSC terminal. +5. Verify that Git is installed by running `git status` in VSC terminal. If Git is not properly installed, you will see an error message like the one below. Just [download Git][git] and install. ![Alt text](image.png) 6. Type `bundle install` inside the root folder of this repository. 7. Run `bundle exec jekyll serve` to start the website. 8. Open in a browser. - ### Visual Studio Code plugins You might want to install plugins for Graphviz, JSON, Liquid, Markdown and Mermaid as this will enhance your coding experience. - ## Contributing Bug reports and pull requests are welcome on [GitHub][github]. This project is @@ -82,15 +78,11 @@ agreement][cla]. [design-guide]: [developer-portal]: [docker]: -[gems]: [git]: [github]: -[graphviz]: [license-badge]: https://img.shields.io/github/license/SwedbankPay/swedbank-pay-design-guide-jekyll-theme [license]: -[liquid]: [opengraph-image]: [ruby]: [swedbankpay]: [test-badge]: -[vsc-ruler]: diff --git a/index.md b/index.md index a33baaf9f..9de2a51eb 100644 --- a/index.md +++ b/index.md @@ -164,14 +164,7 @@ Content-Type: application/json' "vatAmount": 0, "description": "Test transaction", "payeeReference": "1583846100", - "isOperational": true, - "operations": [ - { - "method": "GET", - "href": "https://api.stage.payex.com/psp/creditcard/confined/payments/authorizations/authenticate/ec2a9b09-601a-42ae-8e33-a5737e1cf177", - "rel": "redirect-authentication" - } - ] + "isOperational": true } } }' diff --git a/lib/sidebar_html_builder.rb b/lib/sidebar_html_builder.rb index cfbcddf5e..5e94e8135 100644 --- a/lib/sidebar_html_builder.rb +++ b/lib/sidebar_html_builder.rb @@ -116,7 +116,7 @@ def sub_items_markup(page, current_page) "
    #{if page.level.positive? && page.children? - " + " arrow_back_ios Back to #{page.parent.title} diff --git a/spec/card_checkout_core_features_spec.rb b/spec/card_checkout_core_features_spec.rb deleted file mode 100644 index 3cb9c38d7..000000000 --- a/spec/card_checkout_core_features_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: false - -describe 'Checkout Core Features' do - include_context 'shared' - core_features_path = File.join(@dest_dir, 'checkout', 'v2', 'features', 'core', 'index.html') - - describe core_features_path do - subject { File.read(core_features_path) } - - it { - expect(File).to exist(core_features_path) - } - - it 'has expected cards' do - expect(subject).to have_tag('article') do - with_tag('h2#core-features', with: { class: 'heading-line' }) do - with_tag('a.header-anchor', with: { href: '#core-features' }) - end - with_tag('.row.card-list') do - with_card('3d-secure-2', '3-D Secure 2', 'Authenticating the cardholder', '3d_rotation', false) - with_card('payment-order-abort', 'Abort', 'Aborting a created payment', 'pan_tool') - with_card('cancel', 'Cancel', 'Cancelling the authorization and releasing the funds', 'pan_tool') - with_card('payment-order-capture', 'Capture', 'Capturing the authorized funds', 'compare_arrow') - with_card('payment-order', 'Payment Order', 'Creating the payment order', 'credit_card') - with_card('reversal', 'Reversal', 'How to reverse a payment', 'keyboard_return') - with_card('settlement-reconciliation', 'Settlement & Reconciliation', 'Balancing the books', 'description') - end - end - end - end - - def with_card(href, title, body, icon, icon_outlined = true) - href = "/checkout/v2/features/core/#{href}" - icon_type = 'material-icons' - icon_type << '-outlined' if icon_outlined - - with_tag('.col-lg-4') do - with_tag('a.dx-card', with: { href: href }) do - with_tag('.dx-card-icon') do - with_tag('i', text: /#{icon}/, with: { class: icon_type }) - end - with_tag('.dx-card-content') do - with_tag('.h4', text: title) - with_tag('span', text: body) - end - with_tag('i.material-icons', text: /arrow_forward/) - end - end - end -end diff --git a/spec/card_overview_spec.rb b/spec/card_overview_spec.rb deleted file mode 100644 index 8ed6da4ef..000000000 --- a/spec/card_overview_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -# frozen_string_literal: true - -describe 'Card Overview' do - include_context 'shared' - card_index = File.join(@dest_dir, 'cards', 'index.html') - - describe card_index do - subject { File.read(card_index) } - - it { - expect(File).to exist(card_index) - } - - it 'has expected first card deck' do - expect(subject).to have_tag('article') do - with_tag('h2#deck-1', with: { class: 'heading-line' }) do - with_tag('a.header-anchor', with: { href: '#deck-1' }) - end - with_tag('.row.card-list') do - with_tag('.col-lg-6') do - with_tag('a.dx-card.dx-card-module', with: { href: '/cards/deck1/card1' }) do - with_tag('.dx-card-icon') do - with_tag('i.material-icons-outlined', text: /attach_money/) - end - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 1 Card 1') - with_tag('span', text: 'Deck One Card One') - end - with_tag('i.material-icons', text: /arrow_forward/) - end - end - end - end - end - - it 'has card with no icon' do - expect(subject).to have_tag('a.dx-card', with: { href: '/cards/deck1/card2' }) do - with_tag('.dx-card-icon.d-none') do - with_tag('i.material-icons', text: /^\s*$/) - end - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 1 Card 2') - with_tag('span', text: 'Deck One Card Two') - end - with_tag('i.material-icons', text: /arrow_forward/) - end - end - - it 'has expected second card deck' do - expect(subject).to have_tag('article') do - with_tag('h2#deck-2', with: { class: 'heading-line' }) do - with_tag('a.header-anchor', with: { href: '#deck-2' }) - end - - with_tag('.row.card-list') do - with_tag('.col-lg-12') do - with_tag('a.dx-card', with: { href: '/cards/deck2/card1' }) do - with_tag('.dx-card-icon') do - with_tag('i.material-icons', text: /api/) - end - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 2 Card 1') - with_tag('span', text: 'Deck Two Card One') - end - with_tag('i.material-icons', text: /arrow_forward/) - end - end - end - end - end - - it 'has card with svg icon' do - expect(subject).to have_tag('.col-lg-12') do - with_tag('a.dx-card', with: { href: '/cards/deck2/card2' }) do - with_tag('.dx-card-icon') do - with_tag('svg') - end - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 2 Card 2') - with_tag('span', text: 'Deck Two Card Two') - end - with_tag('i.material-icons', text: /arrow_forward/) - end - end - end - - it 'has horizontal card' do - expect(subject).to have_tag('.dx-card-horizontal') do - with_tag('a.dx-card', with: { href: '/cards/deck2/card3' }) do - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 2 Card 3') - with_tag('span', text: 'Deck Two Card Three') - end - with_tag('i.material-icons', text: /arrow_forward/) - end - end - end - - it 'has disabled default card' do - expect(subject).to have_tag('span.dx-card.dx-card-disabled') do - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 3 Card 3') - with_tag('span', text: 'Deck Three Card Three (Disabled)') - end - without_tag('i.material-icons', text: /arrow_forward/) - end - end - - it 'has disabled sdk card' do - expect(subject).to have_tag('span.dx-card-sdk.dx-card-disabled') do - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 3 Card 1') - with_tag('span', text: 'Deck Three Card One (Disabled)') - end - without_tag('i.material-icons', text: /arrow_forward/) - end - end - - it 'has disabled module card' do - expect(subject).to have_tag('span.dx-card-module.dx-card-disabled') do - with_tag('.dx-card-content') do - with_tag('.h4', text: 'Deck 3 Card 2') - with_tag('span', text: 'Deck Three Card Two (Disabled)') - end - without_tag('i.material-icons', text: /arrow_forward/) - end - end - end -end diff --git a/spec/field_tag_spec.rb b/spec/field_tag_spec.rb deleted file mode 100644 index 8e124ad94..000000000 --- a/spec/field_tag_spec.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -require 'its' -require 'liquid' -require 'field_tag' - -describe SwedbankPay::FieldTag do - subject(:date) { described_class.parse('f', input, nil, Liquid::ParseContext.new) } - - context 'with field name' do - let(:input) { 'href' } - - its(:raw) { is_expected.to eq('f href') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('href') - end - end - - context 'with field name and level' do - let(:input) { 'operations, 2' } - - its(:raw) { is_expected.to eq('f operations, 2') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('operations') - end - end - - context 'with invalid level' do - let(:input) { 'operations, abc' } - - its(:raw) { is_expected.to eq('f operations, abc') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('operations') - end - end - - context 'with zero level' do - let(:input) { 'operations, 0' } - - its(:raw) { is_expected.to eq('f operations, 0') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('operations') - end - end - - context 'with negative level' do - let(:input) { 'operations, -1' } - - its(:raw) { is_expected.to eq('f operations, -1') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('operations') - end - end - - context 'with nil field name' do - let(:input) { nil } - - its(:raw) { is_expected.to eq('f ') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('') - end - end - - context 'with empty field name and valid level' do - let(:input) { ', 4' } - - its(:raw) { is_expected.to eq('f , 4') } - - its(:render, Liquid::Context.new) do - is_expected.to eq('') - end - end -end diff --git a/spec/sidebar_after_payment_spec.rb b/spec/sidebar_after_payment_spec.rb deleted file mode 100644 index b488990b8..000000000 --- a/spec/sidebar_after_payment_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - after_payment_path = File.expand_path(File.join(@dest_dir, 'checkout', 'v2', 'after-payment.html')) - - describe after_payment_path do - subject { File.read(after_payment_path) } - - it { - expect(File).to exist(after_payment_path) - } - - it 'has active item' do - expect(subject).to have_tag('li.group.active') do - with_tag('li.group.active') do - with_tag('a[href="/checkout/v2/after-payment"]', text: 'After Payment') do - end - end - end - end - - it 'has expected page title' do - expect(subject).to have_tag('title', text: 'Checkout v2 – After Payment') - end - end -end diff --git a/spec/sidebar_checkin_file_spec.rb b/spec/sidebar_checkin_file_spec.rb deleted file mode 100644 index d578c9662..000000000 --- a/spec/sidebar_checkin_file_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - checkin_path = File.join(@dest_dir, 'checkout', 'v2', 'checkin.html') - - describe checkin_path do - subject { File.read(checkin_path) } - - it { - expect(File).to exist(checkin_path) - } - - it 'has expected nav structure' do - expect(subject).to have_tag('li.main-nav-li.active') do - with_tag('li.group.active') do - with_tag('a[href="/checkout/v2/checkin"]', text: 'Checkout – Checkin') - with_tag('ul') do - with_tag('li.nav-leaf') do - with_tag('a[href="/checkout/v2/checkin#step-1-initiate-session-for-consumer-identification"]', - text: 'Step 1: Initiate session for consumer identification') - with_tag('li.nav-leaf') do - end - end - end - end - end - end - - it 'has expected title header' do - expect(subject).to have_tag('div.title-header') do - with_tag('div.title-header-container') do - with_tag('h4', text: 'Checkout v2') - with_tag('h1', text: 'Checkin') - with_tag('div.title-header-estimated-read', text: /6 min read/) - end - end - end - - it 'has expected page title' do - expect(subject).to have_tag('title', text: 'Checkout v2 – Checkin') - end - - it 'has field with explicit level 1 tag' do - expect(subject).to have_tag('span.field-level.field-level-1') do - have_tag('code.language-json.highlighter-rouge', text: 'rel') - end - end - - it 'has field with implicit level 1 tag' do - expect(subject).to have_tag('span.field-level.field-level-1') do - have_tag('code.language-json.highlighter-rouge', text: 'contenType') - end - end - - it 'has field with explicit level 2 tag' do - expect(subject).to have_tag('span.field-level.field-level-2') do - have_tag('code.language-json.highlighter-rouge', text: 'method') - end - end - end -end diff --git a/spec/sidebar_checkout_core_features_file_spec.rb b/spec/sidebar_checkout_core_features_file_spec.rb deleted file mode 100644 index 812a84978..000000000 --- a/spec/sidebar_checkout_core_features_file_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - checkout_core_features_path = File.join(@dest_dir, 'checkout', 'v2', 'features', 'core', 'index.html') - - describe checkout_core_features_path do - subject { File.read(checkout_core_features_path) } - - it { - expect(File).to exist(checkout_core_features_path) - } - - it 'is missing header navigation' do - expect(subject).to have_tag('li.main-nav-li.active') do - with_tag('li.main-nav-li.active') do - with_tag('a[href="/checkout/"]') - with_tag('nav.sidebar-secondary-nav') do - with_tag('header.secondary-nav-header', Text: 'Checkout') - with_tag('ul.secondary-nav-ul') do - with_tag('li.leaf', with: { class: 'active' }) do - with_tag('a[href="/checkout/v2/features/"]', text: 'Features') - with_tag('ul') do - with_tag('li.leaf', with: { class: 'active' }) do - with_tag('a[href="/checkout/v2/features/core/"]', text: 'Core Features') - end - end - end - end - end - end - end - end - end -end diff --git a/spec/sidebar_checkout_more_file_spec.rb b/spec/sidebar_checkout_more_file_spec.rb deleted file mode 100644 index 55edbc1ca..000000000 --- a/spec/sidebar_checkout_more_file_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - checkout_more_path = File.join(@dest_dir, 'checkout-more', 'after-payment.html') - - describe checkout_more_path do - subject { File.read(checkout_more_path) } - - it { - expect(File).to exist(checkout_more_path) - } - - it 'has expected nav structure' do - expect(subject).to have_tag('li.main-nav-li.active') do - with_tag('a[href="/checkout-more/"]') - end - with_tag('nav.sidebar-secondary-nav') do - with_tag('a[href="/checkout-more/after-payment#after-paaaayment"]', - text: 'After paaaayment') - end - end - - it 'has expected title header' do - expect(subject).to have_tag('div.title-header') do - with_tag('div.title-header-container') do - with_tag('h4', text: 'Checkout More') - with_tag('h1', text: 'After payment is completed') - end - end - end - end -end diff --git a/spec/sidebar_features_file_spec.rb b/spec/sidebar_features_file_spec.rb deleted file mode 100644 index 402354385..000000000 --- a/spec/sidebar_features_file_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - features_path = File.join(@dest_dir, 'checkout', 'v2', 'features', 'index.html') - - describe features_path do - subject { File.read(features_path) } - - it { - expect(File).to exist(features_path) - } - - it 'has expected nav structure' do - expect(subject).to have_tag('ul#dx-sidebar-main-nav-ul') do - with_tag('li.main-nav-li.active') do - with_tag('ul.nav-ul') do - with_tag('li.nav-leaf') do - with_tag('li.nav-leaf') do - with_tag('a[href="/checkout/v2/#prerequisites"]', text: 'Prerequisites') - end - end - end - end - end - end - - it 'has expected title header' do - expect(subject).to have_tag('div.title-header') do - with_tag('div.title-header-container') do - with_tag('h4', text: 'Checkout v2') - with_tag('h1', text: 'Features') - end - end - end - - it 'has expected page title' do - expect(subject).to have_tag('title', text: 'Checkout v2 – Features') - end - end -end diff --git a/spec/sidebar_front_page_spec.rb b/spec/sidebar_front_page_spec.rb deleted file mode 100644 index 590439f7f..000000000 --- a/spec/sidebar_front_page_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - front_page_path = File.join(@dest_dir, 'page1.html') - - describe front_page_path do - subject { File.read(front_page_path) } - - it { - expect(File).to exist(front_page_path) - } - - it 'has expected nav structure' do - expect(subject).to have_tag('ul.nav-ul') do - with_tag('li.nav-leaf') do - end - end - end - - it 'has release notes' do - expect(subject).to have_tag('div.front-page-release-notes') do - with_tag('div.release-notes-container') do - with_tag('div.release-notes-date') do - with_tag('a[href="/resources/release-notes#28-may-2020"]', text: '28 May 2020') - end - with_tag('div') do - with_tag('p.h4') do - with_tag('a[href="/resources/release-notes#version-1110"]', text: 'Version 1.11.0') - end - with_tag('ul') do - with_tag('li', text: 'Added a new Trustly Payments section.') - end - end - end - end - end - end -end diff --git a/spec/sidebar_index_file_spec.rb b/spec/sidebar_index_file_spec.rb deleted file mode 100644 index c1447c625..000000000 --- a/spec/sidebar_index_file_spec.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - index_path = File.expand_path(File.join(@dest_dir, 'index.html')) - - describe index_path do - subject { File.read(index_path) } - - it { - expect(File).to exist(index_path) - } - - it 'does not have "has-secondary-nav" class' do - expect(subject).to have_tag('#dg-sidebar:not([class*="has-secondary-nav"])') - end - - it 'has nav leaf' do - expect(subject).to have_tag('ul#dx-sidebar-main-nav-ul') do - with_tag('li.main-nav-li') do - with_tag('nav.sidebar-secondary-nav') do - with_tag('ul.secondary-nav-ul') do - with_tag('li.secondary-nav-li.leaf') do - with_tag('li.leaf') do - with_tag('a[href="/checkout/v2/"]', text: 'Checkout v2') - end - end - end - end - end - end - end - - it 'has active home item' do - expect(subject).to have_tag('ul#dx-sidebar-main-nav-ul.main-nav-ul') do - with_tag('li.main-nav-li.active') do - with_tag('a[href="/"]', text: 'homeHome') do - with_tag('i.material-icons-outlined', text: 'home') - end - with_tag('nav.sidebar-secondary-nav') do - with_tag('header.secondary-nav-header', text: 'Home') - end - end - end - end - - it 'has checkin items' do - expect(subject).to have_tag('ul#dx-sidebar-main-nav-ul') do - with_tag('li.main-nav-li') do - with_tag('nav.sidebar-secondary-nav') do - with_tag('ul.secondary-nav-ul') do - with_tag('li.secondary-nav-li.leaf') do - with_tag('li.group') do - with_tag('li.nav-leaf') do - with_tag('a[href="/checkout/v2/checkin#step-1-initiate-session-for-consumer-identification"]', - text: 'Step 1: Initiate session for consumer identification') - end - with_tag('li.nav-leaf') do - with_tag('a[href="/checkout/v2/checkin#step-2-display-swedbank-pay-checkin-module"]', - text: 'Step 2: Display Swedbank Pay Checkin module') - end - end - end - end - end - end - end - end - - # Hidden pages shouldn't be visible for non-hidden pages - it 'has no navigation for hidden pages' do - expect(subject).not_to have_tag('a[href="/payments/secrets/"]') - expect(subject).not_to have_tag('a[href="/payments/secrets/super-secret"]') - end - end -end diff --git a/spec/sidebar_po_file_spec.rb b/spec/sidebar_po_file_spec.rb deleted file mode 100644 index a32e6dd2c..000000000 --- a/spec/sidebar_po_file_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - po_path = File.join(@dest_dir, 'checkout', 'v2', 'features', 'core', 'payment-order.html') - - describe po_path do - subject { File.read(po_path) } - - it { - expect(File).to exist(po_path) - } - - it 'has expected nav structure' do - expect(subject).to have_tag('nav.sidebar-main-nav') do - with_tag('ul#dx-sidebar-main-nav-ul') do - with_tag('li.main-nav-li.active') do - with_tag('ul.secondary-nav-ul') do - with_tag('li.secondary-nav-li.leaf.active') do - with_tag('i.material-icons', text: 'arrow_back_ios') - with_tag('a[href="/checkout/v2/features/core/payment-order"]', text: 'Payment Order') - end - with_tag('ul.secondary-nav-ul') do - with_tag('li.secondary-nav-li') do - with_tag('a[href="/checkout/v2/features/core/payment-order"]', text: 'Payment Order') - end - end - end - end - end - end - end - - it 'has expected title header' do - expect(subject).to have_tag('div.title-header') do - with_tag('div.title-header-container') do - with_tag('h4', text: 'Checkout v2') - with_tag('h1', text: 'Payment Order') - end - end - end - - it 'has expected page title' do - expect(subject).to have_tag('title', text: 'Checkout v2 – Payment Order') - end - end -end diff --git a/spec/sidebar_redirect_file_spec.rb b/spec/sidebar_redirect_file_spec.rb deleted file mode 100644 index 06f70b7ee..000000000 --- a/spec/sidebar_redirect_file_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - redirect_path = File.join(@dest_dir, 'resources', 'redirect-from.html') - - describe redirect_path do - subject { File.read(redirect_path) } - - it { - expect(File).to exist(redirect_path) - } - - it { - expect(subject).not_to include('arrow_rightHome') - } - end -end diff --git a/spec/sidebar_resource_file_spec.rb b/spec/sidebar_resource_file_spec.rb deleted file mode 100644 index 4d8de616c..000000000 --- a/spec/sidebar_resource_file_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - resource_path = File.join(@dest_dir, 'resources', 'index.html') - - describe resource_path do - subject { File.read(resource_path) } - - it { - expect(File).to exist(resource_path) - } - - it 'has expected nav structure' do - expect(subject).to have_tag('ul#dx-sidebar-main-nav-ul') do - with_tag('li.main-nav-li.active') do - # TODO: Navigate to http://localhost:4000/resources/ and fix the link - # that is currently empty. - with_tag('a[href="/resources/"]', text: /Resources/) - end - with_tag('nav.sidebar-secondary-nav') do - with_tag('li.secondary-nav-li') do - with_tag('a[href="/resources/release-notes"]', text: 'Release Notes') - end - end - with_tag('li.secondary-nav-li') do - with_tag('a[href="/resources/sub-resources/"]', text: 'Sub-resources') - end - end - end - end -end diff --git a/spec/sidebar_search_file_spec.rb b/spec/sidebar_search_file_spec.rb deleted file mode 100644 index d99d34969..000000000 --- a/spec/sidebar_search_file_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - search_path = File.join(@dest_dir, 'search.html') - - describe search_path do - subject { File.read(search_path) } - - it { - expect(File).to exist(search_path) - } - - it 'does not have search item' do - expect(subject).not_to have_tag('.main-nav-ul span', text: 'Search') - expect(subject).not_to have_tag('.main-nav-ul a[href="/search"]') - end - end -end diff --git a/spec/sidebar_spec.rb b/spec/sidebar_spec.rb deleted file mode 100644 index cc5fb3a62..000000000 --- a/spec/sidebar_spec.rb +++ /dev/null @@ -1,145 +0,0 @@ -# frozen_string_literal: true - -require 'its' -require 'jekyll' -require 'sidebar' -require 'sidebar_page_collection' - -sidebar = SwedbankPay::Sidebar - -describe sidebar do - include_context 'shared' - - describe '#pages' do - subject { sidebar.pages } - - its(:count) { is_expected.to eq 247 } - its(:length) { is_expected.to eq 12 } - - describe '[0]' do - subject { sidebar.pages[index[0]] } - - let(:index) { |x| parse_index(x) } - - its(:path) { is_expected.to eq '/' } - its(:children) { is_expected.to be_an_instance_of SwedbankPay::SidebarPageCollection } - its(:hidden?) { is_expected.to be false } - its(:title) { is_expected.to be_string 'Home' } - end - - describe '[1].title' do - let(:index) { |x| parse_index(x) } - - it { expect(sidebar.pages[index[0]].title).to be_string 'Products' } - end - - describe '[5]' do - subject { sidebar.pages[index[0]] } - - let(:index) { |x| parse_index(x) } - - its(:path) { is_expected.to eq '/checkout/' } - its(:active?, '/checkout/') { is_expected.to be true } - its(:hidden?) { is_expected.to be false } - - describe 'children[0]' do - subject { sidebar.pages[index[0]].children[index[1]] } - - its(:title) { is_expected.to be_string 'Checkout v2' } - its(:path) { is_expected.to eq '/checkout/v2/' } - its(:active?, '/checkout/v2/after-payment') { is_expected.to be true } - its(:active?, '/checkout/v2/features/core/payment-order') { is_expected.to be true } - its(:active?, '/checkout/v2/features/core/payment-order', is_leaf: true) { is_expected.to be false } - - describe 'children[3]' do - subject { sidebar.pages[index[0]].children[index[1]].children[index[2]] } - - its(:path) { is_expected.to eq '/checkout/v2/after-payment' } - its(:active?, '/checkout/v2/after-payment') { is_expected.to be true } - end - - describe 'children[4]' do - subject { sidebar.pages[index[0]].children[index[1]].children[index[2]] } - - its(:path) { is_expected.to eq '/checkout/v2/features/' } - its(:active?, '/checkout/v2/features/core/payment-order') { is_expected.to be true } - its(:active?, '/checkout/v2/features/core/payment-order', is_leaf: true) { is_expected.to be false } - - describe 'children[0]' do - subject { sidebar.pages[index[0]].children[index[1]].children[index[2]].children[index[3]] } - - its(:path) { is_expected.to eq '/checkout/v2/features/core/' } - its(:active?, '/checkout/v2/features/core/') { is_expected.to be true } - - describe 'children[4]' do - subject { sidebar.pages[index[0]].children[index[1]].children[index[2]].children[index[3]].children[index[4]] } - - its(:path) { is_expected.to eq '/checkout/v2/features/core/payment-order' } - its(:active?, '/checkout/v2/features/core/payment-order') { is_expected.to be true } - end - end - end - end - end - - describe '[7]' do - subject { sidebar.pages[index[0]] } - - let(:index) { |x| parse_index(x) } - - its(:title) { is_expected.to be_string 'Payments' } - - describe 'children' do - subject { sidebar.pages[index[0]].children } - - its(:length) { is_expected.to eq 3 } - - describe '[2]' do - subject { sidebar.pages[index[0]].children[index[1]] } - - its(:hidden?) { is_expected.to be true } - its(:title) { is_expected.to be_string 'Secret payments' } - - describe 'children' do - subject { sidebar.pages[index[0]].children[index[1]].children } - - its(:length) { is_expected.to eq 1 } - - describe '[0]' do - subject { sidebar.pages[index[0]].children[index[1]].children[index[2]] } - - its(:hidden?) { is_expected.to be true } - its(:title) { is_expected.to be_string 'Secrets in payments' } - end - end - end - end - end - - describe '[9]' do - subject { sidebar.pages[index[0]] } - - let(:index) { |x| parse_index(x) } - - its(:title) { is_expected.to be_string 'Resources' } - - describe 'children' do - subject { sidebar.pages[index[0]].children } - - its(:length) { is_expected.to eq 5 } - - describe '[0].title' do - it { expect(subject[0].title).to be_string 'Alpha' } - end - - describe '[1].title' do - it { expect(subject[1].title).to be_string 'Beta' } - end - - describe '[2].title' do - it { expect(subject[2].title).to be_string 'Gamma' } - end - end - end - end -end diff --git a/spec/sidebar_super_secret_file_spec.rb b/spec/sidebar_super_secret_file_spec.rb deleted file mode 100644 index 8a635edca..000000000 --- a/spec/sidebar_super_secret_file_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -require 'sidebar' - -describe SwedbankPay::Sidebar do - include_context 'shared' - # TODO: Hidden pages should be hidden from non-hidden pages, but not from other hidden pages within the same or lower hierarchy. - super_secret_path = File.join(@dest_dir, 'payments', 'secrets', 'super-secret.html') - - describe super_secret_path do - subject { File.read(super_secret_path) } - - it { - expect(File).to exist(super_secret_path) - } - - # The navigation for a section that has `hide_from_sidebar: true` should not - # be hidden from itself. - it 'has expected nav structure' do - expect(subject).to have_tag('ul#dx-sidebar-main-nav-ul') do - with_tag('li.secondary-nav-li.leaf.active') do - with_tag('a[href="/payments/secrets/"]', text: 'Secret payments') - - with_tag('ul') do - with_tag('li.leaf') do - with_tag('a[href="/payments/secrets/"]', text: 'Secret payments') do - end - with_tag('ul.nav-ul') do - with_tag('li.nav-leaf') do - with_tag('a[href="/payments/secrets/#how-we-do-secret-payments"]', text: 'How we do secret payments') - end - end - end - - with_tag('li.group.active') do - with_tag('a[href="/payments/secrets/super-secret"]', text: 'Secrets in payments') do - end - end - with_tag('ul') do - with_tag('li.nav-leaf') do - with_tag('a[href="/payments/secrets/super-secret#dont-render-this"]', text: 'Don’t render this') - end - end - end - end - end - end - end -end