applications_spec.rb 4.4 KB
Newer Older
K
Kamil Trzcinski 已提交
1 2 3 4 5
require 'spec_helper'

feature 'Clusters Applications', :js do
  include GoogleApi::CloudPlatformHelpers

K
Kamil Trzcinski 已提交
6 7
  let(:project) { create(:project) }
  let(:user) { create(:user) }
K
Kamil Trzcinski 已提交
8 9 10

  before do
    project.add_master(user)
K
Kamil Trzcinski 已提交
11
    sign_in(user)
K
Kamil Trzcinski 已提交
12 13 14 15 16 17 18 19 20
  end

  describe 'Installing applications' do
    before do
      visit project_cluster_path(project, cluster)
    end

    context 'when cluster is being created' do
      let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project])}
K
Kamil Trzcinski 已提交
21
 
K
Kamil Trzcinski 已提交
22 23 24 25 26 27 28 29 30 31
      scenario 'user is unable to install applications' do
        page.within('.js-cluster-application-row-helm') do
          expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
          expect(page.find(:css, '.js-cluster-application-install-button').text).to eq('Install')
        end
      end
    end

    context 'when cluster is created' do
      let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project])}
K
Kamil Trzcinski 已提交
32

K
Kamil Trzcinski 已提交
33 34 35 36 37 38 39 40 41 42
      scenario 'user can install applications' do
        page.within('.js-cluster-application-row-helm') do
          expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to be_nil
          expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install')
        end
      end

      context 'when user installs Helm' do
        before do
          allow(ClusterInstallAppWorker).to receive(:perform_async).and_return(nil)
K
Kamil Trzcinski 已提交
43

K
Kamil Trzcinski 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
          page.within('.js-cluster-application-row-helm') do
            page.find(:css, '.js-cluster-application-install-button').click
          end
        end

        it 'he sees status transition' do
          page.within('.js-cluster-application-row-helm') do
            # FE sends request and gets the response, then the buttons is "Install"
            expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
            expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install')

            Clusters::Cluster.last.application_helm.make_installing!

            # FE starts polling and update the buttons to "Installing"
            expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
            expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installing')

            Clusters::Cluster.last.application_helm.make_installed!

            expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
            expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installed')
          end

          expect(page).to have_content('Helm Tiller was successfully installed on your cluster')
        end
      end

      context 'when user installs Ingress' do
        context 'when user installs application: Ingress' do
          before do
            allow(ClusterInstallAppWorker).to receive(:perform_async).and_return(nil)

            create(:cluster_applications_helm, :installed, cluster: cluster)

            page.within('.js-cluster-application-row-ingress') do
              page.find(:css, '.js-cluster-application-install-button').click
            end
          end

          it 'he sees status transition' do
            page.within('.js-cluster-application-row-ingress') do
              # FE sends request and gets the response, then the buttons is "Install"
              expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
              expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install')

              Clusters::Cluster.last.application_ingress.make_installing!

              # FE starts polling and update the buttons to "Installing"
              expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
              expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installing')

              Clusters::Cluster.last.application_ingress.make_installed!

              expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
              expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installed')
            end

            expect(page).to have_content('Ingress was successfully installed on your cluster')
          end
        end
      end
    end
  end
end