-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E2E Test Utils: Handle both plaintext and HTML errors
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { hasPageError } from '../has-page-error'; | ||
|
||
describe( 'hasPageError', () => { | ||
let originalPage; | ||
|
||
beforeEach( () => { | ||
originalPage = global.page; | ||
} ); | ||
|
||
afterEach( () => { | ||
global.page = originalPage; | ||
} ); | ||
|
||
it( 'returns false if there is no error', async () => { | ||
global.page = { | ||
content: () => 'Happy!', | ||
}; | ||
|
||
expect( await hasPageError() ).toBe( false ); | ||
} ); | ||
|
||
it.each( [ | ||
[ | ||
'PHP, HTML', | ||
'<b>Notice</b>: Undefined property: WP_Block_Type_Registry::$x in <b>/var/www/html/wp-content/plugins/gutenberg/lib/blocks.php</b> on line <b>47</b><br />', | ||
], | ||
[ | ||
'PHP, Plaintext', | ||
'Notice: Undefined property: WP_Block_Type_Registry::$x in /var/www/html/wp-content/plugins/gutenberg/lib/blocks.php on line 47', | ||
], | ||
] )( | ||
'returns true if there is an error (%s)', | ||
async ( _variant, error ) => { | ||
global.page = { | ||
content: () => error, | ||
}; | ||
|
||
expect( await hasPageError() ).toBe( true ); | ||
} | ||
); | ||
} ); |