-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from fingerprintjs/test/INTER-568-mock-app-tests
test: add mock e2e tests
- Loading branch information
Showing
6 changed files
with
216 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Test e2e for PR | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check-changed-files: | ||
runs-on: ubuntu-20.04 | ||
name: Check changed files | ||
outputs: | ||
CANT_PASS_WITHOUT_TESTS: ${{ steps.decision.outputs.CANT_PASS_WITHOUT_TESTS }} | ||
steps: | ||
- id: files | ||
uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 | ||
- name: Make decision based on changed files | ||
id: decision | ||
run: | | ||
cantPassWithoutTests=false | ||
for changed_file in ${{ steps.files.outputs.all }}; do | ||
if [[ ${changed_file} =~ ^(assets|generators)\/.+$ ]]; then | ||
cantPassWithoutTests=true | ||
fi | ||
if [[ ${changed_file} =~ ^build\.ts$ ]]; then | ||
cantPassWithoutTests=true | ||
fi | ||
if [[ ${changed_file} =~ scripts\/mockTests\.ts$ ]]; then | ||
cantPassWithoutTests=true | ||
fi | ||
if [[ ${changed_file} =~ .*ci\.yml$ ]]; then | ||
cantPassWithoutTests=true | ||
fi | ||
done | ||
echo $cantPassWithoutTests | ||
echo CANT_PASS_WITHOUT_TESTS=${cantPassWithoutTests} >> $GITHUB_OUTPUT | ||
build-and-test-e2e-mock: | ||
runs-on: ubuntu-20.04 | ||
name: Test e2e for PR using mock app | ||
needs: check-changed-files | ||
if: needs['check-changed-files'].outputs.CANT_PASS_WITHOUT_TESTS == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: 'Install pnpm' | ||
uses: pnpm/action-setup@129abb77bf5884e578fcaf1f37628e41622cc371 | ||
with: | ||
version: 8 | ||
- name: Install node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.node-version' | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Install Playwright | ||
run: pnpm exec playwright install | ||
- name: Extract Branch Name | ||
id: extract-branch | ||
run: | | ||
echo SUBDOMAIN=mock-$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | perl -pe 's/[^a-zA-Z0-9]+/-/g and s/-+$//g' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT | ||
- name: Run test | ||
run: pnpm test:mock-e2e | ||
env: | ||
TEST_DOMAIN: 'https://${{steps.extract-branch.outputs.SUBDOMAIN}}.${{secrets.FPJS_CI_DOMAIN}}' | ||
INTEGRATION_PATH: ${{secrets.INTEGRATION_PATH}} | ||
RESULT_PATH: ${{secrets.RESULT_PATH}} | ||
AGENT_PATH: ${{secrets.AGENT_PATH}} | ||
API_URL: ${{secrets.MOCK_FPCDN}} |
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,42 @@ | ||
import { execSync } from 'child_process' | ||
import pkg from '../package.json' | ||
|
||
function getEnv(name: string) { | ||
const value = process.env[name] | ||
if (!value) { | ||
throw new Error(`${name} is not set`) | ||
} | ||
return value | ||
} | ||
|
||
async function main() { | ||
const apiUrl = getEnv('API_URL') | ||
const agentPath = `${getEnv('INTEGRATION_PATH')}/${getEnv('AGENT_PATH')}` | ||
const resultPath = `${getEnv('INTEGRATION_PATH')}/${getEnv('RESULT_PATH')}` | ||
const host = getEnv('TEST_DOMAIN') | ||
|
||
const agentUrl = new URL(host) | ||
agentUrl.pathname = agentPath | ||
|
||
const resultUrl = new URL(host) | ||
resultUrl.pathname = resultPath | ||
|
||
console.info('Agent download path:', agentPath) | ||
console.info('Get result path:', resultPath) | ||
|
||
console.info(`Running mock e2e tests for`, host) | ||
|
||
execSync( | ||
`npm exec -y "git+https://github.com/fingerprintjs/dx-team-mock-for-proxy-integrations-e2e-tests.git" -- --api-url="https://${apiUrl}" --cdn-proxy-url="${agentUrl.toString()}" --ingress-proxy-url="${resultUrl.toString()}" --traffic-name=fingerprint-pro-akamai --integration-version=${ | ||
pkg.version | ||
}`, | ||
{ | ||
stdio: 'inherit', | ||
} | ||
) | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |