Skip to content

Commit af32dc9

Browse files
committed
Update
1 parent df369bb commit af32dc9

7 files changed

Lines changed: 85 additions & 41 deletions

File tree

.github/workflows/nodejs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,57 @@ jobs:
2828
PUBLIC_KEY: ${{ secrets.ik_public_key }}
2929
PRIVATE_KEY: ${{ secrets.ik_private_key }}
3030
URL_ENDPOINT: ${{ secrets.ik_url_endopint }}
31+
e2e:
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
node-version: [14.x]
37+
steps:
38+
- uses: actions/checkout@v3
39+
40+
- name: Use Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v1
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
45+
- name: Create e2e environment variables
46+
run: |
47+
cd sdk/src/environments
48+
echo export const environment = { > environment.ts;
49+
echo production: false, >> environment.ts;
50+
echo URL_ENDPOINT:\"https://ik.imagekit.io/sdktestingik\", >> environment.ts;
51+
echo PUBLIC_KEY:\"${{ secrets.ik_public_key }}\", >> environment.ts;
52+
echo AUTHENTICATION_ENDPOINT:\"http://localhost:3000/auth\" >> environment.ts;
53+
echo '};' >> environment.ts;
54+
less environment.ts
55+
56+
- name: Start client server
57+
run: |
58+
cd sdk
59+
npm install
60+
npm start &
61+
- name: Start auth server
62+
run: |
63+
cd samples/sample-server
64+
echo PRIVATE_KEY=${{ secrets.ik_private_key }} >> .env;
65+
npm install
66+
npm run server &
67+
env:
68+
CI: true
69+
PUBLIC_KEY: ${{ secrets.ik_public_key }}
70+
PRIVATE_KEY: ${{ secrets.ik_private_key }}
71+
URL_ENDPOINT: https://ik.imagekit.io/sdktestingik
72+
- name: Run E2E tests
73+
uses: cypress-io/github-action@v5
74+
with:
75+
install: false
76+
wait-on: 'http://localhost:4200'
77+
working-directory: sdk
78+
env:
79+
DEBUG: 'cypress:server:browsers:electron'
80+
CI: true
81+
PUBLIC_KEY: ${{ secrets.ik_public_key }}
82+
PRIVATE_KEY: ${{ secrets.ik_private_key }}
83+
URL_ENDPOINT: https://ik.imagekit.io/sdktestingik
84+
AUTHENTICATION_ENDPOINT: 'http://localhost:3000/auth'

samples/imagekitio-angular-sample/src/app/app.component.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ <h1>Hi! This is an ImageKit Angular SDK Demo!</h1>
8080
<p>To use this funtionality please remember to setup the server</p>
8181
<ik-upload
8282
fileName="test.jpg"
83-
tags='["sample-tag1", "sample-tag2"]'
83+
[tags]='["sample-tag1", "sample-tag2"]'
8484
customCoordinates="10,10,10,10"
8585
[isPrivateFile]="false"
8686
[useUniqueFileName]="true"
87-
responseFields='["tags"]'
87+
[responseFields]='["tags"]'
8888
folder="/sample-folder"
8989
(onError)="handleUploadError($event)"
9090
(onSuccess)="handleUploadSuccess($event)"
@@ -111,4 +111,15 @@ <h1>Hi! This is an ImageKit Angular SDK Demo!</h1>
111111
<p style="color:red" class="upload-error-ik">
112112
{{uploadErrorMessage}}
113113
</p>
114-
</div>
114+
115+
<p>Upload with custom button</p>
116+
<ik-upload
117+
(onSuccess)="handleUploadSuccess($event)"
118+
(onError)="handleUploadError($event)"
119+
[buttonRef] = 'myBtn'
120+
>
121+
</ik-upload>
122+
<button #myBtn type="button" style="color:blue">
123+
<span>Upload</span>
124+
</button>
125+
</div>

sdk/cypress/integration/IKUpload.cy.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,5 @@ describe('ik-upload component', () => {
1818
//Verify uploaded file
1919
cy.get('.uploaded-img-ik').find('img').invoke('attr', 'src').should('contain','/test');
2020
});
21-
22-
it('should upload non-image file and try to get error element', () => {
23-
//static file
24-
const p = 'example.json'
25-
26-
// launch URL
27-
cy.visit(APP_HOST);
28-
29-
//upload file with attachFile
30-
cy.get('.file-upload-error').find('input').attachFile(p)
31-
32-
// wait for 2 secs
33-
cy.wait(2000);
34-
35-
//Verify uploaded file
36-
cy.get('.upload-error-ik').should('contain', 'File upload failed.')
37-
});
3821
});
3922
});

