From 61748c993de8a38300c0c038cec5a07e6c324cd6 Mon Sep 17 00:00:00 2001 From: Ciro Santillli Date: Tue, 4 Feb 2014 08:48:33 +0100 Subject: Headers have ids and link to their own id. --- features/dashboard/help.feature | 8 +++++ features/project/issues/issues.feature | 12 +++++++ features/project/issues/milestones.feature | 6 ++++ features/project/merge_requests.feature | 12 +++++++ features/project/source/markdown_render.feature | 42 ++++++++++++++++++----- features/steps/help.rb | 21 ++++++++++++ features/steps/project/project_issues.rb | 5 ++- features/steps/project/project_markdown_render.rb | 32 ++++++++++------- features/steps/project/project_merge_requests.rb | 5 ++- features/steps/project/project_milestones.rb | 8 +++-- features/steps/shared/markdown.rb | 12 +++++++ features/steps/shared/note.rb | 17 +++++++++ 12 files changed, 154 insertions(+), 26 deletions(-) create mode 100644 features/dashboard/help.feature create mode 100644 features/steps/help.rb create mode 100644 features/steps/shared/markdown.rb (limited to 'features') diff --git a/features/dashboard/help.feature b/features/dashboard/help.feature new file mode 100644 index 00000000000..02ec688f804 --- /dev/null +++ b/features/dashboard/help.feature @@ -0,0 +1,8 @@ +Feature: Help + Background: + Given I sign in as a user + And I visit the "Rake Tasks" help page + + Scenario: The markdown should be rendered correctly + Then I should see "Rake Tasks" page markdown rendered + And Header "Rebuild project satellites" should have correct ids and links diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature index 67986784bc7..033051991e2 100644 --- a/features/project/issues/issues.feature +++ b/features/project/issues/issues.feature @@ -55,3 +55,15 @@ Feature: Project Issues And I fill in issue search with ".3" Then I should see "Release 0.3" in issues And I should not see "Release 0.4" in issues + + # Markdown + + Scenario: Headers inside the description should have ids generated for them. + Given I visit issue page "Release 0.4" + Then Header "Description header" should have correct id and link + + @javascript + Scenario: Headers inside comments should not have ids generated for them. + Given I visit issue page "Release 0.4" + And I leave a comment with a header containing "Comment with a header" + Then The comment with the header should not have an ID diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature index 2f38acf14d0..e67b5d2d860 100644 --- a/features/project/issues/milestones.feature +++ b/features/project/issues/milestones.feature @@ -22,3 +22,9 @@ Feature: Project Milestones Given the milestone has open and closed issues And I click link "v2.2" Then I should see 3 issues + + # Markdown + + Scenario: Headers inside the description should have ids generated for them. + Given I click link "v2.2" + Then Header "Description header" should have correct id and link diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature index 946f6760126..3ca099b9572 100644 --- a/features/project/merge_requests.feature +++ b/features/project/merge_requests.feature @@ -77,3 +77,15 @@ Feature: Project Merge Requests Then I modify merge commit message And I accept this merge request Then I should see merged request + + # Markdown + + Scenario: Headers inside the description should have ids generated for them. + When I visit merge request page "Bug NS-04" + Then Header "Description header" should have correct id and link + + @javascript + Scenario: Headers inside comments should not have ids generated for them. + Given I visit merge request page "Bug NS-04" + And I leave a comment with a header containing "Comment with a header" + Then The comment with the header should not have an ID diff --git a/features/project/source/markdown_render.feature b/features/project/source/markdown_render.feature index 04467b66648..42d6ebcb1cf 100644 --- a/features/project/source/markdown_render.feature +++ b/features/project/source/markdown_render.feature @@ -4,6 +4,15 @@ Feature: Project markdown render And I own project "Delta" Given I visit project source page + # ------------------------------------------- + # README + # ------------------------------------------- + + Scenario: Tree view should have correct links in README + Given I go directory which contains README file + And I click on a relative link in README + Then I should see the correct markdown + Scenario: I browse files from master branch Then I should see files from repository in master And I should see rendered README which contains correct links @@ -28,6 +37,14 @@ Feature: Project markdown render And I click on Maintenance in README Then I should see correct maintenance file rendered + Scenario: README headers should have header links + Then I should see rendered README which contains correct links + And Header "Application details" should have correct id and link + + # ------------------------------------------- + # File content + # ------------------------------------------- + Scenario: I navigate to doc directory to view documentation in master And I navigate to the doc/api/README And I see correct file rendered @@ -40,6 +57,14 @@ Feature: Project markdown render And I click on raketasks in doc/api/README Then I should see correct directory rendered + Scenario: I navigate to doc directory to view user doc in master + And I navigate to the doc/api/README + And Header "GitLab API" should have correct id and link + + # ------------------------------------------- + # Markdown branch README + # ------------------------------------------- + Scenario: I browse files from markdown branch When I visit markdown branch Then I should see files from repository in markdown branch @@ -68,6 +93,10 @@ Feature: Project markdown render And I click on raketasks in doc/api/README Then I should see correct directory rendered for markdown branch + # ------------------------------------------- + # Wiki + # ------------------------------------------- + Scenario: I create a wiki page with different links Given I go to wiki page And I add various links to the wiki page @@ -81,12 +110,7 @@ Feature: Project markdown render And I click on Rake tasks link Then I see Rake tasks directory - Scenario: I visit the help page with markdown - Given I visit to the help page - And I select a page with markdown - Then I should see a help page with markdown - - Scenario: Tree view should have correct links in README - Given I go directory which contains README file - And I click on a relative link in README - Then I should see the correct markdown + Scenario: Wiki headers should have should have ids generated for them. + Given I go to wiki page + And I add a header to the wiki page + Then Wiki header should have correct id and link diff --git a/features/steps/help.rb b/features/steps/help.rb new file mode 100644 index 00000000000..aa147fd65ce --- /dev/null +++ b/features/steps/help.rb @@ -0,0 +1,21 @@ +class Spinach::Features::Help < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedMarkdown + + step 'I visit the help page' do + visit help_path + end + + step 'I visit the "Rake Tasks" help page' do + visit help_raketasks_path + end + + step 'I should see "Rake Tasks" page markdown rendered' do + page.should have_content "GitLab provides some specific rake tasks to enable special features or perform maintenance tasks" + end + + step 'Header "Rebuild project satellites" should have correct ids and links' do + header_should_have_correct_id_and_link(3, 'Rebuild project satellites', 'rebuild-project-satellites') + end +end diff --git a/features/steps/project/project_issues.rb b/features/steps/project/project_issues.rb index 4a503dfaf4f..a92fd50584d 100644 --- a/features/steps/project/project_issues.rb +++ b/features/steps/project/project_issues.rb @@ -3,6 +3,7 @@ class ProjectIssues < Spinach::FeatureSteps include SharedProject include SharedNote include SharedPaths + include SharedMarkdown Given 'I should see "Release 0.4" in issues' do page.should have_content "Release 0.4" @@ -121,7 +122,9 @@ class ProjectIssues < Spinach::FeatureSteps create(:issue, title: "Release 0.4", project: project, - author: project.users.first) + author: project.users.first, + description: "# Description header" + ) end And 'project "Shop" have "Tweet control" open issue' do diff --git a/features/steps/project/project_markdown_render.rb b/features/steps/project/project_markdown_render.rb index 1209aae6434..89fbb7408c2 100644 --- a/features/steps/project/project_markdown_render.rb +++ b/features/steps/project/project_markdown_render.rb @@ -1,6 +1,7 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps include SharedAuthentication include SharedPaths + include SharedMarkdown And 'I own project "Delta"' do @project = Project.find_by(name: "Delta") @@ -44,7 +45,6 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_content "maintenance.md" end - And 'I click on GitLab API doc directory in README' do click_link "GitLab API doc directory" end @@ -140,6 +140,16 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_content "test GitLab API doc Rake tasks" end + step 'I add a header to the wiki page' do + fill_in "wiki[content]", with: "# Wiki header\n" + fill_in "wiki[message]", with: "Add header to wiki" + click_button "Create page" + end + + step 'Wiki header should have correct id and link' do + header_should_have_correct_id_and_link(1, 'Wiki header', 'wiki-header') + end + And 'I click on test link' do click_link "test" end @@ -173,18 +183,6 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_content "maintenance.md" end - Given 'I visit to the help page' do - visit help_path - end - - And 'I select a page with markdown' do - click_link "Rake Tasks" - end - - Then 'I should see a help page with markdown' do - page.should have_content "GitLab provides some specific rake tasks to enable special features or perform maintenance tasks" - end - Given 'I go directory which contains README file' do visit project_tree_path(@project, "master/doc/api") current_path.should == project_tree_path(@project, "master/doc/api") @@ -198,4 +196,12 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps current_path.should == project_blob_path(@project, "master/doc/api/users.md") page.should have_content "List users" end + + step 'Header "Application details" should have correct id and link' do + header_should_have_correct_id_and_link(2, 'Application details', 'application-details') + end + + step 'Header "GitLab API" should have correct id and link' do + header_should_have_correct_id_and_link(1, 'GitLab API', 'gitlab-api') + end end diff --git a/features/steps/project/project_merge_requests.rb b/features/steps/project/project_merge_requests.rb index 0c5f05a0a68..fcbae8b8fb0 100644 --- a/features/steps/project/project_merge_requests.rb +++ b/features/steps/project/project_merge_requests.rb @@ -3,6 +3,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps include SharedProject include SharedNote include SharedPaths + include SharedMarkdown step 'I click link "New Merge Request"' do click_link "New Merge Request" @@ -83,7 +84,9 @@ class ProjectMergeRequests < Spinach::FeatureSteps target_project: project, source_branch: 'stable', target_branch: 'master', - author: project.users.first) + author: project.users.first, + description: "# Description header" + ) end step 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do diff --git a/features/steps/project/project_milestones.rb b/features/steps/project/project_milestones.rb index 85962221c0f..9ce18fbaabd 100644 --- a/features/steps/project/project_milestones.rb +++ b/features/steps/project/project_milestones.rb @@ -2,6 +2,7 @@ class ProjectMilestones < Spinach::FeatureSteps include SharedAuthentication include SharedProject include SharedPaths + include SharedMarkdown Then 'I should see milestone "v2.2"' do milestone = @project.milestones.find_by(title: "v2.2") @@ -32,8 +33,11 @@ class ProjectMilestones < Spinach::FeatureSteps And 'project "Shop" has milestone "v2.2"' do project = Project.find_by(name: "Shop") - milestone = create(:milestone, title: "v2.2", project: project) - + milestone = create(:milestone, + title: "v2.2", + project: project, + description: "# Description header" + ) 3.times { create(:issue, project: project, milestone: milestone) } end diff --git a/features/steps/shared/markdown.rb b/features/steps/shared/markdown.rb new file mode 100644 index 00000000000..782f3f0920b --- /dev/null +++ b/features/steps/shared/markdown.rb @@ -0,0 +1,12 @@ +module SharedMarkdown + include Spinach::DSL + + def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki") + page.find(:css, "#{parent} h#{level}##{id}").text.should == text + page.find(:css, "#{parent} h#{level}##{id} > :last-child")[:href].should =~ /##{id}$/ + end + + step 'Header "Description header" should have correct id and link' do + header_should_have_correct_id_and_link(1, 'Description header', 'description-header') + end +end diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index da08da9420d..36b81b74186 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -102,4 +102,21 @@ module SharedNote page.should have_content("XML attached") end end + + # Markdown + + step 'I leave a comment with a header containing "Comment with a header"' do + within(".js-main-target-form") do + fill_in "note[note]", with: "# Comment with a header" + click_button "Add Comment" + sleep 0.05 + end + end + + step 'The comment with the header should not have an ID' do + within(".note-text") do + page.should have_content("Comment with a header") + page.should_not have_css("#comment-with-a-header") + end + end end -- cgit v1.2.1