Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
780d65a
MOB-10966: Add business critical integration testing framework
sumeruchat Jul 1, 2025
2e43f9f
Add local integration test environment and sample app test integration
sumeruchat Jul 1, 2025
1b246d6
Add comprehensive README for non-technical integration testing
sumeruchat Jul 1, 2025
6082a33
Fix
sumeruchat Jul 7, 2025
c4e5a51
Fix
sumeruchat Jul 7, 2025
289072e
Fix
sumeruchat Jul 17, 2025
2077270
Delete build folder
sumeruchat Jul 23, 2025
ca90c48
Fixes
sumeruchat Jul 23, 2025
39cae09
Fixes
sumeruchat Jul 23, 2025
01a727a
Fix.
sumeruchat Aug 7, 2025
e7421d7
Merge branch 'master' into feature/MOB-10966-business-critical-integr…
sumeruchat Aug 7, 2025
42ded98
Fix.
sumeruchat Aug 7, 2025
08c1cf2
Fixes
sumeruchat Aug 7, 2025
486bf8c
Fixes
sumeruchat Aug 7, 2025
7ae274a
Fixes
sumeruchat Aug 7, 2025
59fe437
Fix.
sumeruchat Aug 7, 2025
7d1bb87
Fixes
sumeruchat Aug 7, 2025
f3325b5
Fixes
sumeruchat Aug 11, 2025
b77d485
Fixes
sumeruchat Aug 11, 2025
e744664
Fixes
sumeruchat Aug 11, 2025
47e1496
Fixes
sumeruchat Aug 11, 2025
98384fc
Fixes
sumeruchat Aug 11, 2025
0d88c03
fixes
sumeruchat Aug 11, 2025
e5e94a7
Fixes
sumeruchat Aug 12, 2025
2a97d25
Fixes
sumeruchat Aug 13, 2025
a83597f
Fixes
sumeruchat Aug 13, 2025
52ae1a1
Fixes
sumeruchat Aug 13, 2025
373aedb
no message
sumeruchat Aug 13, 2025
8a25020
Upgrade frontend to v2
sumeruchat Aug 18, 2025
d4c8821
Upgrade frontend to v2
sumeruchat Aug 18, 2025
fc421e5
Upgrade frontend to v2
sumeruchat Aug 18, 2025
b7cc5fb
Upgrade frontend to v2
sumeruchat Aug 18, 2025
e3778eb
Fixes
sumeruchat Aug 18, 2025
574889b
Fixes
sumeruchat Aug 18, 2025
afc97e4
Upgrade frontend to v2
sumeruchat Aug 18, 2025
616b35e
fix
sumeruchat Aug 18, 2025
64b41a5
fix
sumeruchat Aug 18, 2025
f37c9e9
Merge branch 'master' into feature/MOB-10966-business-critical-integr…
sumeruchat Aug 18, 2025
edfaca0
fix
sumeruchat Aug 18, 2025
4bfa94a
fix
sumeruchat Aug 18, 2025
fe62e7c
fix
sumeruchat Aug 18, 2025
e8f6941
fix
sumeruchat Aug 18, 2025
6aeaf8f
fix
sumeruchat Aug 18, 2025
d9f33d6
fix
sumeruchat Aug 18, 2025
8a5d63a
fix
sumeruchat Aug 18, 2025
300c4c9
fix
sumeruchat Aug 18, 2025
a339455
fixes
sumeruchat Aug 18, 2025
e79560d
fix
sumeruchat Aug 18, 2025
ecb5d24
fix
sumeruchat Aug 18, 2025
250450e
fix
sumeruchat Aug 18, 2025
62fd2ed
fix
sumeruchat Aug 18, 2025
8d70349
fix
sumeruchat Aug 18, 2025
43538ef
fix
sumeruchat Aug 18, 2025
9bcbc27
fix
sumeruchat Aug 18, 2025
716ce18
fix
sumeruchat Aug 18, 2025
ab23e7d
fix
sumeruchat Aug 18, 2025
5d96b42
fix
sumeruchat Aug 18, 2025
00f4288
fix
sumeruchat Aug 18, 2025
63122cb
fix
sumeruchat Aug 18, 2025
f1c8ba0
fix
sumeruchat Aug 18, 2025
5dd2bb5
fix
sumeruchat Aug 18, 2025
69d8b92
fix
sumeruchat Aug 18, 2025
d81e1e4
fix
sumeruchat Aug 18, 2025
b123056
fix
sumeruchat Aug 18, 2025
ced5f97
Merge branch 'master' into feature/MOB-10966-business-critical-integr…
sumeruchat Aug 21, 2025
7b4f012
Revert
sumeruchat Aug 21, 2025
8f4d2ba
Revert
sumeruchat Aug 21, 2025
2deb644
Revert
sumeruchat Aug 21, 2025
90a143c
Revert
sumeruchat Aug 21, 2025
73d14f3
Revert
sumeruchat Aug 21, 2025
3da5337
Revert
sumeruchat Aug 21, 2025
8445062
Revert
sumeruchat Aug 21, 2025
b2fb8de
Revert
sumeruchat Aug 22, 2025
1fbb469
Revert
sumeruchat Aug 22, 2025
17fbd15
Revert
sumeruchat Aug 22, 2025
85e02bf
Fixes
sumeruchat Aug 22, 2025
f6b5d26
Fix
sumeruchat Aug 22, 2025
22b9b4d
Revert
sumeruchat Aug 22, 2025
d155df4
Revert
sumeruchat Aug 22, 2025
4665177
Revert
sumeruchat Aug 22, 2025
876df24
Revert
sumeruchat Aug 22, 2025
fb442df
Revert
sumeruchat Aug 22, 2025
7646778
Revert
sumeruchat Aug 22, 2025
dfecdda
Revert
sumeruchat Aug 22, 2025
339b078
Revert
sumeruchat Aug 22, 2025
7411c14
Revert
sumeruchat Aug 22, 2025
7790fe6
Revert
sumeruchat Aug 22, 2025
4e29e5b
Revert
sumeruchat Aug 22, 2025
88ae10a
Revert
sumeruchat Aug 22, 2025
1156ef5
Revert
sumeruchat Aug 22, 2025
638ec3a
fixes
sumeruchat Aug 22, 2025
b225fdc
Revert
sumeruchat Aug 22, 2025
a5eaa45
Revert
sumeruchat Aug 22, 2025
13b9c4d
Revert
sumeruchat Aug 22, 2025
17fe327
Revert
sumeruchat Aug 22, 2025
b4b7618
Revert
sumeruchat Aug 22, 2025
95ea9f1
Revert
sumeruchat Aug 22, 2025
5eca3bf
Revert
sumeruchat Aug 22, 2025
89eeade
Revert
sumeruchat Aug 22, 2025
84753cd
Add template
sumeruchat Aug 29, 2025
bd8868f
Add template
sumeruchat Aug 29, 2025
137ab18
Add template
sumeruchat Aug 29, 2025
8e13eaf
Add template
sumeruchat Aug 29, 2025
72b2eda
Add template
sumeruchat Aug 29, 2025
790d74a
Add template
sumeruchat Aug 29, 2025
25778fc
Add template
sumeruchat Aug 29, 2025
0d0fec3
Add template
sumeruchat Aug 29, 2025
b67f8b6
Add template
sumeruchat Aug 29, 2025
4ceba34
Add template
sumeruchat Aug 29, 2025
31a6ae9
Add template
sumeruchat Aug 29, 2025
a7ab3cc
Add template
sumeruchat Aug 29, 2025
0f9c65d
Add template
sumeruchat Aug 29, 2025
f676c4e
Add template
sumeruchat Aug 29, 2025
9cf65fc
Add template
sumeruchat Aug 29, 2025
f919540
Add template
sumeruchat Aug 29, 2025
91a8b21
Add template
sumeruchat Aug 29, 2025
bfed6c2
Add template
sumeruchat Aug 29, 2025
c6cc967
Add template
sumeruchat Aug 29, 2025
7e1cd8d
Merge branch 'master' into feature/MOB-10966-business-critical-integr…
sumeruchat Aug 29, 2025
b5d8665
Add template
sumeruchat Aug 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/bcit-integration-test-push-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: BCIT Push Notification Integration Test

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
workflow_dispatch:
inputs:
ref:
description: 'Branch or commit to test (leave empty for current branch)'
required: false
type: string

