blob: d62f894279f768a70cc7e40f1a0fdfa069abef87 (
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
85
86
87
88
89
|
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'Upload a file in Web IDE' do
let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', file_name)) }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'upload-file-project'
project.initialize_with_readme = true
end
end
before do
Flow::Login.sign_in
project.visit!
Page::Project::Show.perform(&:open_web_ide!)
end
context 'when a file with the same name already exists' do
let(:file_name) { 'README.md' }
it 'throws an error' do
Page::Project::WebIDE::Edit.perform do |ide|
ide.upload_file(file_path)
end
expect(page).to have_content('The name "README.md" is already taken in this directory.')
end
end
context 'when the file is a text file' do
let(:file_name) { 'text_file.txt' }
it 'shows the Edit tab with the text' do
Page::Project::WebIDE::Edit.perform do |ide|
ide.upload_file(file_path)
expect(ide).to have_file(file_name)
expect(ide).to have_file_addition_icon(file_name)
expect(ide).to have_text('Simple text')
ide.commit_changes
expect(ide).to have_file(file_name)
end
end
end
context 'when the file is binary' do
let(:file_name) { 'logo_sample.svg' }
it 'shows a Download button' do
Page::Project::WebIDE::Edit.perform do |ide|
ide.upload_file(file_path)
expect(ide).to have_file(file_name)
expect(ide).to have_file_addition_icon(file_name)
expect(ide).to have_download_button(file_name)
ide.commit_changes
expect(ide).to have_file(file_name)
end
end
end
context 'when the file is an image' do
let(:file_name) { 'dk.png' }
it 'shows an image viewer' do
Page::Project::WebIDE::Edit.perform do |ide|
ide.upload_file(file_path)
expect(ide).to have_file(file_name)
expect(ide).to have_file_addition_icon(file_name)
expect(ide).to have_image_viewer(file_name)
ide.commit_changes
expect(ide).to have_file(file_name)
end
end
end
end
end
end
|