summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb
blob: 51791c01048382c192336800edb2c9eb3b472934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
# frozen_string_literal: true

module QA
  RSpec.describe(
    'Create',
    :runner,
    quarantine: {
      issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338179',
      type: :bug
    }
  ) do
    describe 'Web IDE web terminal' do
      before do
        project = Resource::Project.fabricate_via_api! do |project|
          project.name = 'web-terminal-project'
        end

        Resource::Repository::Commit.fabricate_via_api! do |commit|
          commit.project = project
          commit.commit_message = 'Add .gitlab/.gitlab-webide.yml'
          commit.add_files(
            [
              {
                file_path: '.gitlab/.gitlab-webide.yml',
                content: <<~YAML
                  terminal:
                    tags: ["web-ide"]
                    script: sleep 60
                YAML
              }
            ]
          )
        end

        @runner = Resource::Runner.fabricate_via_api! do |runner|
          runner.project = project
          runner.name = "qa-runner-#{Time.now.to_i}"
          runner.tags = %w[web-ide]
          runner.image = 'gitlab/gitlab-runner:latest'
          runner.config = <<~END
            concurrent = 1

            [session_server]
              listen_address = "0.0.0.0:8093"
              advertise_address = "localhost:8093"
              session_timeout = 120
          END
        end

        Flow::Login.sign_in

        project.visit!
      end

      after do
        @runner.remove_via_api! if @runner
      end

      it 'user starts the web terminal', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1593' do
        Page::Project::Show.perform(&:open_web_ide!)

        # Start the web terminal and check that there were no errors
        # The terminal screen is a canvas element, so we can't read its content,
        # so we infer that it's working if:
        #  a) The terminal JS package has loaded, and
        #  b) It's not stuck in a "Loading/Starting" state, and
        #  c) There's no alert stating there was a problem
        #
        # The terminal itself is a third-party package so we assume it is
        # adequately tested elsewhere.
        #
        # There are also FE specs
        # * spec/frontend/ide/components/terminal/terminal_controls_spec.js
        Page::Project::WebIDE::Edit.perform do |edit|
          edit.start_web_terminal

          expect(edit).to have_no_alert
          expect(edit).to have_finished_loading
          expect(edit).to have_terminal_screen
        end
      end
    end
  end
end