-
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.
sample tests with and without camera permissions enabled; classic int…
…egration (#6)
- Loading branch information
1 parent
2978682
commit c7ace4b
Showing
11 changed files
with
2,859 additions
and
750 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
# WebViewAngular | ||
A sample Angular native app integration with Onfido’s [Web SDK](https://documentation.onfido.com/sdk/web/), using webviews. | ||
|
||
## | ||
## Instructions | ||
|
||
Create a `.env` file on the root of the project and set the following environment variables: | ||
|
||
``` | ||
IS_CLASSIC_INTEGRATION=<true-or-false> | ||
API_TOKEN=<your-api-token> | ||
WORKFLOW_ID=<your-workflow-id>, | ||
``` | ||
|
||
> Check other possible environment variables under [environment.ts](src/app/environments/environment.ts). | ||
```shell | ||
npm i | ||
npm build | ||
npm run start | ||
npm run e2e | ||
npm i # install dependencies | ||
npm build # set other required environment variables on .env file | ||
npm run start # start the web sdk | ||
npm run e2e # run the e2e tests | ||
``` |
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,105 @@ | ||
import { chromium, expect, test } from '@playwright/test' | ||
|
||
const getPage = async ({ withCameraPermissions = true }) => { | ||
const args = [] | ||
const permissions = [] | ||
|
||
if (withCameraPermissions) { | ||
args.push('--use-fake-ui-for-media-stream') | ||
args.push('--use-fake-device-for-media-stream') | ||
permissions.push('camera') | ||
} | ||
|
||
const browser = await chromium.launch({ | ||
args, | ||
}) | ||
const page = await browser.newPage() | ||
|
||
await page.context().grantPermissions(permissions) | ||
|
||
// Mocking consents being given | ||
await page.route('**/applicants/*/consents', async (route) => { | ||
return route.fulfill({ | ||
body: JSON.stringify([]), | ||
}) | ||
}) | ||
|
||
return page | ||
} | ||
|
||
test.describe('Classic integration', () => { | ||
test.skip( | ||
process.env.IS_CLASSIC_INTEGRATION === 'false', | ||
'Skipping tests if not a classic integration' | ||
) | ||
|
||
test('without camera permissions', async () => { | ||
const page = await getPage({ withCameraPermissions: false }) | ||
|
||
await page.goto('/') | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="country-selector"]') | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('span[role="option"]') | ||
.first() | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="passport"]') | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="passport-guide-next-btn"]') | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="enable-camera-btn"]') | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-screen="Recover"]') | ||
.isVisible() | ||
}) | ||
|
||
test('with camera permissions', async () => { | ||
const page = await getPage({}) | ||
|
||
await page.goto('/') | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="country-selector"]') | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('span[role="option"]') | ||
.first() | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="passport"]') | ||
.click() | ||
|
||
await page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="passport-guide-next-btn"]') | ||
.click() | ||
|
||
await expect( | ||
page | ||
.frameLocator('iframe[name="onfido-document"]') | ||
.locator('[data-qa="enable-camera-btn"]') | ||
).not.toBeVisible() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test.describe('Studio integration', () => { | ||
test.skip( | ||
process.env.IS_CLASSIC_INTEGRATION === 'true', | ||
'Skipping tests if not a Studio integration' | ||
) | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('/') | ||
expect( | ||
page | ||
.frameLocator('iframe[name="onfido-welcome"]') | ||
.getByText('Verify your identity') | ||
).toBeTruthy() | ||
}) | ||
}) |
Oops, something went wrong.