This repository was archived by the owner on Aug 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Automation/playwright #257
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
9c5ced5
Add transcoder Test cases
alvitazwar f80abca
Addressed Feedback
alvitazwar 9874d9b
Fix: Addressed Feedback and added missing scenarios
alvitazwar a7fd4fc
Check GH action
alvitazwar 855e456
Update main.sh
pooja-muchandikar b0b244a
Update main.sh
pooja-muchandikar bdadf7d
Update main.sh
pooja-muchandikar 8c0788f
Update main.sh
pooja-muchandikar abad204
Addressed Feedback with new test case
alvitazwar fc4f454
Update main.sh
pavanpatil1 68cf1ca
Update main.sh
pavanpatil1 4e36ee8
Update main.sh
pavanpatil1 9d4f71b
Update main.sh
pavanpatil1 6e28104
Update main.sh
pavanpatil1 fb1c713
Test GH Action
alvitazwar 0997cbd
update site name
752583e
Update main.sh
pavanpatil1 64779b4
Complete Feedback without GH
alvitazwar 9ea9f3c
Test GH Action
alvitazwar 99961bd
Test GH Action
alvitazwar 4d1dab4
Test GH Action
alvitazwar 5a97950
Test GH Action
alvitazwar 95f6165
Test GH Action
alvitazwar 1f38bdb
Test GH Action
alvitazwar 6d29f88
Test GH Action
alvitazwar 94e205e
Test GH Action
alvitazwar 5d77403
Test GH Action
alvitazwar 931f75f
Test GH Action
alvitazwar a65e831
Test GH Action
alvitazwar 444329f
Test GH Action
alvitazwar acccf76
Test GH Action
alvitazwar eb71c5e
Check Direct URL action
alvitazwar 21e03a1
Check Direct URL action
alvitazwar 6fa45c4
Check Direct URL action
alvitazwar 19f6dd5
Check Direct URL action
alvitazwar 894a8b8
Check E2E Test cases
alvitazwar ef9ffad
Check Tesult Integration
alvitazwar 76f68e2
Check Tesult Integration
alvitazwar bce0ffb
Check Tesult Test Cases
alvitazwar 4dca143
Implement cleaning after test execution
alvitazwar 0b7f43d
Implement cleaning after test execution
alvitazwar 67b518a
Implement cleaning after test execution
alvitazwar eae0f17
Implement cleaning after test execution
alvitazwar 4a21033
Implement cleaning after test execution
alvitazwar f984d3a
Merge pull request #256 from rtCamp/action/directUrl
alvitazwar 83acd86
Tesult Implementation
alvitazwar c662c68
Tesult Implementation
alvitazwar 84de83b
Tesult Implementation
alvitazwar 8bf17ca
Address final Feedback
alvitazwar 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 hidden or 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,76 @@ | ||
| # e2e test for transcoder | ||
|
|
||
| name: CI for Transcoder | ||
|
|
||
| # Controls when the workflow will run | ||
| on: | ||
| # Triggers the workflow on push or pull request events but only for the main branch | ||
| push: | ||
| branches: | ||
| - master | ||
| - develop | ||
|
|
||
| pull_request: | ||
| branches: | ||
| - master | ||
alvitazwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - develop | ||
|
|
||
| # Allows you to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
| jobs: | ||
| Run-wpe2e-TestCase: | ||
| # The type of runner that the job will run on | ||
| name: Run Transcoder Jobs | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| SHA: ${{ github.event.pull_request.head.sha }} | ||
| COMMIT_SHA: ${{ github.sha }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| working-directory: ./tests/e2e-playwright | ||
| TESRESULT_TOKEN: ${{ secrets.TESRESULT_TOKEN }} | ||
| TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
|
|
||
| # Steps represent a sequence of tasks that will be executed as part of the job | ||
| steps: | ||
|
|
||
| - uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 17 | ||
| cache: "npm" | ||
| cache-dependency-path: tests/e2e-playwright/package-lock.json | ||
|
|
||
| - name: Install npm dependencies | ||
| run: npm install | ||
| working-directory: ${{env.working-directory}} | ||
|
|
||
| - name: Build Playwright utils dependencies | ||
| run: npm run build | ||
| working-directory: ${{env.working-directory}} | ||
|
|
||
| - name: Install browser | ||
| run: npx playwright install chromium | ||
| working-directory: ${{env.working-directory}} | ||
|
|
||
| - name: Run End to End tests | ||
| run: npm run test-e2e:playwright -- test | ||
| working-directory: ${{env.working-directory}} | ||
|
|
||
| - name: run PR status | ||
| if: ${{ always() }} | ||
| run: node ./tests/e2e-playwright/bin/pr-status.js | ||
| working-directory: ${{env.working_directory}} | ||
|
|
||
| - name: Make reports available | ||
| uses: actions/upload-artifact@v2 | ||
| if: success() || failure() | ||
| with: | ||
| name: playwright-report | ||
| retention-days: 2 | ||
| path: | | ||
| ${{ github.workspace }}/playwright-report | ||
This file contains hidden or 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,30 @@ | ||
| # wp-e2e | ||
| This is a generic automation test suit using WP Gutenberg Playwright Utils | ||
| Used Framewrok | ||
| 1. Playwright https://playwright.dev/ | ||
| 2. WordPress E2E Playwright Utils https://github.com/WordPress/gutenberg/tree/trunk/packages/e2e-test-utils-playwright | ||
|
|
||
| ## Install | ||
| `npm install` | ||
|
|
||
| `npm run build` | ||
|
|
||
|
|
||
|
|
||
| ## Run all available tests. | ||
| `npm run test-e2e:playwright` | ||
|
|
||
| ## Run in headed mode.` | ||
| `npm run test-e2e:playwright -- --headed` | ||
|
|
||
| ## Run a single test file. | ||
| `npm run test-e2e:playwright -- <path_to_test_file> # E.g., npm run test-e2e:playwright -- add-new-post.spec.js` | ||
|
|
||
| ## Debugging | ||
| `npm run test-e2e:playwright -- --debug` | ||
|
|
||
| ## Migration | ||
| We can migrate wp-e2e generic test cases from [here](https://github.com/rtCamp/wp-e2e/tree/master/specs) using the steps mentioned in [this](https://github.com/WordPress/gutenberg/pull/38570) | ||
|
|
||
|
|
||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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,199 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| const { promisify } = require( 'util' ); | ||
| const fs = require( 'fs' ); | ||
| const path = require( 'path' ); | ||
| const babel = require( '@babel/core' ); | ||
| const makeDir = require( 'make-dir' ); | ||
| const sass = require( 'sass' ); | ||
| const postcss = require( 'postcss' ); | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| const getBabelConfig = require( './get-babel-config' ); | ||
|
|
||
| /** | ||
| * Path to packages directory. | ||
| * | ||
| * @type {string} | ||
| */ | ||
| const PACKAGES_DIR = path | ||
| .resolve( __dirname, '../../packages' ) | ||
| .replace( /\\/g, '/' ); | ||
|
|
||
| /** | ||
| * Mapping of JavaScript environments to corresponding build output. | ||
| * | ||
| * @type {Object} | ||
| */ | ||
| const JS_ENVIRONMENTS = { | ||
| main: 'build', | ||
| module: 'build-module', | ||
| }; | ||
|
|
||
| /** | ||
| * Promisified fs.readFile. | ||
| * | ||
| * @type {Function} | ||
| */ | ||
| const readFile = promisify( fs.readFile ); | ||
|
|
||
| /** | ||
| * Promisified fs.writeFile. | ||
| * | ||
| * @type {Function} | ||
| */ | ||
| const writeFile = promisify( fs.writeFile ); | ||
|
|
||
| /** | ||
| * Promisified sass.render. | ||
| * | ||
| * @type {Function} | ||
| */ | ||
| const renderSass = promisify( sass.render ); | ||
|
|
||
| /** | ||
| * Get the package name for a specified file | ||
| * | ||
| * @param {string} file File name. | ||
| * | ||
| * @return {string} Package name. | ||
| */ | ||
| function getPackageName( file ) { | ||
| return path.relative( PACKAGES_DIR, file ).split( path.sep )[ 0 ]; | ||
| } | ||
|
|
||
| /** | ||
| * Get Build Path for a specified file. | ||
| * | ||
| * @param {string} file File to build. | ||
| * @param {string} buildFolder Output folder. | ||
| * | ||
| * @return {string} Build path. | ||
| */ | ||
| function getBuildPath( file, buildFolder ) { | ||
| const pkgName = getPackageName( file ); | ||
| const pkgSrcPath = path.resolve( PACKAGES_DIR, pkgName, 'src' ); | ||
| const pkgBuildPath = path.resolve( PACKAGES_DIR, pkgName, buildFolder ); | ||
| const relativeToSrcPath = path.relative( pkgSrcPath, file ); | ||
| return path.resolve( pkgBuildPath, relativeToSrcPath ); | ||
| } | ||
|
|
||
| async function buildCSS( file ) { | ||
| const outputFile = getBuildPath( | ||
| file.replace( '.scss', '.css' ), | ||
| 'build-style' | ||
| ); | ||
| const outputFileRTL = getBuildPath( | ||
| file.replace( '.scss', '-rtl.css' ), | ||
| 'build-style' | ||
| ); | ||
|
|
||
| const [ , contents ] = await Promise.all( [ | ||
| makeDir( path.dirname( outputFile ) ), | ||
| readFile( file, 'utf8' ), | ||
| ] ); | ||
|
|
||
| const importLists = [ | ||
| 'colors', | ||
| 'breakpoints', | ||
| 'variables', | ||
| 'mixins', | ||
| 'animations', | ||
| 'z-index', | ||
| ] | ||
| // Editor styles should be excluded from the default CSS vars output. | ||
| .concat( | ||
| file.includes( 'common.scss' ) || ! file.includes( 'block-library' ) | ||
| ? [ 'default-custom-properties' ] | ||
| : [] | ||
| ) | ||
| .map( ( imported ) => `@import "${ imported }";` ) | ||
| .join( ' ' ); | ||
|
|
||
| const builtSass = await renderSass( { | ||
| file, | ||
| includePaths: [ path.join( PACKAGES_DIR, 'base-styles' ) ], | ||
| data: ''.concat( '@use "sass:math";', importLists, contents ), | ||
| } ); | ||
|
|
||
| const result = await postcss( | ||
| require( '@wordpress/postcss-plugins-preset' ) | ||
| ).process( builtSass.css, { | ||
| from: 'src/app.css', | ||
| to: 'dest/app.css', | ||
| } ); | ||
|
|
||
| const resultRTL = await postcss( [ require( 'rtlcss' )() ] ).process( | ||
| result.css, | ||
| { | ||
| from: 'src/app.css', | ||
| to: 'dest/app.css', | ||
| } | ||
| ); | ||
|
|
||
| await Promise.all( [ | ||
| writeFile( outputFile, result.css ), | ||
| writeFile( outputFileRTL, resultRTL.css ), | ||
| ] ); | ||
| } | ||
|
|
||
| async function buildJS( file ) { | ||
| for ( const [ environment, buildDir ] of Object.entries( | ||
| JS_ENVIRONMENTS | ||
| ) ) { | ||
| const destPath = getBuildPath( | ||
| file.replace( /\.tsx?$/, '.js' ), | ||
| buildDir | ||
| ); | ||
| const babelOptions = getBabelConfig( | ||
| environment, | ||
| file.replace( PACKAGES_DIR, '@wordpress' ) | ||
| ); | ||
|
|
||
| const [ , transformed ] = await Promise.all( [ | ||
| makeDir( path.dirname( destPath ) ), | ||
| babel.transformFileAsync( file, babelOptions ), | ||
| ] ); | ||
|
|
||
| await Promise.all( [ | ||
| writeFile( destPath + '.map', JSON.stringify( transformed.map ) ), | ||
| writeFile( | ||
| destPath, | ||
| transformed.code + | ||
| '\n//# sourceMappingURL=' + | ||
| path.basename( destPath ) + | ||
| '.map' | ||
| ), | ||
| ] ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Object of build tasks per file extension. | ||
| * | ||
| * @type {Object<string,Function>} | ||
| */ | ||
| const BUILD_TASK_BY_EXTENSION = { | ||
| '.scss': buildCSS, | ||
| '.js': buildJS, | ||
| '.ts': buildJS, | ||
| '.tsx': buildJS, | ||
| }; | ||
|
|
||
| module.exports = async ( file, callback ) => { | ||
| const extension = path.extname( file ); | ||
| const task = BUILD_TASK_BY_EXTENSION[ extension ]; | ||
|
|
||
| if ( ! task ) { | ||
| callback( new Error( `No handler for extension: ${ extension }` ) ); | ||
| } | ||
|
|
||
| try { | ||
| await task( file ); | ||
| callback(); | ||
| } catch ( error ) { | ||
| callback( error ); | ||
| } | ||
| }; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.