Skip to content

Commit

Permalink
Check that full reCAPTCHA script URL was assigned to script element
Browse files Browse the repository at this point in the history
  • Loading branch information
dlarocque committed Jul 11, 2024
1 parent 1483f41 commit b134676
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/analytics/src/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ describe('Gtag wrapping functions', () => {
insertScriptTag(customDataLayerName, fakeMeasurementId);
const scriptTag = findGtagScriptOnPage(customDataLayerName);
expect(scriptTag).to.not.be.null;
expect(scriptTag!.src).to.equal(`https://www.googletagmanager.com/gtag/js?l=${customDataLayerName}&id=${fakeMeasurementId}`);
expect(scriptTag!.src).to.equal(
`https://www.googletagmanager.com/gtag/js?l=${customDataLayerName}&id=${fakeMeasurementId}`
);
});

// The test above essentially already touches this functionality but it is still valuable
Expand Down
12 changes: 9 additions & 3 deletions packages/app-check/src/recaptcha.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import {
initializeV3,
initializeEnterprise,
getToken,
GreCAPTCHATopLevel
GreCAPTCHATopLevel,
RECAPTCHA_ENTERPRISE_URL,
RECAPTCHA_URL
} from './recaptcha';
import * as utils from './util';
import {
Expand Down Expand Up @@ -81,7 +83,9 @@ describe('recaptcha', () => {

expect(findgreCAPTCHAScriptsOnPage().length).to.equal(0);
await initializeV3(app, FAKE_SITE_KEY);
expect(findgreCAPTCHAScriptsOnPage().length).to.equal(1);
const greCATPCHAScripts = findgreCAPTCHAScriptsOnPage();
expect(greCATPCHAScripts.length).to.equal(1);
expect(greCATPCHAScripts[0].src).to.equal(RECAPTCHA_URL);
});

it('creates invisible widget', async () => {
Expand Down Expand Up @@ -128,7 +132,9 @@ describe('recaptcha', () => {

expect(findgreCAPTCHAScriptsOnPage().length).to.equal(0);
await initializeEnterprise(app, FAKE_SITE_KEY);
expect(findgreCAPTCHAScriptsOnPage().length).to.equal(1);
const greCAPTCHAScripts = findgreCAPTCHAScriptsOnPage();
expect(greCAPTCHAScripts.length).to.equal(1);
expect(greCAPTCHAScripts[0].src).to.equal(RECAPTCHA_ENTERPRISE_URL);
});

it('creates invisible widget', async () => {
Expand Down

0 comments on commit b134676

Please sign in to comment.