Skip to content

Commit 8f2eb47

Browse files
committed
chore: update testing setup and component configurations
- Refactor .gitignore to include Playwright test results and reports. - Update package-lock.json and package.json to reflect version changes and add Playwright dependencies. - Introduce Playwright configuration and testing scripts in test-app. - Add comprehensive end-to-end tests for IKImage and IKVideo components, covering rendering, transformations, and responsive behavior. - Create integration and transformation tests to validate component functionality and URL handling. - Enhance app.component.html with updated attributes for testing purposes.
1 parent ea79e34 commit 8f2eb47

16 files changed

Lines changed: 1071 additions & 52 deletions

.github/workflows/e2e.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This is a test workflow for testing the tests
2+
name: E2E Tests
3+
4+
on:
5+
push:
6+
branches: ['*']
7+
pull_request:
8+
branches: ['*']
9+
10+
jobs:
11+
playwright-run:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
project: ['Desktop Chrome', 'Desktop Firefox', 'Desktop Safari']
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '18'
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Build SDK
32+
run: npm run build
33+
34+
- name: Install test app dependencies
35+
working-directory: ./test-app
36+
run: npm ci
37+
38+
- name: Install Playwright browsers
39+
working-directory: ./test-app
40+
run: npx playwright install --with-deps
41+
42+
- name: Run Playwright tests
43+
working-directory: ./test-app
44+
run: npx playwright test --project="${{ matrix.project }}"
45+
46+
- name: Upload test results on failure
47+
if: failure()
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: playwright-results-${{ matrix.project }}
51+
path: test-app/test-results/
52+
if-no-files-found: ignore
53+
54+
- name: Upload Playwright report
55+
if: always()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: playwright-report-${{ matrix.project }}
59+
path: test-app/playwright-report/
60+
retention-days: 30
61+
if-no-files-found: ignore
62+
63+
- name: Generate test report
64+
if: always()
65+
run: |
66+
echo "## Test Results - ${{ matrix.project }}" >> $GITHUB_STEP_SUMMARY
67+
echo "Project: ${{ matrix.project }}" >> $GITHUB_STEP_SUMMARY
68+
69+

.gitignore

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ testem.log
4444
.DS_Store
4545
Thumbs.db
4646

47-
# Environment files
48-
.env
49-
.env.local
50-
.env.*.local
47+
# Playwright
48+
/test-app/test-results/
49+
/test-app/playwright-report/
50+
/test-app/playwright/.cache/
5151

5252
# Logs
5353
*.log
@@ -60,3 +60,8 @@ logs/
6060
# Test coverage
6161
coverage/
6262
.nyc_output/
63+
64+
# Environment files
65+
.env
66+
.env.local
67+
.env.*.local

TESTING.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Testing Guide
2+
3+
This document provides an overview of testing in the ImageKit Angular SDK.
4+
5+
## Test Framework
6+
7+
The SDK uses **Playwright** for end-to-end testing.
8+
9+
## Quick Start
10+
11+
### Install Dependencies
12+
13+
```bash
14+
# Install root dependencies
15+
npm install
16+
17+
# Install test app dependencies
18+
cd test-app
19+
npm install
20+
21+
# Install Playwright browsers
22+
npx playwright install
23+
```
24+
25+
### Run Tests
26+
27+
```bash
28+
# From root directory
29+
npm run test:e2e # Run all tests headless
30+
npm run test:e2e:ui # Open interactive UI
31+
npm run test:e2e:headed # Run with visible browser
32+
33+
# From test-app directory
34+
cd test-app
35+
npm run test:e2e # Run all tests
36+
npm run test:e2e:ui # Open interactive UI
37+
npm run test:e2e:headed # Run with visible browser
38+
```
39+
40+
## Test Structure
41+
42+
```
43+
test-app/
44+
├── e2e/
45+
│ ├── ik-image.spec.ts # IKImage component tests
46+
│ ├── ik-video.spec.ts # IKVideo component tests
47+
│ ├── transformations.spec.ts # URL transformation tests
48+
│ ├── integration.spec.ts # Integration tests
49+
│ └── README.md # Detailed E2E testing guide
50+
└── playwright.config.ts # Playwright configuration
51+
```
52+
53+
54+
## Debugging Tests
55+
56+
### UI Mode (Recommended)
57+
```bash
58+
npm run test:e2e:ui
59+
```
60+
61+
### Debug Mode
62+
```bash
63+
cd test-app
64+
npx playwright test --debug
65+
```
66+
67+
### Headed Mode
68+
```bash
69+
npm run test:e2e:headed
70+
```
71+
72+
### Specific Test File
73+
```bash
74+
cd test-app
75+
npx playwright test ik-image.spec.ts
76+
```
77+
78+
### Specific Browser
79+
```bash
80+
cd test-app
81+
npx playwright test --project="Desktop Chrome"
82+
```
83+
84+
## Test Reports
85+
86+
After running tests, view the HTML report:
87+
88+
```bash
89+
cd test-app
90+
npx playwright show-report
91+
```
92+
## Getting Help
93+
94+
- Check existing test files for examples
95+
- Review [Playwright documentation](https://playwright.dev/)
96+
97+

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
"postbuild": "cp README.md dist/imagekit-angular/ && cp LICENSE dist/imagekit-angular/",
1111
"watch": "ng build imagekit-angular --watch",
1212
"test": "ng test imagekit-angular",
13-
"pack": "npm run build && cd dist/imagekit-angular && npm pack"
13+
"pack": "npm run build && cd dist/imagekit-angular && npm pack",
14+
"start:test-app": "cd test-app && npm start",
15+
"test:e2e": "cd test-app && npm run test:e2e",
16+
"test:e2e:ui": "cd test-app && npm run test:e2e:ui",
17+
"test:e2e:headed": "cd test-app && npm run test:e2e:headed",
18+
"test:e2e:ci": "cd test-app && npm run test:e2e",
19+
"testapp" : "cd test-app && npm start"
1420
},
1521
"private": true,
1622
"dependencies": {
@@ -24,6 +30,7 @@
2430
"@angular/cli": "^17.0.0",
2531
"@angular/compiler": "^17.0.0",
2632
"@angular/compiler-cli": "^17.0.0",
33+
"@types/http-proxy": "^1.17.17",
2734
"ng-packagr": "^17.0.0",
2835
"typescript": "~5.2.2"
2936
}

