Skip to content

Commit

Permalink
Merge pull request #1058 from adobe/testShowContainers
Browse files Browse the repository at this point in the history
Show containers even when renderDecisions is false
  • Loading branch information
jonsnyder authored Oct 19, 2023
2 parents 8cb75b7 + 84afa26 commit 812dbe2
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/Personalization/createFetchDataHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default ({
return ({ cacheUpdate, personalizationDetails, event, onResponse }) => {
if (personalizationDetails.isRenderDecisions()) {
hideContainers(prehidingStyle);
} else {
showContainers();
}
mergeQuery(event, personalizationDetails.createQueryDetails());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default ({ schemaProcessors, logger }) => {
.catch(error => {
if (logger.enabled) {
const { message, stack } = error;
const errorMessage = `Failed to execute action ${item.toString()}. ${message} ${stack}`;
logger.error(errorMessage);
const warning = `Failed to execute action ${item.toString()}. ${message} ${stack}`;
logger.warn(warning);
}
return false;
});
Expand Down
47 changes: 47 additions & 0 deletions test/functional/specs/Personalization/C14299419.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { t, Selector } from "testcafe";
import createFixture from "../../helpers/createFixture";
import {
compose,
orgMainConfigMain,
debugEnabled
} from "../../helpers/constants/configParts";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import addHtmlToHeader from "../../helpers/dom/addHtmlToHeader";

const config = compose(orgMainConfigMain, debugEnabled);

createFixture({
title:
"C14299419: Prehiding style is removed when no personalization payload is returned",
url: `${TEST_PAGE_URL}?test=C14299419`
});

test.meta({
ID: "C14299419",
SEVERITY: "P0",
TEST_RUN: "Regression"
});

test("Test C14299419: Prehiding style is removed when no personalization payload is returned", async () => {
await addHtmlToHeader(
`<style id="alloy-prehiding">body { visibility: hidden; }</style`
);

const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.sendEvent({ renderDecisions: true });

await t.expect(Selector("#alloy-prehiding").exists).notOk();
});
46 changes: 46 additions & 0 deletions test/functional/specs/Personalization/C14299420.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { t, Selector } from "testcafe";
import createFixture from "../../helpers/createFixture";
import {
compose,
orgMainConfigMain,
debugEnabled
} from "../../helpers/constants/configParts";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import addHtmlToHeader from "../../helpers/dom/addHtmlToHeader";

const config = compose(orgMainConfigMain, debugEnabled);

createFixture({
title: "C14299420: Prehiding style is removed when renderDecisions is false",
url: `${TEST_PAGE_URL}?test=C14299420`
});

test.meta({
ID: "C14299420",
SEVERITY: "P0",
TEST_RUN: "Regression"
});

test("Test C14299420: Prehiding style is removed when renderDecisions is false", async () => {
await addHtmlToHeader(
`<style id="alloy-prehiding">body { visibility: hidden; }</style`
);

const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.sendEvent({ renderDecisions: false });

await t.expect(Selector("#alloy-prehiding").exists).notOk();
});
59 changes: 59 additions & 0 deletions test/functional/specs/Personalization/C14299421.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { t, Selector } from "testcafe";
import createFixture from "../../helpers/createFixture";
import {
compose,
orgMainConfigMain,
debugEnabled
} from "../../helpers/constants/configParts";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import addHtmlToHeader from "../../helpers/dom/addHtmlToHeader";
import addHtmlToBody from "../../helpers/dom/addHtmlToBody";
import createConsoleLogger from "../../helpers/consoleLogger";

const config = compose(orgMainConfigMain, debugEnabled);

createFixture({
title:
"C14299421: Prehiding style is removed when there is a problem rendering",
url: `${TEST_PAGE_URL}?test=C14299421`
});

test.meta({
ID: "C14299421",
SEVERITY: "P0",
TEST_RUN: "Regression"
});

test("Test C14299421: Prehiding style is removed when there is a problem rendering", async () => {
const logger = await createConsoleLogger();

// remove the heading so there is an error when trying to apply the personalization which is attached to the h1
await t.eval(() => {
window.document.body.children[0].remove();
});
await addHtmlToBody(`<div>Test C14299421 with missing heading</div>`);
await addHtmlToHeader(
`<style id="alloy-prehiding">body { visibility: hidden; }</style`
);

const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.sendEvent({ renderDecisions: true });

await t.expect(Selector("#alloy-prehiding").exists).notOk();
// wait for the rendering to timeout
await new Promise(resolve => setTimeout(resolve, 5000));
await logger.warn.expectMessageMatching(/Failed to execute action/);
});
47 changes: 47 additions & 0 deletions test/functional/specs/Personalization/C14299422.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { t, Selector } from "testcafe";
import createFixture from "../../helpers/createFixture";
import {
compose,
orgMainConfigMain,
debugEnabled
} from "../../helpers/constants/configParts";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import addHtmlToHeader from "../../helpers/dom/addHtmlToHeader";

const config = compose(orgMainConfigMain, debugEnabled);

createFixture({
title:
"C14299422: Prehiding style is removed when there is a personalization payload",
url: `${TEST_PAGE_URL}?test=C14299421`
});

test.meta({
ID: "C14299422",
SEVERITY: "P0",
TEST_RUN: "Regression"
});

test("Test C14299422: Prehiding style is removed when there is a personalization payload", async () => {
await addHtmlToHeader(
`<style id="alloy-prehiding">body { visibility: hidden; }</style`
);

const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.sendEvent({ renderDecisions: true });

await t.expect(Selector("#alloy-prehiding").exists).notOk();
});

0 comments on commit 812dbe2

Please sign in to comment.