forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Move block fixtures to e2e-tests package (WordPress#13658)
- Loading branch information
1 parent
5dc9ac4
commit c583ea2
Showing
281 changed files
with
200 additions
and
98 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
export { | ||
blockNameToFixtureBasename, | ||
getAvailableBlockFixturesBasenames, | ||
getBlockFixtureHTML, | ||
getBlockFixtureJSON, | ||
getBlockFixtureParsedJSON, | ||
getBlockFixtureSerializedHTML, | ||
writeBlockFixtureHTML, | ||
writeBlockFixtureJSON, | ||
writeBlockFixtureParsedJSON, | ||
writeBlockFixtureSerializedHTML, | ||
} from './utils'; |
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,92 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { uniq } from 'lodash'; | ||
|
||
const FIXTURES_DIR = path.join( __dirname, 'blocks' ); | ||
|
||
function readFixtureFile( fixturesDir, filename ) { | ||
try { | ||
return fs.readFileSync( | ||
path.join( fixturesDir, filename ), | ||
'utf8' | ||
); | ||
} catch ( err ) { | ||
return null; | ||
} | ||
} | ||
|
||
function writeFixtureFile( fixturesDir, filename, content ) { | ||
fs.writeFileSync( | ||
path.join( fixturesDir, filename ), | ||
content | ||
); | ||
} | ||
|
||
export function blockNameToFixtureBasename( blockName ) { | ||
return blockName.replace( /\//g, '__' ); | ||
} | ||
|
||
export function getAvailableBlockFixturesBasenames() { | ||
// We expect 4 different types of files for each fixture: | ||
// - fixture.html : original content | ||
// - fixture.parsed.json : parser output | ||
// - fixture.json : blocks structure | ||
// - fixture.serialized.html : re-serialized content | ||
// Get the "base" name for each fixture first. | ||
return uniq( | ||
fs.readdirSync( FIXTURES_DIR ) | ||
.filter( ( f ) => /(\.html|\.json)$/.test( f ) ) | ||
.map( ( f ) => f.replace( /\..+$/, '' ) ) | ||
); | ||
} | ||
|
||
export function getBlockFixtureHTML( basename ) { | ||
const filename = `${ basename }.html`; | ||
return { | ||
filename, | ||
file: readFixtureFile( FIXTURES_DIR, filename ), | ||
}; | ||
} | ||
|
||
export function getBlockFixtureJSON( basename ) { | ||
const filename = `${ basename }.json`; | ||
return { | ||
filename, | ||
file: readFixtureFile( FIXTURES_DIR, filename ), | ||
}; | ||
} | ||
|
||
export function getBlockFixtureParsedJSON( basename ) { | ||
const filename = `${ basename }.parsed.json`; | ||
return { | ||
filename, | ||
file: readFixtureFile( FIXTURES_DIR, filename ), | ||
}; | ||
} | ||
|
||
export function getBlockFixtureSerializedHTML( basename ) { | ||
const filename = `${ basename }.serialized.html`; | ||
return { | ||
filename, | ||
file: readFixtureFile( FIXTURES_DIR, filename ), | ||
}; | ||
} | ||
|
||
export function writeBlockFixtureHTML( basename, fixture ) { | ||
writeFixtureFile( FIXTURES_DIR, `${ basename }.html`, fixture ); | ||
} | ||
|
||
export function writeBlockFixtureJSON( basename, fixture ) { | ||
writeFixtureFile( FIXTURES_DIR, `${ basename }.json`, fixture ); | ||
} | ||
|
||
export function writeBlockFixtureParsedJSON( basename, fixture ) { | ||
writeFixtureFile( FIXTURES_DIR, `${ basename }.parsed.json`, fixture ); | ||
} | ||
|
||
export function writeBlockFixtureSerializedHTML( basename, fixture ) { | ||
writeFixtureFile( FIXTURES_DIR, `${ basename }.serialized.html`, fixture ); | ||
} |
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