Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/116912
Change subject: Proper edit handling in case of redirects where page does not exist ...................................................................... Proper edit handling in case of redirects where page does not exist * Add QA tests ** Separate the confirm prompt into a separate action Bug: 62175 Change-Id: Iadaacc535283b0ba3d4cd6d3530b615bbf71ff40 --- M javascripts/modules/editor/EditorOverlayBase.js M tests/browser/features/step_definitions/common_steps.rb M tests/browser/features/step_definitions/uploads_steps.rb M tests/browser/features/uploads_lead.feature M tests/browser/features/wikitext_editor.feature 5 files changed, 53 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/12/116912/1 diff --git a/javascripts/modules/editor/EditorOverlayBase.js b/javascripts/modules/editor/EditorOverlayBase.js index ac63781..c8e1129 100644 --- a/javascripts/modules/editor/EditorOverlayBase.js +++ b/javascripts/modules/editor/EditorOverlayBase.js @@ -58,7 +58,11 @@ // FIXME: use generic method for following 3 lines M.pageApi.invalidatePage( title ); - new Page( { title: title, el: $( '#content_wrapper' ) } ).on( 'ready', M.reloadPage ); + new Page( { title: title, el: $( '#content_wrapper' ) } ).on( 'ready', M.reloadPage ). + on( 'error', function() { + // Force refresh when something goes wrong (see bug 62175 for example) + window.location = mw.util.getUrl( title ); + } ); M.router.navigate( '' ); if ( this.isNewPage ) { diff --git a/tests/browser/features/step_definitions/common_steps.rb b/tests/browser/features/step_definitions/common_steps.rb index ceb1a0d..a2d008d 100644 --- a/tests/browser/features/step_definitions/common_steps.rb +++ b/tests/browser/features/step_definitions/common_steps.rb @@ -93,6 +93,11 @@ visit(ArticlePage, :using_params => {:article_name => article}) end +Given(/^I am on a page that does not exist$/) do + name = 'NewPage' + Time.now.to_i.to_s + visit(ArticlePage, :using_params => {:article_name => name}) +end + Then(/^the URL of of my page should contain "(.+)"$/) do |article| on(ArticlePage).current_url.should match article end @@ -106,8 +111,12 @@ on(ArticlePage).back end -When(/^I click the browser back button and confirm$/) do +When(/^I say OK in the confirm dialog$/) do on(ArticlePage).confirm(true) do - on(ArticlePage).back end end + +Then(/^There is a red link with text "(.+)"$/) do |text| + # FIXME: Switch to link_element when red links move to stable + on(ArticlePage).content_wrapper_element.span_element(text: text).when_present(10).should be_visible +end diff --git a/tests/browser/features/step_definitions/uploads_steps.rb b/tests/browser/features/step_definitions/uploads_steps.rb index f4fa1ab..3a6c68a 100644 --- a/tests/browser/features/step_definitions/uploads_steps.rb +++ b/tests/browser/features/step_definitions/uploads_steps.rb @@ -56,10 +56,8 @@ on(ArticlePage).photo_description_element.when_present.should exist end -When(/^I click the upload preview overlay close button and confirm$/) do - on(ArticlePage).confirm(true) do - on(ArticlePage).photo_overlay_close_button_element.click - end +When(/^I click the upload preview overlay close button$/) do + on(ArticlePage).photo_overlay_close_button_element.click end Then(/^I don't see the upload preview$/) do diff --git a/tests/browser/features/uploads_lead.feature b/tests/browser/features/uploads_lead.feature index 37ab6cb..38ca5b7 100644 --- a/tests/browser/features/uploads_lead.feature +++ b/tests/browser/features/uploads_lead.feature @@ -11,11 +11,13 @@ And I can enter a description for my file upload Scenario: Closing upload preview (overlay button) - When I click the upload preview overlay close button and confirm + When I click the upload preview overlay close button + And I say OK in the confirm dialog Then I don't see the upload preview And the URL of of my page should contain "Nonexistent_page_abc" Scenario: Closing upload preview (browser button) - When I click the browser back button and confirm + When I click the browser back button + And I say OK in the confirm dialog Then I don't see the upload preview And the URL of of my page should contain "Nonexistent_page_abc" diff --git a/tests/browser/features/wikitext_editor.feature b/tests/browser/features/wikitext_editor.feature index 3c8708b..cc94086 100644 --- a/tests/browser/features/wikitext_editor.feature +++ b/tests/browser/features/wikitext_editor.feature @@ -3,18 +3,45 @@ Background: Given I am logged into the mobile website - And I am on the "Nonexistent_page_ijewrcmhvg34773" page - When I click the edit button Scenario: Opening editor + Given I am on the "Nonexistent_page_ijewrcmhvg34773" page + When I click the edit button Then I see the wikitext editor Scenario: Closing editor (overlay button) - When I click the wikitext editor overlay close button + Given I am on the "Nonexistent_page_ijewrcmhvg34773" page + When I click the edit button + And I click the wikitext editor overlay close button Then I should not see the wikitext editor And the URL of of my page should contain "Nonexistent_page_ijewrcmhvg34773" Scenario: Closing editor (browser button) - When I click the browser back button + Given I am on the "Nonexistent_page_ijewrcmhvg34773" page + When I click the edit button + And I click the browser back button Then I should not see the wikitext editor And the URL of of my page should contain "Nonexistent_page_ijewrcmhvg34773" + + Scenario: Redirects + Given I am on a page that does not exist + When I click the edit button + And I clear the editor + And I type "#REDIRECT [[Barack Obama]]" into the editor + And I click continue + And I click submit + And I say OK in the confirm dialog + Then I should not see the wikitext editor + And The text of the first heading is "Barack Obama" + + @wip + Scenario: Broken redirects + Given I am on a page that does not exist + When I click the edit button + And I clear the editor + And I type "#REDIRECT [[AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA]]" into the editor + And I click continue + And I click submit + And I say OK in the confirm dialog + Then I should not see the wikitext editor + And There is a red link with text "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -- To view, visit https://gerrit.wikimedia.org/r/116912 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iadaacc535283b0ba3d4cd6d3530b615bbf71ff40 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits