feature 'Can see database schema at editing form' do
  include FeatureSpecHelper

  scenario 'See database schema' do
    create(:hidden_table, name: 'secret_tables')
    visit adhoq.root_path

    click_on 'Show tables'

    within('#current-tables') do
      expect(page).to have_text('Current tables')
      expect(page).to have_text(/Version \d+/)

      main_names_and_types =
        table_contant('li[data-table-name="adhoq_queries"] table').from(2).map { |row| row[2, 2] }.take(4)

      expect(main_names_and_types).to eq [
        %w[slug string],
        %w[name string],
        %w[description string],
        %w[query text]
      ]

      expect(page).not_to have_text('secret_tables')
    end
  end
end
