Skip to content

Commit c4a8eb2

Browse files
authored
build: Release (#1883)
2 parents 98674f0 + cff639b commit c4a8eb2

16 files changed

+1915
-2064
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"jsdoc/require-param-description": 0,
4343
"jsdoc/require-property-description": 0,
4444
"jsdoc/require-param-type": 0,
45+
"jsdoc/tag-lines": 0,
4546
"jsdoc/check-param-names": [
4647
"error",
4748
{

.github/workflows/release-automated-scheduler.yml

-73
This file was deleted.

changelogs/CHANGELOG_alpha.md

+35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
# [4.1.0-alpha.4](https://github.com/parse-community/Parse-SDK-JS/compare/4.1.0-alpha.3...4.1.0-alpha.4) (2023-04-28)
2+
3+
4+
### Features
5+
6+
* Add `Parse.User.loginAs` ([#1875](https://github.com/parse-community/Parse-SDK-JS/issues/1875)) ([381fcfc](https://github.com/parse-community/Parse-SDK-JS/commit/381fcfc7f9cfda70af7c6dc3a35de59b82b72258))
7+
8+
# [4.1.0-alpha.3](https://github.com/parse-community/Parse-SDK-JS/compare/4.1.0-alpha.2...4.1.0-alpha.3) (2023-04-02)
9+
10+
11+
### Features
12+
13+
* Add `ParseQuery.watch` to trigger LiveQuery only on update of specific fields ([#1839](https://github.com/parse-community/Parse-SDK-JS/issues/1839)) ([7479343](https://github.com/parse-community/Parse-SDK-JS/commit/7479343abd8739fe03558ff9b2ce610c34c568ae))
14+
15+
# [4.1.0-alpha.2](https://github.com/parse-community/Parse-SDK-JS/compare/4.1.0-alpha.1...4.1.0-alpha.2) (2023-03-01)
16+
17+
18+
### Bug Fixes
19+
20+
* `Parse.File.cancel` starts new attempt to save file ([#1781](https://github.com/parse-community/Parse-SDK-JS/issues/1781)) ([b755e42](https://github.com/parse-community/Parse-SDK-JS/commit/b755e42394db8b94b87b0dbefc6cf6f18189c46d))
21+
22+
# [4.1.0-alpha.1](https://github.com/parse-community/Parse-SDK-JS/compare/4.0.1...4.1.0-alpha.1) (2023-03-01)
23+
24+
25+
### Bug Fixes
26+
27+
* `LiveQuerySubscription.unsubscribe` resolves promise before unsubscribing completes ([#1727](https://github.com/parse-community/Parse-SDK-JS/issues/1727)) ([1c96205](https://github.com/parse-community/Parse-SDK-JS/commit/1c96205cb3c162b21bf4508f7783400a28a99868))
28+
* Node engine version upper range is <19 despite Node 19 support ([#1732](https://github.com/parse-community/Parse-SDK-JS/issues/1732)) ([febe187](https://github.com/parse-community/Parse-SDK-JS/commit/febe187a24fb56e83542c00ae39148575fc57c4b))
29+
* Saving a new `Parse.Object` with an unsaved `Parse.File` fails ([#1662](https://github.com/parse-community/Parse-SDK-JS/issues/1662)) ([16535a4](https://github.com/parse-community/Parse-SDK-JS/commit/16535a43f6c762983460aa837102a4c692de70bb))
30+
31+
### Features
32+
33+
* `LiveQueryClient.close` returns promise when WebSocket closes ([#1735](https://github.com/parse-community/Parse-SDK-JS/issues/1735)) ([979d660](https://github.com/parse-community/Parse-SDK-JS/commit/979d6607d5449dd3d3c5e51f36119bd05b25feaa))
34+
* Upgrade Node Package Manager lock file `package-lock.json` to version 2 ([#1729](https://github.com/parse-community/Parse-SDK-JS/issues/1729)) ([e993786](https://github.com/parse-community/Parse-SDK-JS/commit/e993786cf0299b1150bf36afee1bc516e23e349a))
35+
136
# [4.0.0-alpha.12](https://github.com/parse-community/Parse-SDK-JS/compare/4.0.0-alpha.11...4.0.0-alpha.12) (2023-02-06)
237

338

gulpfile.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ const FULL_HEADER = (
6565
' */\n'
6666
);
6767

68-
gulp.task('compile', function() {
69-
return gulp.src('src/*.js')
68+
function compileTask(stream) {
69+
return stream
7070
.pipe(babel({
7171
presets: PRESETS[BUILD],
7272
plugins: PLUGINS[BUILD],
@@ -76,6 +76,10 @@ gulp.task('compile', function() {
7676
plugins: ['minify-dead-code-elimination'],
7777
}))
7878
.pipe(gulp.dest(path.join('lib', BUILD)));
79+
}
80+
81+
gulp.task('compile', function() {
82+
return compileTask(gulp.src('src/*.js'));
7983
});
8084

8185
gulp.task('browserify', function(cb) {
@@ -132,14 +136,15 @@ gulp.task('minify-weapp', function() {
132136
});
133137

134138
gulp.task('watch', function() {
135-
return watch('src/*.js', { ignoreInitial: false, verbose: true })
136-
.pipe(babel({
137-
presets: PRESETS[BUILD],
138-
plugins: PLUGINS[BUILD],
139-
}))
140-
// Second pass to kill BUILD-switched code
141-
.pipe(babel({
142-
plugins: ['minify-dead-code-elimination'],
143-
}))
144-
.pipe(gulp.dest(path.join('lib', BUILD)));
139+
if (BUILD === 'browser') {
140+
const watcher = gulp.watch('src/*.js', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify'));
141+
watcher.on('add', function(path) {
142+
console.log(`File ${path} was added`);
143+
});
144+
watcher.on('change', function(path) {
145+
console.log(`File ${path} was changed`);
146+
});
147+
return watcher;
148+
}
149+
return compileTask(watch('src/*.js', { ignoreInitial: false, verbose: true }));
145150
});

integration/test/ParseDistTest.js

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const puppeteer = require('puppeteer');
2+
const { resolvingPromise } = require('../../lib/node/promiseUtils');
3+
24
let browser = null;
35
let page = null;
46
for (const fileName of ['parse.js', 'parse.min.js']) {
57
describe(`Parse Dist Test ${fileName}`, () => {
68
beforeEach(async () => {
7-
browser = await puppeteer.launch();
8-
page = await browser.newPage();
9+
browser = await puppeteer.launch({ args: ['--disable-web-security'] });
10+
const context = await browser.createIncognitoBrowserContext();
11+
page = await context.newPage();
12+
await page.setCacheEnabled(false);
913
await page.goto(`http://localhost:1337/${fileName}`);
1014
});
1115

@@ -35,5 +39,43 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
3539
expect(obj).toBeDefined();
3640
expect(obj.id).toEqual(response);
3741
});
42+
43+
it('can cancel save file with uri', async () => {
44+
let requestsCount = 0;
45+
let abortedCount = 0;
46+
const promise = resolvingPromise();
47+
await page.setRequestInterception(true);
48+
page.on('request', request => {
49+
if (!request.url().includes('favicon.ico')) {
50+
requestsCount += 1;
51+
}
52+
request.continue();
53+
});
54+
page.on('requestfailed', request => {
55+
if (request.failure().errorText === 'net::ERR_ABORTED' && !request.url().includes('favicon.ico')) {
56+
abortedCount += 1;
57+
promise.resolve();
58+
}
59+
});
60+
await page.evaluate(async () => {
61+
const parseLogo =
62+
'https://raw.githubusercontent.com/parse-community/parse-server/master/.github/parse-server-logo.png';
63+
const file = new Parse.File('parse-server-logo', { uri: parseLogo });
64+
file.save().then(() => {});
65+
66+
return new Promise((resolve) => {
67+
const intervalId = setInterval(() => {
68+
if (file._requestTask && typeof file._requestTask.abort === 'function') {
69+
file.cancel();
70+
clearInterval(intervalId);
71+
resolve();
72+
}
73+
}, 1);
74+
});
75+
});
76+
await promise;
77+
expect(requestsCount).toBe(1);
78+
expect(abortedCount).toBe(1);
79+
});
3880
});
3981
}

integration/test/ParseLiveQueryTest.js

+40-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Parse LiveQuery', () => {
7676
query.equalTo('objectId', object.id);
7777
const subscription = await client.subscribe(query);
7878
const promise = resolvingPromise();
79-
subscription.on('update', async (object) => {
79+
subscription.on('update', async object => {
8080
assert.equal(object.get('foo'), 'bar');
8181
await client.close();
8282
promise.resolve();
@@ -206,7 +206,7 @@ describe('Parse LiveQuery', () => {
206206
subscription.on('update', async object => {
207207
assert.equal(object.get('foo'), 'bar');
208208
await Parse.User.logOut();
209-
promise.resolve()
209+
promise.resolve();
210210
});
211211
await object.save({ foo: 'bar' });
212212
await promise;
@@ -276,6 +276,44 @@ describe('Parse LiveQuery', () => {
276276
await promise;
277277
});
278278

279+
it('can subscribe to query with watch', async () => {
280+
const query = new Parse.Query(TestObject);
281+
query.watch('yolo');
282+
const subscription = await query.subscribe();
283+
const spy = {
284+
create(obj) {
285+
if (!obj.get('yolo')) {
286+
fail('create should not have been called');
287+
}
288+
},
289+
update(object, original) {
290+
if (object.get('yolo') === original.get('yolo')) {
291+
fail('create should not have been called');
292+
}
293+
},
294+
};
295+
const createSpy = spyOn(spy, 'create').and.callThrough();
296+
const updateSpy = spyOn(spy, 'update').and.callThrough();
297+
subscription.on('create', spy.create);
298+
subscription.on('update', spy.update);
299+
const obj = new TestObject();
300+
obj.set('foo', 'bar');
301+
await obj.save();
302+
obj.set('foo', 'xyz');
303+
obj.set('yolo', 'xyz');
304+
await obj.save();
305+
const obj2 = new TestObject();
306+
obj2.set('foo', 'bar');
307+
obj2.set('yolo', 'bar');
308+
await obj2.save();
309+
obj2.set('foo', 'bart');
310+
await obj2.save();
311+
await sleep(1000);
312+
await subscription.unsubscribe();
313+
expect(createSpy).toHaveBeenCalledTimes(1);
314+
expect(updateSpy).toHaveBeenCalledTimes(1);
315+
});
316+
279317
it('live query can handle beforeConnect and beforeSubscribe errors', async () => {
280318
await reconfigureServer({
281319
cloud({ Cloud }) {

integration/test/ParseUserTest.js

+31
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,27 @@ describe('Parse User', () => {
148148
expect(sessions[1].get('sessionToken')).toBe(installationUser.getSessionToken());
149149
});
150150

151+
it('can login with userId', async () => {
152+
Parse.User.enableUnsafeCurrentUser();
153+
154+
const user = await Parse.User.signUp('parsetest', 'parse', { code: 'red' });
155+
assert.equal(Parse.User.current(), user);
156+
await Parse.User.logOut();
157+
assert(!Parse.User.current());
158+
159+
const newUser = await Parse.User.loginAs(user.id);
160+
assert.equal(Parse.User.current(), newUser);
161+
assert(newUser);
162+
assert.equal(user.id, newUser.id);
163+
assert.equal(user.get('code'), 'red');
164+
165+
await Parse.User.logOut();
166+
assert(!Parse.User.current());
167+
await expectAsync(Parse.User.loginAs('garbage')).toBeRejectedWithError(
168+
'user not found'
169+
);
170+
});
171+
151172
it('can become a user', done => {
152173
Parse.User.enableUnsafeCurrentUser();
153174
let session = null;
@@ -782,6 +803,16 @@ describe('Parse User', () => {
782803
expect(user.doSomething()).toBe(5);
783804
});
784805

806+
it('can loginAs user with subclass static', async () => {
807+
Parse.User.enableUnsafeCurrentUser();
808+
809+
let user = await CustomUser.signUp('username', 'password');
810+
811+
user = await CustomUser.loginAs(user.id);
812+
expect(user instanceof CustomUser).toBe(true);
813+
expect(user.doSomething()).toBe(5);
814+
});
815+
785816
it('can get user (me) with subclass static', async () => {
786817
Parse.User.enableUnsafeCurrentUser();
787818

0 commit comments

Comments
 (0)