env:
DEVELOPER_DIR: /Applications/Xcode_16.2.app/Contents/Developer

jobs:
push-notification-test:
name: BCIT Push Notification Integration Test
runs-on: macos-latest
timeout-minutes: 30
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request' && (
contains(github.event.pull_request.labels.*.name, 'bcit') ||
contains(github.event.pull_request.labels.*.name, 'BCIT') ||
contains(github.event.pull_request.labels.*.name, 'bcit-push') ||
contains(github.event.pull_request.labels.*.name, 'BCIT-PUSH') ||
contains(github.event.pull_request.labels.*.name, 'Bcit') ||
contains(github.event.pull_request.labels.*.name, 'Bcit-Push') ||
startsWith(github.event.pull_request.head.ref, 'release/')
)
)

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}

- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'

- name: Validate Xcode Version
run: |
echo "πŸ” Validating Xcode version and environment..."
echo "DEVELOPER_DIR: $DEVELOPER_DIR"
echo "Expected Xcode path: /Applications/Xcode_16.2.app/Contents/Developer"

# Check if DEVELOPER_DIR points to the right Xcode
if [[ "$DEVELOPER_DIR" == "/Applications/Xcode_16.2.app/Contents/Developer" ]]; then
echo "βœ… DEVELOPER_DIR is correctly set"
else
echo "❌ DEVELOPER_DIR mismatch!"
echo "Current: $DEVELOPER_DIR"
echo "Expected: /Applications/Xcode_16.2.app/Contents/Developer"
fi

