Skip to content

Commit be9feb1

Browse files
authored
BREAKING CHANGE: Add upload image via miltipart
1 parent ef57503 commit be9feb1

20 files changed

+1861
-1019
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ name: CI
22

33
on:
44
pull_request:
5-
branches: [ master ]
5+
branches: [master]
66

77
jobs:
88
build:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v2
13-
14-
- name: Setup Node.js environment
15-
uses: actions/setup-node@v1.4.4
16-
17-
- name: Install npm dependencies
18-
run: npm ci
19-
20-
- name: Unit tests
21-
run: npm run test:cov
22-
23-
- name: Codacy Coverage Reporter
24-
uses: codacy/[email protected]
25-
with:
26-
project-token: ${{ secrets.CODACY_TOKEN }}
12+
- uses: actions/checkout@v2
13+
14+
- name: Setup Node.js environment
15+
uses: actions/setup-node@v2
16+
17+
- name: Install npm dependencies
18+
run: npm ci
19+
20+
- name: Unit tests
21+
run: npm run test:cov
22+
23+
- name: Codacy Coverage Reporter
24+
uses: codacy/[email protected]
25+
with:
26+
project-token: ${{ secrets.CODACY_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fetch-depth: 0
1515

1616
- name: Setup Node.js environment
17-
uses: actions/setup-node@v1.4.4
17+
uses: actions/setup-node@v2
1818

1919
- name: Install dependencies
2020
run: npm ci

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,14 @@ await vrt.track({
104104
name: "Image name",
105105

106106
// Base64 encoded string
107-
// Required
107+
// Required or use imagePath
108108
imageBase64: image,
109109

110-
// Allowed mismatch tollerance in %
110+
// Path to image (service version api:4.14.0 or higher is required)
111+
// Required or use imageBase64
112+
imagePath: image,
113+
114+
// Allowed mismatch % (mismatched pixels to overal pixels count)
111115
// Optional
112116
diffTollerancePercent: 0,
113117

lib/__data__/2.png

80.1 KB
Loading
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`multipartDtoToFormData should return form data 1`] = `
4+
FormData {
5+
"_checkDataSize": [MockFunction],
6+
"_emitError": [MockFunction],
7+
"_error": [MockFunction],
8+
"_generateBoundary": [MockFunction],
9+
"_getContentDisposition": [MockFunction],
10+
"_getContentType": [MockFunction],
11+
"_getNext": [MockFunction],
12+
"_handleErrors": [MockFunction],
13+
"_lastBoundary": [MockFunction],
14+
"_lengthRetriever": [MockFunction],
15+
"_multiPartFooter": [MockFunction],
16+
"_multiPartHeader": [MockFunction],
17+
"_pipeNext": [MockFunction],
18+
"_realGetNext": [MockFunction],
19+
"_reset": [MockFunction],
20+
"_trackLength": [MockFunction],
21+
"_updateDataSize": [MockFunction],
22+
"addListener": [MockFunction],
23+
"append": [MockFunction] {
24+
"calls": Array [
25+
Array [
26+
"buildId",
27+
"buildId",
28+
],
29+
Array [
30+
"projectId",
31+
"projectId",
32+
],
33+
Array [
34+
"branchName",
35+
"develop",
36+
],
37+
Array [
38+
"name",
39+
"name",
40+
],
41+
Array [
42+
"image",
43+
"mocked Image",
44+
Object {
45+
"knownLength": 1234,
46+
},
47+
],
48+
Array [
49+
"os",
50+
"os",
51+
],
52+
Array [
53+
"browser",
54+
"browser",
55+
],
56+
Array [
57+
"viewport",
58+
"viewport",
59+
],
60+
Array [
61+
"device",
62+
"device",
63+
],
64+
Array [
65+
"ignoreAreas",
66+
"[{\\"x\\":1,\\"y\\":2,\\"height\\":300,\\"width\\":400}]",
67+
],
68+
Array [
69+
"diffTollerancePercent",
70+
0.123,
71+
],
72+
],
73+
"results": Array [
74+
Object {
75+
"type": "return",
76+
"value": undefined,
77+
},
78+
Object {
79+
"type": "return",
80+
"value": undefined,
81+
},
82+
Object {
83+
"type": "return",
84+
"value": undefined,
85+
},
86+
Object {
87+
"type": "return",
88+
"value": undefined,
89+
},
90+
Object {
91+
"type": "return",
92+
"value": undefined,
93+
},
94+
Object {
95+
"type": "return",
96+
"value": undefined,
97+
},
98+
Object {
99+
"type": "return",
100+
"value": undefined,
101+
},
102+
Object {
103+
"type": "return",
104+
"value": undefined,
105+
},
106+
Object {
107+
"type": "return",
108+
"value": undefined,
109+
},
110+
Object {
111+
"type": "return",
112+
"value": undefined,
113+
},
114+
Object {
115+
"type": "return",
116+
"value": undefined,
117+
},
118+
],
119+
},
120+
"destroy": [MockFunction],
121+
"emit": [MockFunction],
122+
"end": [MockFunction],
123+
"eventNames": [MockFunction],
124+
"getBoundary": [MockFunction],
125+
"getBuffer": [MockFunction],
126+
"getHeaders": [MockFunction],
127+
"getLength": [MockFunction],
128+
"getLengthSync": [MockFunction],
129+
"getMaxListeners": [MockFunction],
130+
"hasKnownLength": [MockFunction],
131+
"listenerCount": [MockFunction],
132+
"listeners": [MockFunction],
133+
"once": [MockFunction],
134+
"pause": [MockFunction],
135+
"pipe": [MockFunction],
136+
"prependListener": [MockFunction],
137+
"prependOnceListener": [MockFunction],
138+
"rawListeners": [MockFunction],
139+
"removeAllListeners": [MockFunction],
140+
"removeListener": [MockFunction],
141+
"resume": [MockFunction],
142+
"setBoundary": [MockFunction],
143+
"setMaxListeners": [MockFunction],
144+
"submit": [MockFunction],
145+
"toString": [MockFunction],
146+
"write": [MockFunction],
147+
}
148+
`;
149+
150+
exports[`multipartDtoToFormData should return form data 2`] = `
151+
FormData {
152+
"_checkDataSize": [MockFunction],
153+
"_emitError": [MockFunction],
154+
"_error": [MockFunction],
155+
"_generateBoundary": [MockFunction],
156+
"_getContentDisposition": [MockFunction],
157+
"_getContentType": [MockFunction],
158+
"_getNext": [MockFunction],
159+
"_handleErrors": [MockFunction],
160+
"_lastBoundary": [MockFunction],
161+
"_lengthRetriever": [MockFunction],
162+
"_multiPartFooter": [MockFunction],
163+
"_multiPartHeader": [MockFunction],
164+
"_pipeNext": [MockFunction],
165+
"_realGetNext": [MockFunction],
166+
"_reset": [MockFunction],
167+
"_trackLength": [MockFunction],
168+
"_updateDataSize": [MockFunction],
169+
"addListener": [MockFunction],
170+
"append": [MockFunction] {
171+
"calls": Array [
172+
Array [
173+
"buildId",
174+
"buildId",
175+
],
176+
Array [
177+
"projectId",
178+
"projectId",
179+
],
180+
Array [
181+
"branchName",
182+
"develop",
183+
],
184+
Array [
185+
"name",
186+
"name",
187+
],
188+
Array [
189+
"image",
190+
"mocked Image",
191+
Object {
192+
"knownLength": 1234,
193+
},
194+
],
195+
],
196+
"results": Array [
197+
Object {
198+
"type": "return",
199+
"value": undefined,
200+
},
201+
Object {
202+
"type": "return",
203+
"value": undefined,
204+
},
205+
Object {
206+
"type": "return",
207+
"value": undefined,
208+
},
209+
Object {
210+
"type": "return",
211+
"value": undefined,
212+
},
213+
Object {
214+
"type": "return",
215+
"value": undefined,
216+
},
217+
],
218+
},
219+
"destroy": [MockFunction],
220+
"emit": [MockFunction],
221+
"end": [MockFunction],
222+
"eventNames": [MockFunction],
223+
"getBoundary": [MockFunction],
224+
"getBuffer": [MockFunction],
225+
"getHeaders": [MockFunction],
226+
"getLength": [MockFunction],
227+
"getLengthSync": [MockFunction],
228+
"getMaxListeners": [MockFunction],
229+
"hasKnownLength": [MockFunction],
230+
"listenerCount": [MockFunction],
231+
"listeners": [MockFunction],
232+
"once": [MockFunction],
233+
"pause": [MockFunction],
234+
"pipe": [MockFunction],
235+
"prependListener": [MockFunction],
236+
"prependOnceListener": [MockFunction],
237+
"rawListeners": [MockFunction],
238+
"removeAllListeners": [MockFunction],
239+
"removeListener": [MockFunction],
240+
"resume": [MockFunction],
241+
"setBoundary": [MockFunction],
242+
"setMaxListeners": [MockFunction],
243+
"submit": [MockFunction],
244+
"toString": [MockFunction],
245+
"write": [MockFunction],
246+
}
247+
`;

lib/helpers/config.helper.spec.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,48 +112,36 @@ describe("config.helper", () => {
112112
});
113113
});
114114
describe("validateConfig", () => {
115+
it("valid", () => {
116+
expect(() => validateConfig(initialConfig)).not.toThrowError();
117+
});
118+
115119
it.each([
116120
[
117121
{
122+
...initialConfig,
118123
apiUrl: "",
119-
branchName: "develop",
120-
project: "Default project",
121-
apiKey: "CPKVK4JNK24NVNPNGVFQ853HXXEG",
122-
enableSoftAssert: false,
123-
ciBuildId: "someCIBuildId",
124124
},
125125
"apiUrl is not specified",
126126
],
127127
[
128128
{
129-
apiUrl: "http://localhost:4200",
129+
...initialConfig,
130130
branchName: "",
131-
project: "Default project",
132-
apiKey: "CPKVK4JNK24NVNPNGVFQ853HXXEG",
133-
enableSoftAssert: false,
134-
ciBuildId: "someCIBuildId",
135131
},
136132
"branchName is not specified",
137133
],
138134
[
139135
{
140-
apiUrl: "http://localhost:4200",
141-
branchName: "master",
136+
...initialConfig,
142137
project: "",
143-
apiKey: "CPKVK4JNK24NVNPNGVFQ853HXXEG",
144-
enableSoftAssert: false,
145-
ciBuildId: "someCIBuildId",
146138
},
147139
"project is not specified",
148140
],
149141
[
150142
{
151-
apiUrl: "http://localhost:4200",
152-
branchName: "master",
153-
project: "project",
143+
...initialConfig,
154144
apiKey: "",
155-
enableSoftAssert: false,
156-
ciBuildId: "someCIBuildId",
157145
},
158146
"apiKey is not specified",
159147
],

0 commit comments

Comments
 (0)