# frozen_string_literal: true

require 'spec_helper'

describe 'Group Boards', :js do
  let(:group) { create(:group) }
  let!(:board_ux) { create(:board, group: group, name: 'UX') }
  let!(:board_dev) { create(:board, group: group, name: 'Dev') }
  let(:user) { create(:group_member, user: create(:user), group: group ).user }

  before do
    stub_licensed_features(multiple_group_issue_boards: true)
    sign_in(user)
    visit group_boards_path(group)
    wait_for_requests
  end

  it 'deletes a group issue board' do
    click_boards_dropdown

    wait_for_requests

    find(:css, '.js-delete-board button').click
    find(:css, '.board-config-modal .js-primary-button').click

    click_boards_dropdown

    page.within('.js-boards-selector') do
      expect(page).not_to have_content(board_dev.name)
      expect(page).to have_content(board_ux.name)
    end
  end

  def click_boards_dropdown
    find(:css, '.js-dropdown-toggle').click
  end
end