# Check xcodebuild version
echo "πŸ” Checking xcodebuild version..."
XCODE_VERSION=$(xcodebuild -version | head -n 1)
echo "Xcode version: $XCODE_VERSION"

# Check xcodebuild path
XCODEBUILD_PATH=$(which xcodebuild)
echo "xcodebuild path: $XCODEBUILD_PATH"

# Verify we're using Xcode 16.2
if echo "$XCODE_VERSION" | grep -q "16.2"; then
echo "βœ… Using correct Xcode version: $XCODE_VERSION"
else
echo "❌ Incorrect Xcode version!"
echo "Current: $XCODE_VERSION"
echo "Expected: Xcode 16.2"
exit 1
fi

- name: Setup Local Environment
working-directory: tests/business-critical-integration
run: |
echo "πŸš€ Setting up local environment for integration tests..."

# Run setup script with parameters from repository secrets
./scripts/setup-local-environment.sh \
"${{ secrets.BCIT_TEST_PROJECT_ID }}" \
"${{ secrets.BCIT_ITERABLE_SERVER_KEY }}" \
"${{ secrets.BCIT_ITERABLE_API_KEY }}"

- name: Validate Setup
working-directory: tests/business-critical-integration
run: |
echo "πŸ” Validating environment setup..."
./scripts/validate-setup.sh

- name: Run Push Notification Tests
working-directory: tests/business-critical-integration
run: |
echo "πŸ§ͺ Running push notification integration tests..."
CI=true ./scripts/run-tests.sh push

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: push-notification-test-results
path: |
tests/business-critical-integration/reports/
tests/business-critical-integration/screenshots/
tests/business-critical-integration/logs/
retention-days: 7
2 changes: 1 addition & 1 deletion .github/workflows/prepare-for-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
- [ ] All tests passing
- [ ] Documentation updated (if needed)

branch: "MOB-${{ github.event.inputs.jira_ticket }}-prepare-for-release-${{ steps.update_changelog.outputs.new_version }}"
branch: "release/MOB-${{ github.event.inputs.jira_ticket }}-prepare-for-release-${{ steps.update_changelog.outputs.new_version }}"
commit-message: "[MOB-${{ github.event.inputs.jira_ticket }}]: Prepare for release ${{ steps.update_changelog.outputs.new_version }}"
labels: release
delete-branch: true
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ xcuserdata

.claude/

tests/business-critical-integration/logs
tests/business-critical-integration/integration-test-app/config
tests/business-critical-integration/reports
tests/business-critical-integration/screenshots


.swiftpm/

.claude

*~
Podfile.lock
Pods/
Expand Down
171 changes: 171 additions & 0 deletions tests/business-critical-integration/AGENT_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Business Critical Integration Tests - CI Push Notification Strategy

## Overview
This project implements push notification integration tests that work seamlessly in both local and CI environments.

## CI Push Notification Strategy

### Problem
- CI servers use macOS virtualization which doesn't provide device tokens
- Without device tokens, apps can't register for APNS push notifications
- This breaks push notification integration tests in CI

### Solution Implemented
1. **Environment Detection**: Automatically detects CI environment via environment variables
2. **Mock Device Token**: Generates fake device tokens for CI testing
3. **Simulated Push Notifications**: Uses `xcrun simctl push` to send fake pushes to simulator
4. **Local Testing Unchanged**: Real APNS pushes continue to work locally

## Technical Implementation

### Key Files Modified
- `AppDelegate+IntegrationTest.swift`: CI detection + mock device token generation
- `IntegrationTestBase.swift`: CI environment detection + simulated push capabilities
- `PushNotificationIntegrationTests.swift`: CI-aware push notification testing
- `run-tests.sh`: CI environment variable setup

### CI Environment Detection
- Checks for `CI=1`, `GITHUB_ACTIONS`, `JENKINS_URL`, `BUILDKITE` environment variables
- Automatically enables mock mode when detected

### Mock Device Token Generation
- Generates realistic 32-byte hex string tokens in CI
- Simulates `didRegisterForRemoteNotificationsWithDeviceToken` callback
- Maintains full Iterable SDK registration flow

