From cde455c4e63c8c0e798562a29a5df5a7893eec95 Mon Sep 17 00:00:00 2001
From: Grzegorz Bizon <grzesiek.bizon@gmail.com>
Date: Tue, 12 Jan 2016 11:41:24 +0100
Subject: [PATCH] Add encoding feature tests for builds artifacts browser

---
 features/project/builds.feature  | 18 ++++++++++++++++++
 features/steps/project/builds.rb | 30 ++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/features/project/builds.feature b/features/project/builds.feature
index 14c9b6c9a35..e7626222f7f 100644
--- a/features/project/builds.feature
+++ b/features/project/builds.feature
@@ -30,3 +30,21 @@ Feature: Project Builds
     And I click artifacts browse button
     And I click link to subdirectory within build artifacts
     Then I should see content of subdirectory within artifacts archive
+
+  Scenario: I browse directory with UTF-8 characters in name
+    Given recent build has artifacts available
+    And recent build has artifacts metadata available
+    And recent build artifacts contain directory with UTF-8 characters
+    When I visit recent build summary page
+    And I click artifacts browse button
+    And I navigate to directory with UTF-8 characters in name
+    Then I should see content of directory with UTF-8 characters in name
+
+  Scenario: I try to browse directory with invalid UTF-8 characters in name
+    Given recent build has artifacts available
+    And recent build has artifacts metadata available
+    And recent build artifacts contain directory with invalid UTF-8 characters
+    When I visit recent build summary page
+    And I click artifacts browse button
+    And I navigate to parent directory of directory with invalid name
+    Then I should not see directory with invalid name on the list
diff --git a/features/steps/project/builds.rb b/features/steps/project/builds.rb
index 5ee6226a522..12d0dd24427 100644
--- a/features/steps/project/builds.rb
+++ b/features/steps/project/builds.rb
@@ -45,4 +45,34 @@ class Spinach::Features::ProjectBuilds < Spinach::FeatureSteps
       expect(page).to have_content 'doc_sample.txt'
     end
   end
+
+  step 'recent build artifacts contain directory with UTF-8 characters' do
+    # metadata fixture contains relevant directory
+  end
+
+  step 'I navigate to directory with UTF-8 characters in name' do
+    page.within('.tree-table') { click_link 'tests_encoding' }
+    page.within('.tree-table') { click_link 'utf8 test dir ✓' }
+  end
+
+  step 'I should see content of directory with UTF-8 characters in name' do
+    page.within('.tree-table') do
+      expect(page).to have_content '..'
+      expect(page).to have_content 'regular_file_2'
+    end
+  end
+
+  step 'recent build artifacts contain directory with invalid UTF-8 characters' do
+    # metadata fixture contains relevant directory
+  end
+
+  step 'I navigate to parent directory of directory with invalid name' do
+    page.within('.tree-table') { click_link 'tests_encoding' }
+  end
+
+  step 'I should not see directory with invalid name on the list' do
+    page.within('.tree-table') do
+      expect(page).to have_no_content('non-utf8-dir')
+    end
+  end
 end
-- 
GitLab