Skip to content

Commit

Permalink
Edit Post: Reverse order of AdminNotice upgraded notices
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Nov 16, 2018
1 parent eba59c0 commit c308c3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/edit-post/src/components/admin-notices/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const NOTICE_CLASS_STATUSES = {
* @return {Element[]} Admin notice elements.
*/
function getAdminNotices() {
return [ ...document.querySelectorAll( '.notice' ) ];
// The order is reversed to match expectations of rendered order, since a
// NoticesList is itself rendered in reverse order (newest to oldest).
return [ ...document.querySelectorAll( '.notice' ) ].reverse();
}

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/edit-post/src/components/admin-notices/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ describe( 'AdminNotices', () => {
expect( createNotice ).toHaveBeenCalledTimes( 2 );
expect( createNotice.mock.calls[ 0 ] ).toEqual( [
{
status: 'success',
status: 'warning',
content: '',
__unstableHTML: '<p>My <strong>notice</strong> text</p><p>My second line of text</p>',
isDismissible: true,
__unstableHTML: 'Warning',
isDismissible: false,
},
{ speak: false },
] );
expect( createNotice.mock.calls[ 1 ] ).toEqual( [
{
status: 'warning',
status: 'success',
content: '',
__unstableHTML: 'Warning',
isDismissible: false,
__unstableHTML: '<p>My <strong>notice</strong> text</p><p>My second line of text</p>',
isDismissible: true,
},
{ speak: false },
] );
Expand Down

0 comments on commit c308c3e

Please sign in to comment.