Skip to content

Commit c08e784

Browse files
committed
cleanup and refactor
1 parent c1fca0e commit c08e784

File tree

5 files changed

+23
-43
lines changed

5 files changed

+23
-43
lines changed

react-example/e2e/authentication.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { test, expect } from '@playwright/test';
22
import { BasePage } from './page-objects/BasePage';
3-
4-
const TEST_EMAIL =
5-
process.env.LOGIN_EMAIL || '[email protected]';
3+
import { TEST_EMAIL } from './utils/test-constants';
64

75
/**
86
* SDK Authentication Test Suite

react-example/e2e/fixtures/message-factory.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,11 @@
33
* Follows Playwright best practices - DRY, reusable, maintainable
44
*/
55

6+
import type { InAppMessage } from '@iterable/web-sdk';
67
import { MessageTemplates } from './message-templates';
78

8-
export interface InAppMessage {
9-
messageId: string;
10-
campaignId: number;
11-
createdAt: number;
12-
expiresAt: number;
13-
content: {
14-
html: string;
15-
payload: Record<string, unknown>;
16-
inAppDisplaySettings: {
17-
top: { displayOption: string };
18-
right: { percentage: number };
19-
bottom: { displayOption: string };
20-
left: { percentage: number };
21-
shouldAnimate: boolean;
22-
bgColor?: { alpha: number; hex: string };
23-
};
24-
webInAppDisplaySettings: { position: string };
25-
};
26-
customPayload: Record<string, unknown>;
27-
trigger: { type: string };
28-
saveToInbox: boolean;
29-
inboxMetadata: {
30-
title: string;
31-
subtitle: string;
32-
icon: string;
33-
};
34-
priorityLevel: number;
35-
read: boolean;
36-
jsonOnly: boolean;
37-
typeOfContent: string;
38-
messageType: string;
39-
}
9+
// Re-export InAppMessage type for convenience
10+
export type { InAppMessage };
4011

4112
const defaultDisplaySettings = {
4213
top: { displayOption: 'AutoExpand' },

react-example/e2e/fixtures/test-fixtures.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
import { test as base } from '@playwright/test';
1414
import { BasePage } from '../page-objects/BasePage';
1515
import { InAppPage } from '../page-objects/pages/InAppPage';
16-
17-
const TEST_EMAIL =
18-
process.env.LOGIN_EMAIL || '[email protected]';
16+
import { TEST_EMAIL } from '../utils/test-constants';
1917

2018
type CustomFixtures = {
2119
basePage: BasePage;

react-example/e2e/inapp-e2e.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { test, expect } from '@playwright/test';
22
import { BasePage } from './page-objects/BasePage';
33
import { InAppPage } from './page-objects/pages/InAppPage';
4-
5-
const TEST_EMAIL =
6-
process.env.LOGIN_EMAIL || '[email protected]';
4+
import { TEST_EMAIL } from './utils/test-constants';
75

86
/**
97
* In-App Messaging E2E Tests
@@ -158,7 +156,8 @@ test.describe('In-App Messaging - E2E (Real API)', () => {
158156
.first();
159157
if (await closeButton.isVisible({ timeout: 2000 }).catch(() => false)) {
160158
await closeButton.click();
161-
await page.waitForTimeout(500);
159+
// Wait for iframe to be removed
160+
await expect(page.locator('iframe#iterable-iframe')).not.toBeAttached();
162161
}
163162

164163
await inAppPage.pauseButton.click();
@@ -184,7 +183,8 @@ test.describe('In-App Messaging - E2E (Real API)', () => {
184183
.first();
185184
if (await closeButton.isVisible({ timeout: 2000 }).catch(() => false)) {
186185
await closeButton.click();
187-
await page.waitForTimeout(500);
186+
// Wait for iframe to be removed
187+
await expect(iframe).not.toBeAttached();
188188
}
189189
}
190190

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Shared test constants
3+
* Single source of truth for test configuration values
4+
*/
5+
6+
export const TEST_EMAIL =
7+
process.env.LOGIN_EMAIL || '[email protected]';
8+
9+
export const API_TIMEOUTS = {
10+
standard: 15000,
11+
short: 5000,
12+
iframe: 10000
13+
} as const;

0 commit comments

Comments
 (0)