From 54bb6d645ba70bab3111dfa65ba2365ad5f6fb75 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sat, 8 Jun 2024 00:24:51 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../style/redundant_interpolation.yml | 18 ------ doc/ci/testing/code_coverage.md | 8 +-- doc/development/ai_features/index.md | 2 +- lib/gitlab/application_rate_limiter.rb | 2 +- lib/gitlab/chat/responder/mattermost.rb | 4 +- lib/gitlab/ci/build/releaser.rb | 2 +- lib/gitlab/ci/reports/test_suite.rb | 2 +- lib/gitlab/ci/runner_instructions.rb | 2 +- lib/gitlab/console.rb | 2 +- lib/gitlab/metrics/web_transaction.rb | 2 +- .../strategies/record_loader_strategy.rb | 2 +- lib/gitlab/prometheus_client.rb | 2 +- lib/gitlab/repository_cache.rb | 2 +- lib/gitlab/repository_cache_adapter.rb | 2 +- lib/gitlab/repository_hash_cache.rb | 2 +- qa/qa/page/project/web_ide/vscode.rb | 59 +++++++++++-------- .../web_ide/add_first_file_in_web_ide_spec.rb | 4 +- .../add_new_directory_in_web_ide_spec.rb | 4 +- ...osing_web_ide_with_unsaved_changes_spec.rb | 5 +- .../upload_new_file_in_web_ide_spec.rb | 13 ++-- .../ide/components/repo_editor_spec.js | 17 +++--- 21 files changed, 74 insertions(+), 82 deletions(-) delete mode 100644 .rubocop_todo/style/redundant_interpolation.yml diff --git a/.rubocop_todo/style/redundant_interpolation.yml b/.rubocop_todo/style/redundant_interpolation.yml deleted file mode 100644 index e8d6648a55d..00000000000 --- a/.rubocop_todo/style/redundant_interpolation.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -# Cop supports --autocorrect. -Style/RedundantInterpolation: - Exclude: - - 'lib/backup/manager.rb' - - 'lib/gitlab/application_rate_limiter.rb' - - 'lib/gitlab/chat/responder/mattermost.rb' - - 'lib/gitlab/ci/build/releaser.rb' - - 'lib/gitlab/ci/reports/test_suite.rb' - - 'lib/gitlab/ci/runner_instructions.rb' - - 'lib/gitlab/console.rb' - - 'lib/gitlab/metrics/web_transaction.rb' - - 'lib/gitlab/pagination/keyset/in_operator_optimization/strategies/record_loader_strategy.rb' - - 'lib/gitlab/prometheus_client.rb' - - 'lib/gitlab/repository_cache.rb' - - 'lib/gitlab/repository_cache_adapter.rb' - - 'lib/gitlab/repository_hash_cache.rb' - diff --git a/doc/ci/testing/code_coverage.md b/doc/ci/testing/code_coverage.md index 413dce9cf18..d7b350340aa 100644 --- a/doc/ci/testing/code_coverage.md +++ b/doc/ci/testing/code_coverage.md @@ -55,14 +55,14 @@ coverage in the tool's output: | Name | Language | Command | Example | |--------------|--------------|--------------|--------------| | Simplecov | Ruby | None | `/\(\d+.\d+\%\) covered/` | -| pytest-cov | Python | None | `/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/` | -| Scoverage | Scala | None | `/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/` | +| pytest-cov | Python | None | `/TOTAL.*? (100(?:\.0+)?\%\|[1-9]?\d(?:\.\d+)?\%)$/` | +| Scoverage | Scala | None | `/(?i)total.*? (100(?:\.0+)?\%\|[1-9]?\d(?:\.\d+)?\%)$/` | | pest | PHP | `pest --coverage --colors=never` | `/Statement coverage[A-Za-z\.*]\s*:\s*([^%]+)/` | | phpunit | PHP | `phpunit --coverage-text --colors=never` | `/^\s*Lines:\s*\d+.\d+\%/` | | gcovr | C/C++ | None | `/^TOTAL.*\s+(\d+\%)$/` | | tap | NodeJs | `tap --coverage-report=text-summary` | `/^Statements\s*:\s*([^%]+)/` | -| nyc | NodeJs | `nyc npm test` | `/All files[^|]*\|[^|]*\s+([\d\.]+)/` | -| jest | NodeJs | `jest --ci --coverage` | `/All files[^|]*\|[^|]*\s+([\d\.]+)/` | +| nyc | NodeJs | `nyc npm test` | `/All files[^\|]*\|[^\|]*\s+([\d\.]+)/` | +| jest | NodeJs | `jest --ci --coverage` | `/All files[^\|]*\|[^\|]*\s+([\d\.]+)/` | | excoveralls | Elixir | None | `/\[TOTAL\]\s+(\d+\.\d+)%/` | | mix | Elixir | `mix test --cover` | `/\d+.\d+\%\s+\|\s+Total/` | | JaCoCo | Java/Kotlin | None | `/Total.*?([0-9]{1,3})%/` | diff --git a/doc/development/ai_features/index.md b/doc/development/ai_features/index.md index 21067babd9a..8fe36c9b917 100644 --- a/doc/development/ai_features/index.md +++ b/doc/development/ai_features/index.md @@ -18,7 +18,7 @@ To obtain a Google Cloud service key for local development, follow the steps bel 1. Set up a Google Cloud project 1. Option 1 (recommended for GitLab team members): request access to our - existing group Google Cloud project by using + existing group Google Cloud project (`ai-enablement-dev-69497ba7`) by using [this template](https://gitlab.com/gitlab-com/it/infra/issue-tracker/-/issues/new?issuable_template=gcp_group_account_iam_update_request) This project has Vertex APIs and Vertex AI Search (for Duo Chat documentaton questions) already enabled diff --git a/lib/gitlab/application_rate_limiter.rb b/lib/gitlab/application_rate_limiter.rb index 266e0f1e600..f69ac1c196c 100644 --- a/lib/gitlab/application_rate_limiter.rb +++ b/lib/gitlab/application_rate_limiter.rb @@ -243,7 +243,7 @@ module Gitlab serialized = composed_key.map do |obj| if obj.is_a?(String) || obj.is_a?(Symbol) - "#{obj}" + obj.to_s else "#{obj.class.model_name.to_s.underscore}:#{obj.id}" end diff --git a/lib/gitlab/chat/responder/mattermost.rb b/lib/gitlab/chat/responder/mattermost.rb index 0488c98e422..6f765a92a66 100644 --- a/lib/gitlab/chat/responder/mattermost.rb +++ b/lib/gitlab/chat/responder/mattermost.rb @@ -40,7 +40,7 @@ module Gitlab { short: true, title: "ID", - value: "#{build_ref}" + value: build_ref.to_s }, { short: true, @@ -70,7 +70,7 @@ module Gitlab { short: true, title: "ID", - value: "#{build_ref}" + value: build_ref.to_s }, { short: true, diff --git a/lib/gitlab/ci/build/releaser.rb b/lib/gitlab/ci/build/releaser.rb index b94f226223f..22a42e865e6 100644 --- a/lib/gitlab/ci/build/releaser.rb +++ b/lib/gitlab/ci/build/releaser.rb @@ -40,7 +40,7 @@ module Gitlab end def stringified_json(object) - "#{object.to_json.to_json}" + object.to_json.to_json.to_s end def catalog_publish? diff --git a/lib/gitlab/ci/reports/test_suite.rb b/lib/gitlab/ci/reports/test_suite.rb index c681727a43d..ec3ee78c45f 100644 --- a/lib/gitlab/ci/reports/test_suite.rb +++ b/lib/gitlab/ci/reports/test_suite.rb @@ -58,7 +58,7 @@ module Gitlab end TestCase::STATUS_TYPES.each do |status_type| - define_method("#{status_type}") do + define_method(status_type.to_s) do return {} if suite_error || test_cases[status_type].nil? test_cases[status_type] diff --git a/lib/gitlab/ci/runner_instructions.rb b/lib/gitlab/ci/runner_instructions.rb index 3040acc1eb4..bacb6b6198c 100644 --- a/lib/gitlab/ci/runner_instructions.rb +++ b/lib/gitlab/ci/runner_instructions.rb @@ -103,7 +103,7 @@ module Gitlab end def replace_variables(expression) - expression.sub('${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION}', "#{environment[:download_locations][@arch.to_sym]}") + expression.sub('${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION}', (environment[:download_locations][@arch.to_sym]).to_s) end def get_file(path) diff --git a/lib/gitlab/console.rb b/lib/gitlab/console.rb index 8babc09f3fe..5e273f8fa86 100644 --- a/lib/gitlab/console.rb +++ b/lib/gitlab/console.rb @@ -13,7 +13,7 @@ module Gitlab puts '-' * 80 puts " Ruby:".ljust(justify) + RUBY_DESCRIPTION puts " GitLab:".ljust(justify) + "#{Gitlab::VERSION} (#{Gitlab.revision}) #{Gitlab.ee? ? 'EE' : 'FOSS'}" - puts " GitLab Shell:".ljust(justify) + "#{Gitlab::VersionInfo.parse(Gitlab::Shell.version)}" + puts " GitLab Shell:".ljust(justify) + Gitlab::VersionInfo.parse(Gitlab::Shell.version).to_s if ApplicationRecord.database.exists? puts " #{ApplicationRecord.database.human_adapter_name}:".ljust(justify) + ApplicationRecord.database.version diff --git a/lib/gitlab/metrics/web_transaction.rb b/lib/gitlab/metrics/web_transaction.rb index ad635a9e376..ac8afb1ffd8 100644 --- a/lib/gitlab/metrics/web_transaction.rb +++ b/lib/gitlab/metrics/web_transaction.rb @@ -80,7 +80,7 @@ module Gitlab def labels_from_controller controller = @env[CONTROLLER_KEY] - action = "#{controller.action_name}" + action = controller.action_name.to_s # Devise exposes a method called "request_format" that does the below. # However, this method is not available to all controllers (e.g. certain diff --git a/lib/gitlab/pagination/keyset/in_operator_optimization/strategies/record_loader_strategy.rb b/lib/gitlab/pagination/keyset/in_operator_optimization/strategies/record_loader_strategy.rb index 786ae282c88..1254d18e93d 100644 --- a/lib/gitlab/pagination/keyset/in_operator_optimization/strategies/record_loader_strategy.rb +++ b/lib/gitlab/pagination/keyset/in_operator_optimization/strategies/record_loader_strategy.rb @@ -24,7 +24,7 @@ module Gitlab def columns query = finder_query .call(*order_by_columns.array_lookup_expressions_by_position(QueryBuilder::RECURSIVE_CTE_NAME)) - .select("#{table_name}") + .select(table_name.to_s) .limit(1) ["(#{query.to_sql})"] diff --git a/lib/gitlab/prometheus_client.rb b/lib/gitlab/prometheus_client.rb index b1f8cdc668c..a5584455a6d 100644 --- a/lib/gitlab/prometheus_client.rb +++ b/lib/gitlab/prometheus_client.rb @@ -48,7 +48,7 @@ module Gitlab # From Prometheus docs: This endpoint returns 200 when Prometheus is ready to serve traffic (i.e. respond to queries). response.code == 200 rescue StandardError => e - raise PrometheusClient::UnexpectedResponseError, "#{e.message}" + raise PrometheusClient::UnexpectedResponseError, e.message.to_s end def proxy(type, args) diff --git a/lib/gitlab/repository_cache.rb b/lib/gitlab/repository_cache.rb index 498eaf92381..87b00538cfc 100644 --- a/lib/gitlab/repository_cache.rb +++ b/lib/gitlab/repository_cache.rb @@ -7,7 +7,7 @@ module Gitlab def initialize(repository, extra_namespace: nil, backend: self.class.store) @repository = repository - @namespace = "#{repository.full_path}" + @namespace = repository.full_path.to_s @namespace += ":#{repository.project.id}" if repository.project @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @backend = backend diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb index c096c870f2a..97ac7de9aef 100644 --- a/lib/gitlab/repository_cache_adapter.rb +++ b/lib/gitlab/repository_cache_adapter.rb @@ -242,7 +242,7 @@ module Gitlab private def memoizable_name(name) - "#{name.to_s.tr('?!', '')}" + name.to_s.tr('?!', '').to_s end def expire_request_store_method_caches(methods) diff --git a/lib/gitlab/repository_hash_cache.rb b/lib/gitlab/repository_hash_cache.rb index 6da5556833f..95300cc5e15 100644 --- a/lib/gitlab/repository_hash_cache.rb +++ b/lib/gitlab/repository_hash_cache.rb @@ -19,7 +19,7 @@ module Gitlab # @param expires_in [Integer] expiry time for hash store keys def initialize(repository, extra_namespace: nil, expires_in: 1.day) @repository = repository - @namespace = "#{repository.full_path}" + @namespace = repository.full_path.to_s @namespace += ":#{repository.project.id}" if repository.project @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @expires_in = expires_in diff --git a/qa/qa/page/project/web_ide/vscode.rb b/qa/qa/page/project/web_ide/vscode.rb index 14ef6f3a741..56470d1ecb9 100644 --- a/qa/qa/page/project/web_ide/vscode.rb +++ b/qa/qa/page/project/web_ide/vscode.rb @@ -20,7 +20,17 @@ module QA end def has_file?(file_name) - has_element?("div[aria-label='#{file_name}']") + within_vscode_editor do + has_element?("div[aria-label='#{file_name}']") + end + end + + def has_pending_changes? + within_vscode_editor do + all_elements('.action-item', minimum: 1).any? do |item| + item[:'aria-label'] =~ /Source Control .* \d+ pending changes/ + end + end end def open_file_from_explorer(file_name) @@ -36,7 +46,7 @@ module QA end def has_right_click_menu_item? - has_element?('div.menu-item-check') + has_element?('.action-menu-item') end def click_menu_item(item) @@ -44,7 +54,11 @@ module QA end def click_upload_menu_item - click_element('span[aria-label="Upload..."]') + selector = 'span[aria-label="Upload..."]' + Support::Waiter.wait_until do + click_element(selector) + has_no_element?(selector, wait: 1) + end end def enter_text_for_input(name) @@ -56,8 +70,8 @@ module QA find_element('input[type="file"]', visible: false).send_keys(file) end - def has_commit_pending_tab? - has_element?('.scm-viewlet-label') + def has_commit_pending_tab?(wait: Capybara.default_max_wait_time) + has_element?('.scm-viewlet-label', wait: wait) end def click_commit_pending_tab @@ -104,7 +118,9 @@ module QA end def has_committed_successfully? - has_element?('.span[title="Success! Your changes have been committed."]') + within_vscode_editor do + has_text?('Success! Your changes have been committed.') + end end def has_message?(content) @@ -117,10 +133,8 @@ module QA page.execute_script "window.close();" if page.current_url.include?('ide') end - def ide_tab_closed? - within_vscode_editor do - has_file_explorer? - end + def ide_tab_closed?(wait: Capybara.default_max_wait_time) + has_no_element?('#ide iframe', wait: wait) end def within_vscode_editor(&block) @@ -183,16 +197,18 @@ module QA def commit_and_push_to_new_branch(file_name) commit_toggle(file_name) push_to_new_branch + Support::Waiter.wait_until { !has_text?("Loading GitLab Web IDE...", wait: 1) } end def commit_and_push_to_existing_branch(file_name) commit_toggle(file_name) push_to_existing_branch + Support::Waiter.wait_until { !has_text?("Loading GitLab Web IDE...", wait: 1) } end def commit_toggle(message) within_vscode_editor do - if has_commit_pending_tab? + if has_commit_pending_tab?(wait: 0) click_commit_pending_tab else click_commit_tab @@ -209,8 +225,8 @@ module QA def push_to_existing_branch within_vscode_editor do click_continue_with_existing_branch - has_committed_successfully? end + raise "failed to push_to_existing_branch" unless has_committed_successfully? end def push_to_new_branch @@ -219,8 +235,8 @@ module QA has_branch_input_field? # Typing enter to 'New branch name' popup to take the default branch name send_keys(:enter) - has_committed_successfully? end + raise "failed to push_to_new_branch" unless has_committed_successfully? end def create_merge_request @@ -237,18 +253,9 @@ module QA # VSCode eagerly removes the input[type='file'] from click on Upload. # We need to execute a script on the iframe to stub out the iframes body.removeChild to add it back in. page.execute_script("document.body.removeChild = function(){};") - - # Use for stability, WebIDE inside an iframe is finnicky, webdriver sometimes moves too fast - Support::Retrier.retry_until( - max_attempts: 5, retry_on_exception: true, sleep_interval: 2 - ) do - right_click_file_explorer - has_right_click_menu_item? - click_upload_menu_item - enter_file_input(file_path) - end - # Wait for the file to be uploaded - has_text?(file_path) + right_click_file_explorer + click_upload_menu_item + enter_file_input(file_path) end end @@ -318,7 +325,7 @@ module QA click_menu_item(click_item) # Verify the button is triggered and textbox is waiting for input enter_text_for_input(item_name) - has_text?(item_name) + has_text?(item_name, wait: 1) end end end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb index 6678469ffd3..a97bb63dccc 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb @@ -15,7 +15,7 @@ module QA context 'when a file with the same name already exists' do let(:file_name) { 'README.md' } - it 'throws an error', :blocking, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/432899' do + it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/432899' do Page::Project::WebIDE::VSCode.perform do |ide| ide.create_new_file(file_name) @@ -33,8 +33,6 @@ module QA Page::Project::WebIDE::VSCode.perform do |ide| ide.create_new_file(file_name) ide.commit_and_push_to_existing_branch(file_name) - - expect(ide).to have_message('Success! Your changes have been committed.') end project.visit! diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb index d365c888a74..fafa47a4a4f 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb @@ -23,7 +23,7 @@ module QA Page::Project::WebIDE::VSCode.perform(&:wait_for_ide_to_load) end - it 'throws an error', :blocking, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/386760' do + it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/386760' do Page::Project::WebIDE::VSCode.perform do |ide| ide.create_new_folder(directory_name) @@ -40,7 +40,7 @@ module QA Page::Project::WebIDE::VSCode.perform(&:wait_for_ide_to_load) end - it 'shows successfully but not able to be committed', :blocking, + it 'shows successfully but not able to be committed', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/386761' do Page::Project::WebIDE::VSCode.perform do |ide| ide.create_new_folder(directory_name) diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/closing_web_ide_with_unsaved_changes_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/closing_web_ide_with_unsaved_changes_spec.rb index a3f0247cea8..2fd04dd336c 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/closing_web_ide_with_unsaved_changes_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/closing_web_ide_with_unsaved_changes_spec.rb @@ -13,11 +13,12 @@ module QA Page::Project::WebIDE::VSCode.perform(&:wait_for_ide_to_load) end - it 'shows an alert when there are unsaved changes', :blocking, + it 'shows an alert when there are unsaved changes', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/411298' do Page::Project::WebIDE::VSCode.perform do |ide| ide.create_new_file(file_name) - ide.has_file?(file_name) + Support::Waiter.wait_until { ide.has_pending_changes? } + ide.close_ide_tab expect do ide.ide_tab_closed? diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb index 46d482ccea1..22a740cd4a8 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb @@ -16,12 +16,13 @@ module QA context 'when a file with the same name already exists' do let(:file_name) { 'README.md' } - it 'throws an error', :blocking, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390005' do + it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390005' do Page::Project::WebIDE::VSCode.perform do |ide| ide.upload_file(file_path) - expect(ide) - .to have_message("A file or folder with the name 'README.md' already exists in the destination folder") + expect(ide).to have_message( + "A file or folder with the name 'README.md' already exists in the destination folder" + ) end end end @@ -30,13 +31,13 @@ module QA it "verifies it successfully uploads and commits to a MR" do Page::Project::WebIDE::VSCode.perform do |ide| ide.upload_file(file_path) + Support::Waiter.wait_until { ide.has_pending_changes? } ide.commit_and_push_to_new_branch(file_name) expect(ide).to have_message('Success! Your changes have been committed.') ide.create_merge_request end - # Opens the MR in new tab and verify the file is in the MR page.driver.browser.switch_to.window(page.driver.browser.window_handles.last) @@ -46,14 +47,14 @@ module QA end end - context 'when the file is a text file', :blocking, + context 'when the file is a text file', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390006' do let(:file_name) { 'text_file.txt' } it_behaves_like 'upload a file' end - context 'when the file is an image', :blocking, + context 'when the file is an image', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390007' do let(:file_name) { 'dk.png' } diff --git a/spec/frontend/ide/components/repo_editor_spec.js b/spec/frontend/ide/components/repo_editor_spec.js index 6f53aaed655..5cf3eb9f8b7 100644 --- a/spec/frontend/ide/components/repo_editor_spec.js +++ b/spec/frontend/ide/components/repo_editor_spec.js @@ -1,7 +1,7 @@ import { GlTab } from '@gitlab/ui'; import MockAdapter from 'axios-mock-adapter'; import { editor as monacoEditor, Range } from 'monaco-editor'; -import Vue, { nextTick } from 'vue'; +import { nextTick } from 'vue'; // eslint-disable-next-line no-restricted-imports import Vuex from 'vuex'; import { shallowMount } from '@vue/test-utils'; @@ -115,6 +115,7 @@ describe('RepoEditor', () => { let applyExtensionSpy; let removeExtensionSpy; let extensionsStore; + let store; const waitForEditorSetup = () => new Promise((resolve) => { @@ -122,7 +123,7 @@ describe('RepoEditor', () => { }); const createComponent = async ({ state = {}, activeFile = dummyFile.text } = {}) => { - const store = prepareStore(state, activeFile); + store = prepareStore(state, activeFile); wrapper = shallowMount(RepoEditor, { store, propsData: { @@ -562,7 +563,10 @@ describe('RepoEditor', () => { }); it('does not call initEditor if the file did not change', async () => { - Vue.set(vm, 'file', vm.file); + const newFile = { ...store.state.openFiles[0] }; + wrapper.setProps({ + file: newFile, + }); await nextTick(); expect(vm.initEditor).not.toHaveBeenCalled(); @@ -596,8 +600,7 @@ describe('RepoEditor', () => { it('after switching viewer from edit to diff', async () => { const f = createRemoteFile('newFile'); - Vue.set(vm.$store.state.entries, f.path, f); - + store.state.entries[f.path] = f; jest.spyOn(service, 'getRawFileData').mockImplementation(() => { expect(vm.file.loading).toBe(true); @@ -622,8 +625,8 @@ describe('RepoEditor', () => { const aContent = 'fileA-rawContent\n'; const bContent = 'fileB-rawContent\n'; const fileB = createRemoteFile('fileB'); - Vue.set(vm.$store.state.entries, fileA.path, fileA); - Vue.set(vm.$store.state.entries, fileB.path, fileB); + store.state.entries[fileA.path] = fileA; + store.state.entries[fileB.path] = fileB; jest .spyOn(service, 'getRawFileData')