### Simulated Push Notifications
- Uses `xcrun simctl push` command with temporary `.apns` payload files
- Supports both standard and deep link push notifications
- Validates same notification handling logic as real pushes
- **NEW**: Background push monitor in test runner automatically executes queued push commands
- Test creates persistent payload and command files in `/tmp/push_queue`
- Test runner monitors queue directory and executes `xcrun simctl` commands automatically

## Usage

### Local Testing (Default)
```bash
./scripts/run-tests.sh
```
- Uses real APNS push notifications
- Full end-to-end validation

### CI Testing
```bash
CI=1 ./scripts/run-tests.sh
```
- Uses mock device tokens
- Sends simulated push notifications
- Tests full push notification flow without network dependencies

## Push Notification Payloads

### Standard Push (CI)
```json
{
"aps": {
"alert": {
"title": "Integration Test",
"body": "This is an integration test simple push"
},
"badge": 1,
"sound": "default"
},
"itbl": {
"campaignId": 12345,
"templateId": 67890,
"isGhostPush": false
}
}
```

### Deep Link Push (CI)
```json
{
"aps": {
"alert": {
"title": "Deep Link Test",
"body": "This is a deep link push notification test"
},
"badge": 1,
"sound": "default"
},
"itbl": {
"campaignId": 12346,
"templateId": 67891,
"isGhostPush": false,
"deepLinkURL": "tester://product?itemId=12345&category=shoes"
}
}
```

## Screenshot Management

### Problem
- Screenshots were being saved to iOS simulator's Documents directory instead of project's screenshots folder
- Screenshots from test runs were not accessible for review or CI artifacts

### Solution
- Added `copy_screenshots_from_simulator()` function to run-tests.sh
- Automatically copies screenshots from simulator Documents to project screenshots folder after tests complete
- Clears previous screenshots from project directory before copying new ones
- Cleans up simulator screenshots after successful copy

### Implementation
- Parses screenshot directory path directly from test log files in reports directory
- Uses `find` to locate most recent `.log` file for parsing
- Falls back to searching simulator directories if log parsing fails
- Integrates into test completion flow before cleanup
- Fixed xcresulttool deprecation warning by adding `--legacy` flag

## Test Artifacts Organization

### Directory Structure
- **πŸ“ reports/**: XCTest result bundles (.xcresult) and test reports (.log files for screenshot parsing)
- **πŸ“ logs/**: Complete test execution logs with full output
- **πŸ“ screenshots/**: Test screenshots automatically copied from simulator
- **πŸ“ scripts/**: Test execution and utility scripts

### File Naming Convention
- Timestamp format: `YYYYMMDD-HHMMSS`
- Test class name converted to lowercase
- Examples:
- `pushnotificationintegrationtests-20250829-131349.xcresult`
- `pushnotificationintegrationtests-20250829-131349.log`

## CI Network Validation Strategy

### Mock Device Token Handling
- **CI Environment**: Skips 200 status code validation for `registerDeviceToken` API calls
- **Reason**: Mock device tokens in CI may return unpredictable backend responses
- **Local Environment**: Full validation including 200 status codes continues as normal
- **Detection**: Uses existing `isRunningInCI` environment detection

## Daily Test User Creation

### Enhancement
- **Date-Prefixed Email Generation**: Test user emails now include current date prefix for daily unique users
- **Format**: `[email protected]` (e.g., `[email protected]`)
- **Automatic**: Both interactive and non-interactive modes generate date-prefixed emails
- **Benefits**: Enables fresh test users daily, avoiding conflicts with previous test data

### Implementation
- Modified `setup-local-environment.sh` to add `$(date +"%Y-%m-%d")` prefix to test emails
- Works in both interactive and non-interactive setup modes
- Updates JSON configuration automatically with date-prefixed email
- Maintains backward compatibility with existing test infrastructure

## Benefits
- βœ… Push notification tests run successfully in CI
- βœ… No changes to existing local testing workflow
- βœ… Tests complete push flow including device registration
- βœ… Supports both standard and deep link push notifications
- βœ… Maintains payload format compatibility for future changes
- βœ… Screenshots automatically copied to project directory for review and CI artifacts
- βœ… Complete test artifacts organized in dedicated directories
- βœ… XCTest results saved for detailed analysis and CI integration
- βœ… Smart network validation that adapts to CI vs local environments
- βœ… **NEW**: Automated push execution via background monitor eliminates manual intervention
- βœ… **NEW**: Enhanced logging provides comprehensive visibility into push simulation process
- βœ… **NEW**: Robust file-based communication between iOS test and macOS test runner
- βœ… **NEW**: Daily test user creation with date-prefixed emails for fresh testing environment
Loading
Loading