Selenium: Daily Jenkins job targeting beta cluster should run only tests that pass
[lhc/web/wiklou.git] / tests / selenium / specs / page.js
index 069a6aa..124279c 100644 (file)
@@ -4,16 +4,14 @@ const assert = require( 'assert' ),
        RestorePage = require( '../pageobjects/restore.page' ),
        EditPage = require( '../pageobjects/edit.page' ),
        HistoryPage = require( '../pageobjects/history.page' ),
-       UserLoginPage = require( '../pageobjects/userlogin.page' );
+       UndoPage = require( '../pageobjects/undo.page' ),
+       UserLoginPage = require( '../pageobjects/userlogin.page' ),
+       Util = require( 'wdio-mediawiki/Util' );
 
 describe( 'Page', function () {
        var content,
                name;
 
-       function getTestString( suffix = 'defaultsuffix' ) {
-               return Math.random().toString() + '-Iñtërnâtiônàlizætiøn☃-' + suffix;
-       }
-
        before( function () {
                // disable VisualEditor welcome dialog
                UserLoginPage.open();
@@ -22,8 +20,8 @@ describe( 'Page', function () {
 
        beforeEach( function () {
                browser.deleteCookie();
-               content = getTestString( 'beforeEach-content' );
-               name = getTestString( 'beforeEach-name' );
+               content = Util.getTestString( 'beforeEach-content-' );
+               name = Util.getTestString( 'BeforeEach-name-' );
        } );
 
        it( 'should be creatable', function () {
@@ -36,7 +34,7 @@ describe( 'Page', function () {
        } );
 
        it( 'should be re-creatable', function () {
-               let initialContent = getTestString( 'initialContent' );
+               let initialContent = Util.getTestString( 'initialContent-' );
 
                // create
                browser.call( function () {
@@ -56,14 +54,14 @@ describe( 'Page', function () {
                assert.strictEqual( EditPage.displayedContent.getText(), content );
        } );
 
-       it( 'should be editable', function () {
+       it( 'should be editable @daily', function () {
                // create
                browser.call( function () {
                        return Api.edit( name, content );
                } );
 
                // edit
-               let editContent = getTestString( 'editContent' );
+               let editContent = Util.getTestString( 'editContent-' );
                EditPage.edit( name, editContent );
 
                // check
@@ -71,7 +69,7 @@ describe( 'Page', function () {
                assert.strictEqual( EditPage.displayedContent.getText(), editContent );
        } );
 
-       it( 'should have history', function () {
+       it( 'should have history @daily', function () {
                // create
                browser.call( function () {
                        return Api.edit( name, content );
@@ -121,4 +119,26 @@ describe( 'Page', function () {
                // check
                assert.strictEqual( RestorePage.displayedContent.getText(), name + ' has been restored\nConsult the deletion log for a record of recent deletions and restorations.' );
        } );
+
+       it( 'should be undoable', function () {
+               // create
+               browser.call( function () {
+                       return Api.edit( name, content );
+               } );
+
+               // edit
+               let previousRev, undoRev;
+               browser.call( function () {
+                       return Api.edit( name, Util.getTestString( 'editContent-' ) )
+                               .then( ( response ) => {
+                                       previousRev = response.edit.oldrevid;
+                                       undoRev = response.edit.newrevid;
+                               } );
+               } );
+
+               UndoPage.undo( name, previousRev, undoRev );
+
+               assert.strictEqual( EditPage.displayedContent.getText(), content );
+       } );
+
 } );