-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Playwright: use an interface for passing TestFile paths. #55693
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import path from 'path'; | ||
|
||
export const TEST_IMAGE_PATH = path.normalize( | ||
path.join( __dirname, '..', 'image-uploads', 'image0.jpg' ) | ||
); | ||
export const TEST_AUDIO_PATH = path.normalize( | ||
path.join( __dirname, '..', 'image-uploads', 'bees.mp3' ) | ||
); | ||
export const UNSUPPORTED_FILE_PATH = path.normalize( | ||
path.join( __dirname, '..', 'image-uploads', 'unsupported_extension.mkv' ) | ||
); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
* @group gutenberg | ||
*/ | ||
|
||
import path from 'path'; | ||
import { | ||
setupHooks, | ||
DataHelper, | ||
|
@@ -15,27 +14,29 @@ import { | |
HeroBlock, | ||
ClicktoTweetBlock, | ||
LogosBlock, | ||
TestFile, | ||
} from '@automattic/calypso-e2e'; | ||
import { Page } from 'playwright'; | ||
import { TEST_IMAGE_PATH } from '../constants'; | ||
|
||
describe( DataHelper.createSuiteTitle( 'Blocks: CoBlocks' ), () => { | ||
describe( DataHelper.createSuiteTitle( 'Blocks: CoBlocks' ), function () { | ||
let gutenbergEditorPage: GutenbergEditorPage; | ||
let pricingTableBlock: PricingTableBlock; | ||
let page: Page; | ||
let logoImage: string; | ||
let logoImage: TestFile; | ||
|
||
// Test data | ||
const pricingTableBlockPrice = 888; | ||
const heroBlockHeading = 'Hero heading'; | ||
const clicktoTweetBlockTweet = | ||
'The foolish man seeks happiness in the distance. The wise grows it under his feet. — James Oppenheim'; | ||
|
||
setupHooks( ( args ) => { | ||
setupHooks( ( args: { page: Page } ) => { | ||
page = args.page; | ||
} ); | ||
|
||
beforeAll( async () => { | ||
logoImage = await MediaHelper.createTestImage(); | ||
logoImage = await MediaHelper.createTestFile( TEST_IMAGE_PATH ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other methods for generating test files have been removed. Test writers are expected to pass the path of the source image file to the |
||
} ); | ||
|
||
it( 'Log in', async function () { | ||
|
@@ -78,7 +79,7 @@ describe( DataHelper.createSuiteTitle( 'Blocks: CoBlocks' ), () => { | |
it( `Insert ${ LogosBlock.blockName } block and set image`, async function () { | ||
const blockHandle = await gutenbergEditorPage.addBlock( LogosBlock.blockName ); | ||
const logosBlock = new LogosBlock( blockHandle ); | ||
await logosBlock.upload( logoImage ); | ||
await logosBlock.upload( logoImage.fullpath ); | ||
} ); | ||
|
||
it( 'Publish and visit post', async function () { | ||
|
@@ -104,6 +105,6 @@ describe( DataHelper.createSuiteTitle( 'Blocks: CoBlocks' ), () => { | |
); | ||
|
||
it( `Confirm Logos block is visible in published post`, async () => { | ||
await LogosBlock.validatePublishedContent( page, path.parse( logoImage ).name ); | ||
await LogosBlock.validatePublishedContent( page, [ logoImage.filename ] ); | ||
} ); | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,26 +9,29 @@ import { | |
MediaPage, | ||
SidebarComponent, | ||
setupHooks, | ||
TestFile, | ||
} from '@automattic/calypso-e2e'; | ||
import { Page } from 'playwright'; | ||
import { TEST_IMAGE_PATH } from '../constants'; | ||
|
||
describe( DataHelper.createSuiteTitle( 'Media: Edit Media' ), function () { | ||
let testImage; | ||
let page; | ||
let testImage: TestFile; | ||
let page: Page; | ||
|
||
setupHooks( ( args ) => { | ||
page = args.page; | ||
} ); | ||
|
||
beforeAll( async () => { | ||
testImage = await MediaHelper.createTestImage(); | ||
testImage = await MediaHelper.createTestFile( TEST_IMAGE_PATH ); | ||
} ); | ||
|
||
describe.each` | ||
siteType | user | ||
${ 'Simple' } | ${ 'defaultUser' } | ||
${ 'Atomic' } | ${ 'wooCommerceUser' } | ||
`( 'Edit Image ($siteType)', function ( { user } ) { | ||
let mediaPage; | ||
let mediaPage: MediaPage; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file has been changed to TypeScript. |
||
|
||
it( 'Log In', async function () { | ||
const loginFlow = new LoginFlow( page, user ); | ||
|
@@ -51,7 +54,7 @@ describe( DataHelper.createSuiteTitle( 'Media: Edit Media' ), function () { | |
it( 'Upload image', async function () { | ||
// Ideally, we'd not want to upload an image (that's a separate test) | ||
// but occasionally, the photo gallery is cleaned out leaving no images. | ||
const uploadedImageHandle = await mediaPage.upload( testImage ); | ||
const uploadedImageHandle = await mediaPage.upload( testImage.fullpath ); | ||
const isVisible = await uploadedImageHandle.isVisible(); | ||
expect( isVisible ).toBe( true ); | ||
} ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file defines the paths where the test files are located.
Test writers should import the appropriate
const
and pass it into thecreateTestFile
method.