-
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
ci(e2e): Refactor Media helper to better handle concurrency #55678
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3296c1f
Bump fs-extra
scinos 0adb97f
Debug media
scinos 7015a9c
Drop fs-extra
scinos 1f48bef
Try copying it manually
scinos 9ea22cf
Use try/catch
scinos 9321a33
toString
scinos d5715b4
Try to be concurrency friendly
scinos f37def3
Use e2e prefix
scinos 5605808
Fix typo
scinos 8c7a501
Drop deleteFile
scinos 0846d89
Drop unused dep
scinos 6096286
Fix test code
scinos e19490b
Do not overwrite docker params
scinos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -15,20 +15,23 @@ import { Page } from 'playwright'; | |
describe( DataHelper.createSuiteTitle( 'Blocks: Media (Upload)' ), () => { | ||
let gutenbergEditorPage: GutenbergEditorPage; | ||
let page: Page; | ||
|
||
const testFiles = { | ||
image: MediaHelper.createTestImage(), | ||
image_reserved_name: MediaHelper.createTestFile( { | ||
sourceFileName: 'image0.jpg', | ||
testFileName: 'filewith#?#?reservedurlchars', | ||
} ), | ||
audio: MediaHelper.createTestAudio(), | ||
}; | ||
let testFiles: { image: string; image_reserved_name: string; audio: string }; | ||
|
||
setupHooks( ( args ) => { | ||
page = args.page; | ||
} ); | ||
|
||
beforeAll( async () => { | ||
testFiles = { | ||
image: await MediaHelper.createTestImage(), | ||
image_reserved_name: await MediaHelper.createTestFile( { | ||
sourceFileName: 'image0.jpg', | ||
testFileName: 'filewith#?#?reservedurlchars', | ||
} ), | ||
audio: await MediaHelper.createTestAudio(), | ||
}; | ||
} ); | ||
|
||
it( 'Log in', async function () { | ||
const loginFlow = new LoginFlow( page, 'gutenbergSimpleSiteUser' ); | ||
await loginFlow.logIn(); | ||
|
@@ -72,20 +75,22 @@ describe( DataHelper.createSuiteTitle( 'Blocks: Media (Upload)' ), () => { | |
await gutenbergEditorPage.publish( { visit: true } ); | ||
} ); | ||
|
||
// Pass in a 1D array of values or text strings to validate each block. | ||
// The full filename (name.extension) is not used within the Image block, but the file name is. | ||
// `path.parse` is called to trim the extension. | ||
it.each` | ||
block | content | ||
${ ImageBlock } | ${ [ path.parse( testFiles.image ).name ] } | ||
${ ImageBlock } | ${ [ path.parse( testFiles.image_reserved_name ).name.replace( /[^a-zA-Z ]/g, '' ) ] } | ||
${ AudioBlock } | ${ [ path.parse( testFiles.audio ).base ] } | ||
${ FileBlock } | ${ [ path.parse( testFiles.audio ).name ] } | ||
`( | ||
`Confirm $block.blockName block is visible in published post`, | ||
async ( { block, content } ) => { | ||
// Pass the Block object class here then call the static method to validate. | ||
await block.validatePublishedContent( page, content ); | ||
} | ||
); | ||
it( `Confirm Image block is visible in published post`, async () => { | ||
await ImageBlock.validatePublishedContent( page, path.parse( testFiles.image ).name ); | ||
} ); | ||
|
||
it( `Confirm Image block is visible in published post (reserved name)`, async () => { | ||
await ImageBlock.validatePublishedContent( | ||
page, | ||
path.parse( testFiles.image_reserved_name ).name.replace( /[^a-zA-Z ]/g, '' ) | ||
); | ||
} ); | ||
|
||
it( `Confirm Audio block is visible in published post`, async () => { | ||
await AudioBlock.validatePublishedContent( page ); | ||
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.
|
||
} ); | ||
|
||
it( `Confirm File block is visible in published post`, async () => { | ||
await FileBlock.validatePublishedContent( page, path.parse( testFiles.audio ).name ); | ||
} ); | ||
} ); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is outside the scope of this PR, but we should really refactor this out. A package shouldn't need to have knowledge of the directory structure of the project using said package. Instead, this path should come as part of
sourceFileName
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.
With the EPERM issues resolved, another solution (that was originally intended) could be to have an
image-source
directory in this package which holds the test files.How does that sound?