From c308c3ed3677e67d02fd50df63fb5831a4c566fb Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 16 Nov 2018 13:24:23 -0500 Subject: [PATCH] Edit Post: Reverse order of AdminNotice upgraded notices --- .../edit-post/src/components/admin-notices/index.js | 4 +++- .../src/components/admin-notices/test/index.js | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/edit-post/src/components/admin-notices/index.js b/packages/edit-post/src/components/admin-notices/index.js index c55523bfa2b3be..54da011461de4a 100644 --- a/packages/edit-post/src/components/admin-notices/index.js +++ b/packages/edit-post/src/components/admin-notices/index.js @@ -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(); } /** diff --git a/packages/edit-post/src/components/admin-notices/test/index.js b/packages/edit-post/src/components/admin-notices/test/index.js index a1cdbe9d95f635..e5a09ca2bcb4d9 100644 --- a/packages/edit-post/src/components/admin-notices/test/index.js +++ b/packages/edit-post/src/components/admin-notices/test/index.js @@ -33,19 +33,19 @@ describe( 'AdminNotices', () => { expect( createNotice ).toHaveBeenCalledTimes( 2 ); expect( createNotice.mock.calls[ 0 ] ).toEqual( [ { - status: 'success', + status: 'warning', content: '', - __unstableHTML: '

My notice text

My second line of text

', - isDismissible: true, + __unstableHTML: 'Warning', + isDismissible: false, }, { speak: false }, ] ); expect( createNotice.mock.calls[ 1 ] ).toEqual( [ { - status: 'warning', + status: 'success', content: '', - __unstableHTML: 'Warning', - isDismissible: false, + __unstableHTML: '

My notice text

My second line of text

', + isDismissible: true, }, { speak: false }, ] );