-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
375 additions
and
24 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
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,5 @@ | ||
export const UNSPLASH_LIBRARY_BUTTON = '#menu-item-unsplash'; | ||
export const UNSPLASH_LIBRARY_SEARCH_INPUT = '#unsplash-search-input'; | ||
export const UNSPLASH_CONTRAINER = '.unsplash-browser .attachments'; | ||
export const UNSPLASH_MODAL = '.media-modal'; | ||
export const UNSPLASH_NO_RESULTS = '.unsplash-browser .no-media'; |
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 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { visitAdminPage } from '@wordpress/e2e-test-utils'; | ||
import { clickSelector } from '../../utils'; | ||
|
||
const inputSelector = '#unsplash_access_key'; | ||
const btnSelect = '#submit.button-primary'; | ||
|
||
describe( 'Settings', () => { | ||
beforeEach( async () => { | ||
await visitAdminPage( 'options-general.php', 'page=unsplash' ); | ||
await page.evaluate( selector => { | ||
document.querySelector( selector ).value = ''; | ||
}, inputSelector ); | ||
await clickSelector( btnSelect ); | ||
await page.waitForNavigation(); | ||
} ); | ||
|
||
afterEach( async () => { | ||
await visitAdminPage( 'options-general.php', 'page=unsplash' ); | ||
await page.evaluate( selector => { | ||
document.querySelector( selector ).value = ''; | ||
}, inputSelector ); | ||
await clickSelector( btnSelect ); | ||
await page.waitForNavigation(); | ||
} ); | ||
|
||
it( 'page input exist', async () => { | ||
// Wait input tab. | ||
await expect( page ).toMatchElement( inputSelector ); | ||
} ); | ||
|
||
it( 'Valid key the input exist', async () => { | ||
await page.focus( inputSelector ); | ||
await page.keyboard.type( 'valid-key' ); | ||
await clickSelector( btnSelect ); | ||
await page.waitForNavigation(); | ||
|
||
const NO_RESULTS = '.notice-error.notice-unsplash'; | ||
await page.waitForSelector( NO_RESULTS ); | ||
await expect( page ).toMatchElement( NO_RESULTS ); | ||
} ); | ||
} ); |
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,56 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { visitAdminPage } from '@wordpress/e2e-test-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { activatePlugin, clickSelector, deactivatePlugin } from '../../utils'; | ||
import { | ||
UNSPLASH_CONTRAINER, | ||
UNSPLASH_LIBRARY_BUTTON, | ||
UNSPLASH_MODAL, | ||
} from '../../constants'; | ||
|
||
const MEDIA_LIBRARY_BUTTON = '#set-post-thumbnail'; | ||
|
||
describe( 'Classic editor', () => { | ||
beforeAll( async () => { | ||
await activatePlugin( 'classic-editor' ); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await deactivatePlugin( 'classic-editor' ); | ||
} ); | ||
|
||
beforeEach( async () => { | ||
await visitAdminPage( 'post-new.php', {} ); | ||
await page.waitForSelector( MEDIA_LIBRARY_BUTTON ); | ||
await page.click( MEDIA_LIBRARY_BUTTON ); | ||
await page.waitForSelector( UNSPLASH_MODAL, { | ||
visible: true, | ||
} ); | ||
await page.waitForSelector( UNSPLASH_LIBRARY_BUTTON ); | ||
} ); | ||
|
||
it( 'should the tab exist', async () => { | ||
// Click the media library button and wait for tab. | ||
await expect( page ).toMatchElement( UNSPLASH_LIBRARY_BUTTON ); | ||
} ); | ||
|
||
it( 'select image', async () => { | ||
await page.waitForSelector( UNSPLASH_CONTRAINER ); | ||
const btnSelector = | ||
UNSPLASH_CONTRAINER + ' .unsplash-attachment:first-of-type'; | ||
await clickSelector( btnSelector ); | ||
const btnSelect = '.media-button-select'; | ||
await clickSelector( btnSelect ); | ||
await page.waitForSelector( UNSPLASH_MODAL, { | ||
visible: false, | ||
} ); | ||
const blockClass = '.size-post-thumbnail'; | ||
await page.waitForSelector( blockClass ); | ||
await expect( page ).toMatchElement( blockClass ); | ||
} ); | ||
} ); |
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,33 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createNewPost, insertBlock } from '@wordpress/e2e-test-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { clickButton, deactivatePlugin } from '../../utils'; | ||
import { UNSPLASH_LIBRARY_BUTTON, UNSPLASH_MODAL } from '../../constants'; | ||
|
||
describe( 'Cover Block', () => { | ||
beforeAll( async () => { | ||
await deactivatePlugin( 'classic-editor' ); | ||
} ); | ||
|
||
beforeEach( async () => { | ||
await createNewPost( {} ); | ||
} ); | ||
|
||
it( 'should the tab exist', async () => { | ||
// Insert cover block. | ||
await insertBlock( 'Cover' ); | ||
|
||
// Click the media library button and wait for tab. | ||
await clickButton( 'Media Library' ); | ||
await page.waitForSelector( UNSPLASH_MODAL, { | ||
visible: true, | ||
} ); | ||
await page.waitForSelector( UNSPLASH_LIBRARY_BUTTON ); | ||
await expect( page ).toMatchElement( UNSPLASH_LIBRARY_BUTTON ); | ||
} ); | ||
} ); |
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,51 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createNewPost } from '@wordpress/e2e-test-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { clickButton, deactivatePlugin, clickSelector } from '../../utils'; | ||
import { | ||
UNSPLASH_CONTRAINER, | ||
UNSPLASH_LIBRARY_BUTTON, | ||
UNSPLASH_MODAL, | ||
} from '../../constants'; | ||
/** | ||
* Tests the notices for the featured image. | ||
*/ | ||
describe( 'Featured Image', () => { | ||
beforeAll( async () => { | ||
await deactivatePlugin( 'classic-editor' ); | ||
} ); | ||
|
||
beforeEach( async () => { | ||
await createNewPost(); | ||
await clickButton( 'Document' ); | ||
await clickButton( 'Featured image' ); | ||
await clickButton( 'Set featured image' ); | ||
await page.waitForSelector( UNSPLASH_MODAL, { | ||
visible: true, | ||
} ); | ||
} ); | ||
|
||
it( 'select image', async () => { | ||
await page.waitForSelector( UNSPLASH_LIBRARY_BUTTON ); | ||
await clickSelector( UNSPLASH_LIBRARY_BUTTON ); | ||
await page.waitForSelector( UNSPLASH_CONTRAINER, { | ||
visible: true, | ||
} ); | ||
const btnSelector = | ||
UNSPLASH_CONTRAINER + ' .unsplash-attachment:first-of-type'; | ||
await clickSelector( btnSelector ); | ||
const btnSelect = '.media-button-select'; | ||
await clickSelector( btnSelect ); | ||
await page.waitForSelector( UNSPLASH_MODAL, { | ||
visible: false, | ||
} ); | ||
const blockClass = '.editor-post-featured-image__preview'; | ||
await page.waitForSelector( blockClass ); | ||
await expect( page ).toMatchElement( blockClass ); | ||
} ); | ||
} ); |
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,33 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createNewPost, insertBlock } from '@wordpress/e2e-test-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { clickButton, deactivatePlugin } from '../../utils'; | ||
import { UNSPLASH_LIBRARY_BUTTON, UNSPLASH_MODAL } from '../../constants'; | ||
|
||
describe( 'Image Block', () => { | ||
beforeAll( async () => { | ||
await deactivatePlugin( 'classic-editor' ); | ||
} ); | ||
|
||
beforeEach( async () => { | ||
await createNewPost( {} ); | ||
|
||
// Insert image block. | ||
await insertBlock( 'Gallery' ); | ||
|
||
// Click the media library button and wait for tab. | ||
await clickButton( 'Media Library' ); | ||
await page.waitForSelector( UNSPLASH_MODAL, { | ||
visible: true, | ||
} ); | ||
} ); | ||
|
||
it( 'should the tab not exist', async () => { | ||
await expect( page ).not.toMatchElement( UNSPLASH_LIBRARY_BUTTON ); | ||
} ); | ||
} ); |
Oops, something went wrong.