sdk/lib/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"lib": {
1313
"entryFile": "src/public_api.ts"
1414
},
15-
"whitelistedNonPeerDependencies": [
16-
"imagekit-javascript"
17-
],
1815
"dest": "./dist/imagekitio-angular"
1916
}
2017
}

sdk/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"lint": "ng lint",
1313
"postinstall": "./scripts/postinstall.sh",
1414
"build": "rimraf dist && ng-packagr -p lib/package.json && npm run assets",
15-
"assets": "node ./scripts/copy-assets.js"
15+
"assets": "node ./scripts/copy-assets.js",
16+
"serve:test-app": "export SKIP_PREFLIGHT_CHECK=true;ng serve & cd ../samples/sample-server && npm run server"
1617
},
1718
"private": false,
1819
"dependencies": {

sdk/src/app/app.component.html

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ <h1>Hi! This is an ImageKit Angular SDK Demo!</h1>
8080
<p>To use this funtionality please remember to setup the server</p>
8181
<ik-upload
8282
fileName="test.jpg"
83-
tags='["sample-tag1", "sample-tag2"]'
83+
[tags]='["sample-tag1", "sample-tag2"]'
8484
customCoordinates="10,10,10,10"
8585
[isPrivateFile]="false"
86-
[useUniqueFileName]="true"
87-
responseFields='["tags"]'
86+
[responseFields]='["tags"]'
8887
folder="/sample-folder"
8988
(onError)="handleUploadError($event)"
9089
(onSuccess)="handleUploadSuccess($event)"
@@ -99,16 +98,14 @@ <h1>Hi! This is an ImageKit Angular SDK Demo!</h1>
9998
class="uploaded-img-ik">
10099
</ik-image>
101100

102-
<p>Upload invalid file</p>
103-
<ik-upload
104-
class="file-upload-error"
105-
fileName="test-fail.jpg"
106-
folder="/sample-folder"
101+
<p>Upload with custom button</p>
102+
<ik-upload
103+
(onSuccess)="handleUploadSuccess($event)"
107104
(onError)="handleUploadError($event)"
108-
(onSuccess)="handleUploadSuccess($event)">
105+
[buttonRef] = 'myBtn'
106+
>
109107
</ik-upload>
110-
111-
<p style="color:red" class="upload-error-ik">
112-
{{uploadErrorMessage}}
113-
</p>
114-
</div>
108+
<button #myBtn type="button" style="color:blue">
109+
<span>Upload</span>
110+
</button>
111+
</div>

sdk/src/app/app.module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import { NgModule } from "@angular/core";
33

44
import { AppComponent } from "./app.component";
55
import { ImagekitioAngularModule } from "../../lib/src/imagekitio-angular/imagekitio-angular.module";
6+
import { environment } from '../environments/environment';
67

78
@NgModule({
89
declarations: [AppComponent],
910
imports: [
1011
BrowserModule,
1112
ImagekitioAngularModule.forRoot({
12-
urlEndpoint: "your_endpoint",
13-
publicKey: "your_public_key",
14-
authenticationEndpoint: "your_authentication_endpoint"
13+
urlEndpoint: environment.URL_ENDPOINT,
14+
publicKey: environment.PUBLIC_KEY,
15+
authenticationEndpoint: environment.AUTHENTICATION_ENDPOINT
1516
})
1617
],
1718
providers: [],

0 commit comments

Comments
 (0)