projects/imagekit-angular/src/lib/components/ik-image.component.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@ import { getInt, validateUrlEndpoint, getTransformationConfig } from '../utils/c
6666
`
6767
})
6868
export class IKImageComponent implements OnChanges, AfterViewInit {
69-
@Input() src: string = '';
69+
@Input() src: IKImageProps['src'] = '';
7070
@Input() urlEndpoint?: string;
71-
@Input() transformation?: Array<Record<string, any>>;
72-
@Input() queryParameters?: Record<string, string | number>;
73-
@Input() transformationPosition?: 'path' | 'query';
74-
@Input() responsive: boolean = true;
75-
@Input() width?: number | string;
76-
@Input() height?: number | string;
77-
@Input() alt?: string;
78-
@Input() loading?: 'lazy' | 'eager';
79-
@Input() className?: string;
80-
@Input() style?: Record<string, string>;
81-
@Input() sizes?: string;
82-
@Input() deviceBreakpoints?: number[];
83-
@Input() imageBreakpoints?: number[];
84-
@Input() passthrough?: Record<string, any> | null;
71+
@Input() transformation?: IKImageProps['transformation'];
72+
@Input() queryParameters?: IKImageProps['queryParameters'];
73+
@Input() transformationPosition?: IKImageProps['transformationPosition'];
74+
@Input() responsive: IKImageProps['responsive'] = true;
75+
@Input() width?: IKImageProps['width'];
76+
@Input() height?: IKImageProps['height'];
77+
@Input() alt?: IKImageProps['alt'];
78+
@Input() loading?: IKImageProps['loading'];
79+
@Input() className?: IKImageProps['className'];
80+
@Input() style?: IKImageProps['style'];
81+
@Input() sizes?: IKImageProps['sizes'];
82+
@Input() deviceBreakpoints?: IKImageProps['deviceBreakpoints'];
83+
@Input() imageBreakpoints?: IKImageProps['imageBreakpoints'];
84+
@Input() passthrough?: IKImageProps['passthrough'];
8585

8686
@ViewChild(BindDirective, { static: false }) bindDirective?: BindDirective;
8787

projects/imagekit-angular/src/lib/components/ik-video.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,24 @@ import { validateUrlEndpoint, getTransformationConfig } from '../utils/common.ut
7070
`
7171
})
7272
export class IKVideoComponent implements OnChanges, AfterViewInit {
73-
@Input() src: string = '';
73+
@Input() src: IKVideoProps['src'] = '';
7474
@Input() urlEndpoint?: string;
75-
@Input() transformation?: Array<Record<string, any>>;
76-
@Input() queryParameters?: Record<string, string | number>;
77-
@Input() transformationPosition?: 'path' | 'query';
78-
@Input() className?: string;
79-
@Input() style?: Record<string, string>;
80-
@Input() title?: string;
81-
@Input() controls?: boolean;
82-
@Input() autoplay?: boolean;
83-
@Input() loop?: boolean;
84-
@Input() muted?: boolean;
85-
@Input() playsinline?: boolean;
86-
@Input() preload?: string;
87-
@Input() width?: number | string;
88-
@Input() height?: number | string;
89-
@Input() poster?: string;
90-
@Input() passthrough?: Record<string, any> | null;
75+
@Input() transformation?: IKVideoProps['transformation'];
76+
@Input() queryParameters?: IKVideoProps['queryParameters'];
77+
@Input() transformationPosition?: IKVideoProps['transformationPosition'];
78+
@Input() className?: IKVideoProps['className'];
79+
@Input() style?: IKVideoProps['style'];
80+
@Input() title?: IKVideoProps['title'];
81+
@Input() controls?: IKVideoProps['controls'];
82+
@Input() autoplay?: IKVideoProps['autoplay'];
83+
@Input() loop?: IKVideoProps['loop'];
84+
@Input() muted?: IKVideoProps['muted'];
85+
@Input() playsinline?: IKVideoProps['playsinline'];
86+
@Input() preload?: IKVideoProps['preload'];
87+
@Input() width?: IKVideoProps['width'];
88+
@Input() height?: IKVideoProps['height'];
89+
@Input() poster?: IKVideoProps['poster'];
90+
@Input() passthrough?: IKVideoProps['passthrough'];
9191

9292
@ViewChild(BindDirective, { static: false }) bindDirective?: BindDirective;
9393

projects/imagekit-angular/src/lib/types/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Transformation } from '@imagekit/javascript';
2+
13
/**
24
* Re-export types from @imagekit/javascript for convenience
35
*/
@@ -40,7 +42,7 @@ export interface IKSrcProps {
4042
*
4143
* @see https://imagekit.io/docs/transformations#chained-transformations
4244
*/
43-
transformation?: Array<Record<string, any>>;
45+
transformation?: Array<Transformation> | Array<Record<string, any>>;
4446

4547
/**
4648
* By default, the transformation string is added as a `query` parameter in the URL, e.g., `?tr=w-100,h-100`.

0 commit comments

Comments
 (0)