3354: add integration tests verify textile descriptions for projects
authorradhika <radhika@curoverse.com>
Mon, 25 Aug 2014 14:40:27 +0000 (10:40 -0400)
committerradhika <radhika@curoverse.com>
Mon, 25 Aug 2014 14:40:27 +0000 (10:40 -0400)
apps/workbench/test/integration/projects_test.rb

index b2c9d772d14b652688273023eeeb0d7ee9111017..b4202605783e5af89fa23278f01f2166784a3009 100644 (file)
@@ -25,6 +25,77 @@ class ProjectsTest < ActionDispatch::IntegrationTest
            "Description update did not survive page refresh")
   end
 
+  test 'Find a project and edit description to textile description' do
+    visit page_with_token 'active', '/'
+    find('.arv-project-list a,button', text: 'A Project').
+      click
+    within('.container-fluid', text: api_fixture('groups')['aproject']['name']) do
+      find('span', text: api_fixture('groups')['aproject']['name']).click
+      within('.arv-description-as-subtitle') do
+        find('.fa-pencil').click
+        find('.editable-input textarea').set('*Textile description for A project* - "take me home":/')
+        find('.editable-submit').click
+      end
+      wait_for_ajax
+    end
+    visit current_path
+    assert(find?('.container-fluid', text: 'Textile description for A project'),
+           "Description update did not survive page refresh")
+    assert(!find?('.container-fluid', text: '*Textile description for A project*'),
+           "Textile description is displayed with uninterpreted formatting characters")
+    assert(page.has_link?("take me home"), "link not found in description")
+    click_link 'take me home'
+    assert page.has_text?('My projects')
+    assert page.has_text?('Projects shared with me')
+  end
+
+  test 'Find a project and edit description to html description' do
+    visit page_with_token 'active', '/'
+    find('.arv-project-list a,button', text: 'A Project').
+      click
+    within('.container-fluid', text: api_fixture('groups')['aproject']['name']) do
+      find('span', text: api_fixture('groups')['aproject']['name']).click
+      within('.arv-description-as-subtitle') do
+        find('.fa-pencil').click
+        find('.editable-input textarea').set('<br>Textile description for A project</br> - <a href="/">take me home</a>')
+        find('.editable-submit').click
+      end
+      wait_for_ajax
+    end
+    visit current_path
+    assert(find?('.container-fluid', text: 'Textile description for A project'),
+           "Description update did not survive page refresh")
+    assert(!find?('.container-fluid', text: '<br>Textile description for A project</br>'),
+           "Textile description is displayed with uninterpreted formatting characters")
+    assert(page.has_link?("take me home"),"link not found in description")
+    click_link 'take me home'
+    assert page.has_text?('My projects')
+    assert page.has_text?('Projects shared with me')
+  end
+
+  test 'Find a project and edit description to textile description with link to object' do
+    visit page_with_token 'active', '/'
+    find('.arv-project-list a,button', text: 'A Project').
+      click
+    within('.container-fluid', text: api_fixture('groups')['aproject']['name']) do
+      find('span', text: api_fixture('groups')['aproject']['name']).click
+      within('.arv-description-as-subtitle') do
+        find('.fa-pencil').click
+        find('.editable-input textarea').set('*Textile description for A project* - "go to sub-project":' + api_fixture('groups')['asubproject']['uuid'] + "'")
+        find('.editable-submit').click
+      end
+      wait_for_ajax
+    end
+    visit current_path
+    assert(find?('.container-fluid', text: 'Textile description for A project'),
+           "Description update did not survive page refresh")
+    assert(!find?('.container-fluid', text: '*Textile description for A project*'),
+           "Textile description is displayed with uninterpreted formatting characters")
+    assert(page.has_link?("go to sub-project"), "link not found in description")
+    click_link 'go to sub-project'
+    assert(page.has_text?(api_fixture('groups')['asubproject']['name']), 'sub-project name not found after clicking link')
+  end
+
   test 'Add a new name, then edit it, without creating a duplicate' do
     project_uuid = api_fixture('groups')['aproject']['uuid']
     specimen_uuid = api_fixture('specimens')['owned_by_aproject_with_no_name_link']['uuid']