2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Upload a design through graphQL', :js, feature_category: :design_management do
|
2020-11-24 15:15:51 +05:30
|
|
|
include_context 'file upload requests helpers'
|
|
|
|
|
|
|
|
let_it_be(:query) do
|
|
|
|
"
|
|
|
|
mutation uploadDesign($files: [Upload!]!, $projectPath: ID!, $iid: ID!) {
|
|
|
|
designManagementUpload(input: { projectPath: $projectPath, iid: $iid, files: $files}) {
|
|
|
|
clientMutationId,
|
|
|
|
errors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:user) { create(:user, :admin) }
|
|
|
|
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
|
|
|
|
let_it_be(:design) { create(:design) }
|
|
|
|
let_it_be(:map) { { "1": ["variables.files.0"] }.to_json }
|
2021-09-04 01:27:46 +05:30
|
|
|
let_it_be(:operations) do
|
|
|
|
{
|
|
|
|
"operationName": "uploadDesign",
|
|
|
|
"variables": {
|
|
|
|
"files": [nil],
|
|
|
|
"projectPath": design.project.full_path,
|
|
|
|
"iid": design.issue.iid
|
|
|
|
},
|
|
|
|
"query": query
|
|
|
|
}.to_json
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
let(:url) { capybara_url("/api/graphql?private_token=#{personal_access_token.token}") }
|
|
|
|
let(:file) { fixture_file_upload('spec/fixtures/dk.png') }
|
|
|
|
|
|
|
|
subject do
|
|
|
|
HTTParty.post(
|
|
|
|
url,
|
|
|
|
body: {
|
|
|
|
operations: operations,
|
|
|
|
map: map,
|
|
|
|
"1": file
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_lfs_setting(enabled: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.shared_examples 'for a design upload through graphQL' do
|
|
|
|
it 'creates proper objects' do
|
|
|
|
expect { subject }
|
|
|
|
.to change { ::DesignManagement::Design.count }.by(1)
|
|
|
|
.and change { ::LfsObject.count }.by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject.code).to eq(200) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'handling file uploads', 'for a design upload through graphQL'
|
|
|
|
end
|