mediawiki-skins-MinervaNeue/tests/selenium/features/step_definitions/index.js

164 lines
7.5 KiB
JavaScript
Raw Normal View History

const { defineSupportCode } = require( 'cucumber' ),
{ iClickOnTheCategoryButton,
iShouldSeeTheCategoriesOverlay, iShouldSeeAListOfCategories
} = require( './category_steps' ),
{ iAmInAWikiThatHasCategories,
iAmOnAPageThatHasTheFollowingEdits,
Render talk page as a tab instead of an overlay Following up on Jon's POC, this will get rid of the talk board component in favor of linking to the server rendered talk page. Additional Changes: * Cleaned up talk selenium tests. Removed talk_steps.rb which doesn't appear to be used anymore. * Changed talk add button classes to a single class * Moved "Add discussion" button to postheadinghtml per design mock * Added "...talk-explained", "...talk-explained-empty" messages to postheadinghtml per design mock * Due to undesirable jumps in window scroll caused by the section anchor & Toggler.js code when opening the TalkSectionOverlay (read fixme in code), a Promise is always returned from OverlayManager route to reset the scroll position to the top when the section overlay is opened. * Moved "mobile-frontend-talk-fullpage", "mobile-frontend-talk-reply-success", "mobile-frontend-talk-topic-feedback", "mobile-frontend-talk-explained" "mobile-frontend-talk-explained-empty" messages to minerva as minerva is the one who initiates those messages now. * Limited $talk selector to only `.talk` elements since amc talk tab does not need to be targeted * After saving a reply from TalkSectionOverlay, the DOM that is not part of the overlay becomes out of sync since a new reply was created. To get around this, an `onSaveComplete` callback was passed (similar to the TalkSectionAddOverlay) to execute a full page refresh. Although this is clunky, it is the easiest way to resync. Bug: T230695 Depends-On: I80201394fd7015db6700446142b0b4b20829f12e Change-Id: I243f1193bce0da9fa710fc3b5379f90b2d079680
2019-10-17 22:46:07 +00:00
iAmOnATalkPageWithNoTalkTopics,
iAmViewingAWatchedPage, iAmViewingAnUnwatchedPage,
iGoToAPageThatHasLanguages } = require( './create_page_api_steps' ),
{
pageExists, iAmOnAPageThatDoesNotExist, iShouldSeeAToastNotification,
iShouldSeeAToastNotificationWithMessage, iAmUsingMobileScreenResolution,
iAmUsingTheMobileSite, iClickTheBrowserBackButton,
iClickTheOverlayCloseButton, iDoNotSeeAnOverlay,
iAmLoggedIntoTheMobileWebsite,
iAmOnPage, iAmInBetaMode
} = require( './common_steps' ),
{
iShouldSeeAddedContent, iShouldSeeRemovedContent
} = require( './diff_steps' ),
{
iOpenTheLatestDiff,
iClickTheEditButton, iSeeTheWikitextEditorOverlay, iClearTheEditor,
iDoNotSeeTheWikitextEditorOverlay,
iTypeIntoTheEditor, iClickContinue, iClickSubmit, iSayOkayInTheConfirmDialog,
theTextOfTheFirstHeadingShouldBe, thereShouldBeARedLinkWithText
} = require( './editor_steps' ),
{
theWatchstarShouldNotBeSelected, theWatchstarShouldBeSelected,
iClickTheWatchstar, iClickTheUnwatchStar } = require( './watch_steps' ),
{ iVisitMyUserPage, iShouldBeOnMyUserPage, thereShouldBeALinkToMyContributions,
thereShouldBeALinkToMyTalkPage
} = require( './user_page_steps' ),
{
iClickTheSearchIcon,
iTypeIntoTheSearchBox,
iClickASearchWatchstar,
iSeeTheSearchOverlay
} = require( './search_steps' ),
{
Render talk page as a tab instead of an overlay Following up on Jon's POC, this will get rid of the talk board component in favor of linking to the server rendered talk page. Additional Changes: * Cleaned up talk selenium tests. Removed talk_steps.rb which doesn't appear to be used anymore. * Changed talk add button classes to a single class * Moved "Add discussion" button to postheadinghtml per design mock * Added "...talk-explained", "...talk-explained-empty" messages to postheadinghtml per design mock * Due to undesirable jumps in window scroll caused by the section anchor & Toggler.js code when opening the TalkSectionOverlay (read fixme in code), a Promise is always returned from OverlayManager route to reset the scroll position to the top when the section overlay is opened. * Moved "mobile-frontend-talk-fullpage", "mobile-frontend-talk-reply-success", "mobile-frontend-talk-topic-feedback", "mobile-frontend-talk-explained" "mobile-frontend-talk-explained-empty" messages to minerva as minerva is the one who initiates those messages now. * Limited $talk selector to only `.talk` elements since amc talk tab does not need to be targeted * After saving a reply from TalkSectionOverlay, the DOM that is not part of the overlay becomes out of sync since a new reply was created. To get around this, an `onSaveComplete` callback was passed (similar to the TalkSectionAddOverlay) to execute a full page refresh. Although this is clunky, it is the easiest way to resync. Bug: T230695 Depends-On: I80201394fd7015db6700446142b0b4b20829f12e Change-Id: I243f1193bce0da9fa710fc3b5379f90b2d079680
2019-10-17 22:46:07 +00:00
iClickTheAddTalkButton,
iAddATopic,
iSeeTheTalkOverlay,
thereShouldBeASaveDiscussionButton,
noTopicIsPresent,
thereShouldBeAnAddDiscussionButton,
Render talk page as a tab instead of an overlay Following up on Jon's POC, this will get rid of the talk board component in favor of linking to the server rendered talk page. Additional Changes: * Cleaned up talk selenium tests. Removed talk_steps.rb which doesn't appear to be used anymore. * Changed talk add button classes to a single class * Moved "Add discussion" button to postheadinghtml per design mock * Added "...talk-explained", "...talk-explained-empty" messages to postheadinghtml per design mock * Due to undesirable jumps in window scroll caused by the section anchor & Toggler.js code when opening the TalkSectionOverlay (read fixme in code), a Promise is always returned from OverlayManager route to reset the scroll position to the top when the section overlay is opened. * Moved "mobile-frontend-talk-fullpage", "mobile-frontend-talk-reply-success", "mobile-frontend-talk-topic-feedback", "mobile-frontend-talk-explained" "mobile-frontend-talk-explained-empty" messages to minerva as minerva is the one who initiates those messages now. * Limited $talk selector to only `.talk` elements since amc talk tab does not need to be targeted * After saving a reply from TalkSectionOverlay, the DOM that is not part of the overlay becomes out of sync since a new reply was created. To get around this, an `onSaveComplete` callback was passed (similar to the TalkSectionAddOverlay) to execute a full page refresh. Although this is clunky, it is the easiest way to resync. Bug: T230695 Depends-On: I80201394fd7015db6700446142b0b4b20829f12e Change-Id: I243f1193bce0da9fa710fc3b5379f90b2d079680
2019-10-17 22:46:07 +00:00
thereShouldBeATalkButton,
thereShouldBeNoTalkButton,
iShouldSeeTheTopicInTheListOfTopics
} = require( './talk_steps' ),
{ iSeeALinkToAboutPage, iShouldSeeAUserPageLinkInMenu,
iClickOnTheMainNavigationButton,
iShouldSeeALinkInMenu, iShouldSeeALinkToDisclaimer
} = require( './menu_steps' ),
{ iHaveNoNotifications, iClickOnTheNotificationIcon,
iShouldSeeTheNotificationsOverlay, iClickTheNotificationsOverlayCloseButton,
iShouldNotSeeTheNotificationsOverlay
} = require( './notification_steps' ),
{
iClickOnTheHistoryLinkInTheLastModifiedBar
} = require( './history_steps' );
defineSupportCode( function ( { Then, When, Given } ) {
// Editor steps
Given( /^I click the edit button$/, iClickTheEditButton );
Then( /^I see the wikitext editor overlay$/, iSeeTheWikitextEditorOverlay );
When( /^I clear the editor$/, iClearTheEditor );
When( /^I type "(.+)" into the editor$/, iTypeIntoTheEditor );
When( /^I click continue$/, iClickContinue );
When( /^I click submit$/, iClickSubmit );
When( /^I say OK in the confirm dialog$/, iSayOkayInTheConfirmDialog );
When( /^I click the wikitext editor overlay close button$/, iClickTheOverlayCloseButton );
Then( /^I do not see the wikitext editor overlay$/, iDoNotSeeTheWikitextEditorOverlay );
Then( /^the text of the first heading should be "(.+)"$/, theTextOfTheFirstHeadingShouldBe );
Then( /^there should be a red link with text "(.+)"$/, thereShouldBeARedLinkWithText );
Then( /^I should not see the wikitext editor overlay$/, iDoNotSeeAnOverlay );
// common steps
Given( /^I am using the mobile site$/, iAmUsingTheMobileSite );
When( /^I am viewing the site in mobile mode$/, iAmUsingMobileScreenResolution );
Given( /^I am in beta mode$/, iAmInBetaMode );
Given( /^I am on the "(.+)" page$/, iAmOnPage );
Given( /^I am logged into the mobile website$/, iAmLoggedIntoTheMobileWebsite );
Then( /^I should see a toast notification$/, iShouldSeeAToastNotification );
Then( /^I should see a toast with message "(.+)"$/, iShouldSeeAToastNotificationWithMessage );
When( /I click the browser back button/, iClickTheBrowserBackButton );
// Page steps
Render talk page as a tab instead of an overlay Following up on Jon's POC, this will get rid of the talk board component in favor of linking to the server rendered talk page. Additional Changes: * Cleaned up talk selenium tests. Removed talk_steps.rb which doesn't appear to be used anymore. * Changed talk add button classes to a single class * Moved "Add discussion" button to postheadinghtml per design mock * Added "...talk-explained", "...talk-explained-empty" messages to postheadinghtml per design mock * Due to undesirable jumps in window scroll caused by the section anchor & Toggler.js code when opening the TalkSectionOverlay (read fixme in code), a Promise is always returned from OverlayManager route to reset the scroll position to the top when the section overlay is opened. * Moved "mobile-frontend-talk-fullpage", "mobile-frontend-talk-reply-success", "mobile-frontend-talk-topic-feedback", "mobile-frontend-talk-explained" "mobile-frontend-talk-explained-empty" messages to minerva as minerva is the one who initiates those messages now. * Limited $talk selector to only `.talk` elements since amc talk tab does not need to be targeted * After saving a reply from TalkSectionOverlay, the DOM that is not part of the overlay becomes out of sync since a new reply was created. To get around this, an `onSaveComplete` callback was passed (similar to the TalkSectionAddOverlay) to execute a full page refresh. Although this is clunky, it is the easiest way to resync. Bug: T230695 Depends-On: I80201394fd7015db6700446142b0b4b20829f12e Change-Id: I243f1193bce0da9fa710fc3b5379f90b2d079680
2019-10-17 22:46:07 +00:00
Given( /^I am on a talk page with no talk topics$/, iAmOnATalkPageWithNoTalkTopics );
Given( /^I am in a wiki that has categories$/, () => {
iAmInAWikiThatHasCategories( 'Selenium categories test page' );
} );
Given( /^I am on a page that has the following edits:$/, iAmOnAPageThatHasTheFollowingEdits );
Given( /^I am on a page that does not exist$/, iAmOnAPageThatDoesNotExist );
Given( /^I go to a page that has languages$/, iGoToAPageThatHasLanguages );
Given( /^the page "(.+)" exists$/, pageExists );
Given( /^I am viewing a watched page$/, iAmViewingAWatchedPage );
Given( /^I am viewing an unwatched page$/, iAmViewingAnUnwatchedPage );
// history steps
When( /^I open the latest diff$/, iOpenTheLatestDiff );
When( /^I click on the history link in the last modified bar$/,
iClickOnTheHistoryLinkInTheLastModifiedBar );
// diff steps
Then( /^I should see "(.*?)" as added content$/, iShouldSeeAddedContent );
Then( /^I should see "(.*?)" as removed content$/, iShouldSeeRemovedContent );
// notifications
Then( /I have no notifications/, iHaveNoNotifications );
When( /I click on the notification icon/, iClickOnTheNotificationIcon );
When( /I click the notifications overlay close button/, iClickTheNotificationsOverlayCloseButton );
Then( /after 1 seconds I should not see the notifications overlay/, iShouldNotSeeTheNotificationsOverlay );
Then( /I should see the notifications overlay/, iShouldSeeTheNotificationsOverlay );
// talk
Render talk page as a tab instead of an overlay Following up on Jon's POC, this will get rid of the talk board component in favor of linking to the server rendered talk page. Additional Changes: * Cleaned up talk selenium tests. Removed talk_steps.rb which doesn't appear to be used anymore. * Changed talk add button classes to a single class * Moved "Add discussion" button to postheadinghtml per design mock * Added "...talk-explained", "...talk-explained-empty" messages to postheadinghtml per design mock * Due to undesirable jumps in window scroll caused by the section anchor & Toggler.js code when opening the TalkSectionOverlay (read fixme in code), a Promise is always returned from OverlayManager route to reset the scroll position to the top when the section overlay is opened. * Moved "mobile-frontend-talk-fullpage", "mobile-frontend-talk-reply-success", "mobile-frontend-talk-topic-feedback", "mobile-frontend-talk-explained" "mobile-frontend-talk-explained-empty" messages to minerva as minerva is the one who initiates those messages now. * Limited $talk selector to only `.talk` elements since amc talk tab does not need to be targeted * After saving a reply from TalkSectionOverlay, the DOM that is not part of the overlay becomes out of sync since a new reply was created. To get around this, an `onSaveComplete` callback was passed (similar to the TalkSectionAddOverlay) to execute a full page refresh. Although this is clunky, it is the easiest way to resync. Bug: T230695 Depends-On: I80201394fd7015db6700446142b0b4b20829f12e Change-Id: I243f1193bce0da9fa710fc3b5379f90b2d079680
2019-10-17 22:46:07 +00:00
When( /^I click the add talk button$/, iClickTheAddTalkButton );
When( /^I add a topic called "(.+)"$/, iAddATopic );
Then( /^I see the talk overlay$/, iSeeTheTalkOverlay );
Then( /^I should see the talk overlay$/, iSeeTheTalkOverlay );
Then( /^there should be a save discussion button$/, thereShouldBeASaveDiscussionButton );
Then( /^no topic is present$/, noTopicIsPresent );
Then( /^there should be an add discussion button$/, thereShouldBeAnAddDiscussionButton );
Render talk page as a tab instead of an overlay Following up on Jon's POC, this will get rid of the talk board component in favor of linking to the server rendered talk page. Additional Changes: * Cleaned up talk selenium tests. Removed talk_steps.rb which doesn't appear to be used anymore. * Changed talk add button classes to a single class * Moved "Add discussion" button to postheadinghtml per design mock * Added "...talk-explained", "...talk-explained-empty" messages to postheadinghtml per design mock * Due to undesirable jumps in window scroll caused by the section anchor & Toggler.js code when opening the TalkSectionOverlay (read fixme in code), a Promise is always returned from OverlayManager route to reset the scroll position to the top when the section overlay is opened. * Moved "mobile-frontend-talk-fullpage", "mobile-frontend-talk-reply-success", "mobile-frontend-talk-topic-feedback", "mobile-frontend-talk-explained" "mobile-frontend-talk-explained-empty" messages to minerva as minerva is the one who initiates those messages now. * Limited $talk selector to only `.talk` elements since amc talk tab does not need to be targeted * After saving a reply from TalkSectionOverlay, the DOM that is not part of the overlay becomes out of sync since a new reply was created. To get around this, an `onSaveComplete` callback was passed (similar to the TalkSectionAddOverlay) to execute a full page refresh. Although this is clunky, it is the easiest way to resync. Bug: T230695 Depends-On: I80201394fd7015db6700446142b0b4b20829f12e Change-Id: I243f1193bce0da9fa710fc3b5379f90b2d079680
2019-10-17 22:46:07 +00:00
Then( /^there should be a talk button/, thereShouldBeATalkButton );
Then( /^there should be no talk button$/, thereShouldBeNoTalkButton );
Then( /^I should see the topic called "(.+)" in the list of topics$/, iShouldSeeTheTopicInTheListOfTopics );
// user page
Given( /^I visit my user page$/, iVisitMyUserPage );
When( /^I should be on my user page$/, iShouldBeOnMyUserPage );
Then( /^there should be a link to my contributions$/, thereShouldBeALinkToMyContributions );
Then( /^there should be a link to my talk page$/, thereShouldBeALinkToMyTalkPage );
// search
When( /^I click the search icon$/, iClickTheSearchIcon );
When( /^I type into search box "(.+)"$/, iTypeIntoTheSearchBox );
When( /^I click a search watch star$/, iClickASearchWatchstar );
Then( /^I see the search overlay$/, iSeeTheSearchOverlay );
// main menu
When( /^I click on the main navigation button$/, iClickOnTheMainNavigationButton );
When( /^I should see a link to the about page$/, iSeeALinkToAboutPage );
Then( /^I should see a link to my user page in the main navigation menu$/, iShouldSeeAUserPageLinkInMenu );
Then( /^I should see a link to "(.+)" in the main navigation menu$/, iShouldSeeALinkInMenu );
Then( /^I should see a link to the disclaimer$/, iShouldSeeALinkToDisclaimer );
// watchstar
When( /^I click the watch star$/, iClickTheWatchstar );
When( /^I click the unwatch star$/, iClickTheUnwatchStar );
Then( /^the watch star should not be selected$/, theWatchstarShouldNotBeSelected );
Then( /^the watch star should be selected$/, theWatchstarShouldBeSelected );
// Category steps
When( /^I click on the category button$/, iClickOnTheCategoryButton );
Then( /^I should see the categories overlay$/, iShouldSeeTheCategoriesOverlay );
Then( /^I should see a list of categories$/, iShouldSeeAListOfCategories );
} );