Skip to content

Commit

Permalink
clarify selector and var names
Browse files Browse the repository at this point in the history
  • Loading branch information
surekhaw committed Nov 26, 2024
1 parent 65a95b6 commit d0066e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
13 changes: 3 additions & 10 deletions tests/functional/spec/non-snapshot-tests/payload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import { bannerStyles } from '../utils/testStylesConfig';
import { selectors } from '../../v2/utils/index';
import setupTestPage from '../utils/setupTestPage';

const {
message: { messageIframe },
modal: {
button: { close }
}
} = selectors;

const EVENT_TYPES = ['MORS', 'modal_rendered', 'message_hovered', 'modal_close', 'modal_viewed', 'scroll'];

const createSpy = async () => {
Expand Down Expand Up @@ -165,7 +158,7 @@ describe('payload testing', () => {
{
index: expect.any(String),
event_type: 'modal_rendered',
modal: expect.stringMatching(/(NI)|(NO_INTEREST)|(INST)/i),
modal: expect.stringMatching(/(NI)|(NO_INTEREST)/i),
first_modal_render_delay: expect.any(String),
timestamp: expect.any(Number),
render_duration: expect.any(String)
Expand Down Expand Up @@ -229,7 +222,7 @@ describe('payload testing', () => {
testName: 'hover stat sent',
config,
callback: async () => {
await page.hover(messageIframe);
await page.hover(selectors.message.messageIframe);
},
matchObjematchComponentEventscts: [
{
Expand Down Expand Up @@ -264,7 +257,7 @@ describe('payload testing', () => {
testName: 'modal close stat sent',
config,
callback: async ({ modalFrame }) => {
await modalFrame.click(close);
await modalFrame.click(selectors.modal.button.close);
},
matchComponentEvents: [
{
Expand Down
17 changes: 7 additions & 10 deletions tests/functional/spec/utils/setupTestPage.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import { selectors } from '../../v2/utils/index';

const {
modal: { iframe },
message: { messageIframe, messageMessaging }
} = selectors;

export default async function setupTestPage({ config, testPage, frameName }) {
await page.goto(`https://localhost.paypal.com:8080/snapshot/${testPage}?config=${JSON.stringify(config)}`);

const frameWithMessage = frameName ? page.frames().find(frame => frame.name() === frameName) : page.mainFrame();
const zoidMessageIframeEl = await frameWithMessage.waitForSelector(messageIframe, { visible: true });
const bannerElement = await zoidMessageIframeEl.contentFrame();
const bannerElement = await frameWithMessage.waitForSelector(selectors.message.messageIframe, {
visible: true
});
const bannerFrame = await bannerElement.contentFrame();

await bannerElement.waitForSelector(messageMessaging);
await bannerFrame.waitForSelector(selectors.message.messageMessaging);

const openModal = async () => {
await bannerElement.click(messageMessaging);
await bannerElement.click(selectors.message.messageMessaging);

const zoidModalIframeEl = await page.waitForSelector(iframe, { visible: true });
const zoidModalIframeEl = await page.waitForSelector(selectors.modal.iframe, { visible: true });
const modalFrame = await zoidModalIframeEl.contentFrame();
return { modalFrame };
};
Expand Down

0 comments on commit d0066e9

Please sign in to comment.