Skip to content

Commit

Permalink
add e2e tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gilluminate committed May 20, 2024
1 parent 79d7b8b commit d7b4b87
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The types of changes are:
### Added
- Added initial version for Helios: Data Discovery and Detection [#4839](https://github.com/ethyca/fides/pull/4839)
- Enhancements to `MonitorConfig` DB model to support new functionality [#4888](https://github.com/ethyca/fides/pull/4888)
- Added developer option to disable auto-initialization on FidesJS bundles. [#4900](https://github.com/ethyca/fides/pull/4900)

### Changed
- Adds new var to track fides js overlay types [#4869](https://github.com/ethyca/fides/pull/4869)
Expand Down
31 changes: 31 additions & 0 deletions clients/privacy-center/cypress/e2e/consent-banner.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2510,4 +2510,35 @@ describe("Consent overlay", () => {
});
});
});

describe("when initialization has been disabled by the developer", () => {
beforeEach(() => {
cy.getCookie(CONSENT_COOKIE_NAME).should("not.exist");
cy.visit({
url: "/fides-js-demo.html",
qs: { initialize: "false" },
});
cy.window().then((win) => {
win.addEventListener(
"FidesInitialized",
cy.stub().as("FidesInitialized")
);
});
});
it("does not trigger any side-effects (like banners displaying, events firing, etc.)", () => {
cy.window().then((win) => {
assert.isTrue(!!win.Fides.config);
assert.isFalse(win.Fides.initialized);
});
cy.get("@FidesInitialized").should("not.have.been.called");
cy.get("#fides-overlay .fides-banner").should("not.exist");
});
it("can still be initialized manually by the developer after adjusting settings", () => {
cy.window().then((win) => {
win.Fides.init().then(() => {
assert.isTrue(win.Fides.initialized);
});
});
});
});
});
8 changes: 8 additions & 0 deletions clients/privacy-center/cypress/e2e/fides-js.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ describe("fides.js API route", () => {
});
});
});

describe("when disabling initialization", () => {
it("does not call widnow.Fides.init", () => {
cy.request("/fides.js?initialize=false").then((response) => {
expect(response.body).not.to.match(/window.Fides.init(fidesConfig)/);
});
});
});
});

// Convert this to a module instead of script (allows import/export)
Expand Down
6 changes: 6 additions & 0 deletions clients/privacy-center/pages/api/fides-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ let autoRefresh: boolean = true;
* description: Forces the GPP extension to be included in the bundle, even if the experience does not have GPP enabled
* schema:
* type: boolean
* - in: query
* name: initialize
* required: false
* description: When set to "false" fides.js will not be initialized automatically; use `window.Fides.init()` to initialize manually
* schema:
* type: boolean
* - in: header
* name: CloudFront-Viewer-Country
* required: false
Expand Down

0 comments on commit d7b4b87

Please sign in to comment.