Skip to content

Commit

Permalink
Run e2e tests with captcha disabled
Browse files Browse the repository at this point in the history
This PR adds another setting to the e2e tests: captcha enabled / disabled
All tests are now also run against II deployed with captcha disabled.

In order to keep the number of tests run still to a somewhat reasonable
size not all combinations are run anymore: i.e. there is one domain
with captcha enabled and one domain with captcha disabled

Since the domain and the captcha are independent features, this should
not reduce the signal gained by running e2e tests.
  • Loading branch information
Frederik Rothenberger committed Oct 16, 2024
1 parent eb12561 commit 8509ee7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/canister-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,12 @@ jobs:
matrix:
device: [ 'desktop', 'mobile' ]
# We run the integration tests on both the official and legacy domains, to make sure
# the webapp (routes, csp, etc) works on both.
domain: [ 'https://identity.internetcomputer.org', 'https://identity.ic0.app' ]
# the webapp (routes, csp, etc) works on both. Captchas are statically enabled on one
# domain and disabled on the other.
# Both settings are combined in one single matrix variable as otherwise there would be
# excessively many combinations to be run and it would be questionable how much more of
# a signal we would get from that.
settings: [{domain: 'https://identity.internetcomputer.org', captcha: 'enabled'}, {domain: 'https://identity.ic0.app', captcha: 'disabled'}]
# Specify some shards for jest (a jest instance will only run a subset of files
# based on the shard assigned to it)
# The jest parameter is actually 1/N, 2/N etc but we use a artifact-friendly
Expand All @@ -414,7 +418,7 @@ jobs:

env:
# Suffix used for tagging artifacts
artifact_suffix: ${{ contains(matrix.domain, 'internetcomputer') && 'current' || 'legacy' }}-${{ matrix.device }}-${{ matrix.shard }}
artifact_suffix: ${{ contains(matrix.settings.domain, 'internetcomputer') && 'current' || 'legacy' }}-${{ matrix.device }}-captcha_${{ matrix.settings.captcha }}-${{ matrix.shard }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -461,8 +465,12 @@ jobs:

- name: Deploy canisters
run: |
captcha_flag="${{ matrix.settings.captcha }}"
# Build the "CaptchaEnabled" / "CaptchaDisabled" variants from the matrix captcha value
# (i.e. capitalize the first letter)
captcha_variant="Captcha$(tr '[:lower:]' '[:upper:]' <<< ${captcha_flag:0:1})${captcha_flag:1}"
# NOTE: dfx install will run the postinstall scripts from dfx.json
dfx canister install internet_identity --wasm internet_identity_test.wasm.gz
dfx canister install internet_identity --wasm internet_identity_test.wasm.gz --argument "(opt record { captcha_config = opt record { max_unsolved_captchas= 50:nat64; captcha_trigger = variant {Static = variant { $captcha_variant }}}})"
dfx canister install test_app --wasm demos/test-app/test_app.wasm
dfx canister install issuer --wasm demos/vc_issuer/vc_demo_issuer.wasm.gz
Expand All @@ -485,9 +493,10 @@ jobs:
# NOTE: we run chrome in headless mode because that's the only thing that works in GHA
# NOTE: the last bit (tr) replaces 1_N with 1/N
- run: |
II_URL=${{ matrix.domain }} \
II_URL=${{ matrix.settings.domain }} \
SCREEN=${{ matrix.device }} \
II_E2E_CHROME_OPTS="--headless" \
II_CAPTCHA=${{ matrix.settings.captcha }} \
npm run test:e2e -- --shard=$(tr <<<'${{ matrix.shard }}' -s _ /)
- name: Stop dfx
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/test-e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const ISSUER_CUSTOM_ORIGIN_NICE_URL = `https://nice-issuer-custom-orig.co
export const II_URL =
process.env.II_URL ?? "https://identity.internetcomputer.org";

export const CAPTCHA_ENABLED = process.env.II_CAPTCHA === "enabled" ?? false;

export const DEVICE_NAME1 = "FIDO Passkey";
export const RECOVERY_PHRASE_NAME = "Recovery Phrase";

Expand Down
13 changes: 9 additions & 4 deletions src/frontend/src/test-e2e/flows.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CAPTCHA_ENABLED } from "$src/test-e2e/constants";
import {
AddDeviceSuccessView,
AddRemoteDeviceInstructionsView,
Expand All @@ -16,8 +17,10 @@ export const FLOWS = {
const registerView = new RegisterView(browser);
await registerView.waitForDisplay();
await registerView.create();
await registerView.waitForRegisterConfirm();
await registerView.confirmRegisterConfirm();
if (CAPTCHA_ENABLED) {
await registerView.waitForRegisterConfirm();
await registerView.confirmRegisterConfirm();
}
await registerView.waitForIdentity();
const userNumber = await registerView.registerGetIdentity();
await registerView.registerConfirmIdentity();
Expand Down Expand Up @@ -53,8 +56,10 @@ export const FLOWS = {
await pinRegistrationView.setPin(pin);
await pinRegistrationView.waitForConfirmPin();
await pinRegistrationView.confirmPin(pin);
await registerView.waitForRegisterConfirm();
await registerView.confirmRegisterConfirm();
if (CAPTCHA_ENABLED) {
await registerView.waitForRegisterConfirm();
await registerView.confirmRegisterConfirm();
}
await registerView.waitForIdentity();
const userNumber = await registerView.registerGetIdentity();
await registerView.registerConfirmIdentity();
Expand Down

0 comments on commit 8509ee7

Please sign in to comment.