-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from ruscoe/24-reset-ordering
Add functionality to reset page order
- Loading branch information
Showing
4 changed files
with
118 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
describe( 'Test Reset Page Order Change', () => { | ||
it( 'Can reset pages order', () => { | ||
cy.login(); | ||
cy.visit('/wp-admin/edit.php?post_type=page'); | ||
|
||
const firstRow = '.wp-list-table tbody tr:nth-child(1)'; | ||
const secondRow = '.wp-list-table tbody tr:nth-child(2)'; | ||
|
||
// Alias titles as `firstRowText` and `secondRowText` for convenience. | ||
cy.get( firstRow ).find( '.row-title' ).invoke( 'text' ).as( 'firstRowText' ); | ||
cy.get( secondRow ).find( '.row-title' ).invoke( 'text' ).as( 'secondRowText' ); | ||
|
||
// Swap position of `Page 1` with `Page 2`. | ||
cy.get( firstRow ).drag( secondRow ); | ||
|
||
// Verifies if 1st row has title `Page 2`. | ||
cy.get( firstRow ).find( '.row-title' ).invoke( 'text' ).then( function( text ) { | ||
expect( text ).to.eq( this.secondRowText ); | ||
} ); | ||
|
||
// Verifies if 2nd row has title `Page 1`. | ||
cy.get( secondRow ).find( '.row-title' ).invoke( 'text' ).then( function( text ) { | ||
expect( text ).to.eq( this.firstRowText ); | ||
} ); | ||
|
||
// Now reset the page order and verify original values are back. | ||
cy.get( '#contextual-help-link' ).click(); | ||
cy.get( '#tab-link-simple_page_ordering_help_tab' ).click(); | ||
cy.get( '#simple-page-ordering-reset' ).click(); | ||
cy.on( 'window:confirm', () => true ); | ||
|
||
// Perform a reload as Cypress won't after window:confirm. | ||
cy.reload(); | ||
|
||
// Verifies if 1st row has title `Page 1`. | ||
cy.get( firstRow ).find( '.row-title' ).invoke( 'text' ).then( function( text ) { | ||
expect( text ).to.eq( this.firstRowText ); | ||
} ); | ||
|
||
// Verifies if 2nd row has title `Page 2`. | ||
cy.get( secondRow ).find( '.row-title' ).invoke( 'text' ).then( function( text ) { | ||
expect( text ).to.eq( this.secondRowText ); | ||
} ); | ||
} ); | ||
} ); |