Skip to content

Commit

Permalink
build: Release (#2021)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Sep 15, 2023
2 parents 98674f0 + ac42cb0 commit 37c7de1
Show file tree
Hide file tree
Showing 17 changed files with 1,927 additions and 2,064 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"jsdoc/require-param-description": 0,
"jsdoc/require-property-description": 0,
"jsdoc/require-param-type": 0,
"jsdoc/tag-lines": 0,
"jsdoc/check-param-names": [
"error",
{
Expand Down
73 changes: 0 additions & 73 deletions .github/workflows/release-automated-scheduler.yml

This file was deleted.

35 changes: 35 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# [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)


### Features

* 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))

# [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)


### Features

* 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))

# [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)


### Bug Fixes

* `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))

# [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)


### Bug Fixes

* `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))
* 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))
* 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))

### Features

* `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))
* 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))

# [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)


Expand Down
12 changes: 12 additions & 0 deletions changelogs/CHANGELOG_beta.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [4.2.0-beta.1](https://github.com/parse-community/Parse-SDK-JS/compare/4.1.0...4.2.0-beta.1) (2023-05-01)


### Bug Fixes

* `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))

### Features

* 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))
* 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))

# [4.1.0-beta.1](https://github.com/parse-community/Parse-SDK-JS/compare/4.0.1...4.1.0-beta.1) (2023-03-01)


Expand Down
29 changes: 17 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const FULL_HEADER = (
' */\n'
);

gulp.task('compile', function() {
return gulp.src('src/*.js')
function compileTask(stream) {
return stream
.pipe(babel({
presets: PRESETS[BUILD],
plugins: PLUGINS[BUILD],
Expand All @@ -76,6 +76,10 @@ gulp.task('compile', function() {
plugins: ['minify-dead-code-elimination'],
}))
.pipe(gulp.dest(path.join('lib', BUILD)));
}

gulp.task('compile', function() {
return compileTask(gulp.src('src/*.js'));
});

gulp.task('browserify', function(cb) {
Expand Down Expand Up @@ -132,14 +136,15 @@ gulp.task('minify-weapp', function() {
});

gulp.task('watch', function() {
return watch('src/*.js', { ignoreInitial: false, verbose: true })
.pipe(babel({
presets: PRESETS[BUILD],
plugins: PLUGINS[BUILD],
}))
// Second pass to kill BUILD-switched code
.pipe(babel({
plugins: ['minify-dead-code-elimination'],
}))
.pipe(gulp.dest(path.join('lib', BUILD)));
if (BUILD === 'browser') {
const watcher = gulp.watch('src/*.js', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify'));
watcher.on('add', function(path) {
console.log(`File ${path} was added`);
});
watcher.on('change', function(path) {
console.log(`File ${path} was changed`);
});
return watcher;
}
return compileTask(watch('src/*.js', { ignoreInitial: false, verbose: true }));
});
46 changes: 44 additions & 2 deletions integration/test/ParseDistTest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const puppeteer = require('puppeteer');
const { resolvingPromise } = require('../../lib/node/promiseUtils');

let browser = null;
let page = null;
for (const fileName of ['parse.js', 'parse.min.js']) {
describe(`Parse Dist Test ${fileName}`, () => {
beforeEach(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
browser = await puppeteer.launch({ args: ['--disable-web-security'] });
const context = await browser.createIncognitoBrowserContext();
page = await context.newPage();
await page.setCacheEnabled(false);
await page.goto(`http://localhost:1337/${fileName}`);
});

Expand Down Expand Up @@ -35,5 +39,43 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
expect(obj).toBeDefined();
expect(obj.id).toEqual(response);
});

it('can cancel save file with uri', async () => {
let requestsCount = 0;
let abortedCount = 0;
const promise = resolvingPromise();
await page.setRequestInterception(true);
page.on('request', request => {
if (!request.url().includes('favicon.ico')) {
requestsCount += 1;
}
request.continue();
});
page.on('requestfailed', request => {
if (request.failure().errorText === 'net::ERR_ABORTED' && !request.url().includes('favicon.ico')) {
abortedCount += 1;
promise.resolve();
}
});
await page.evaluate(async () => {
const parseLogo =
'https://raw.githubusercontent.com/parse-community/parse-server/master/.github/parse-server-logo.png';
const file = new Parse.File('parse-server-logo', { uri: parseLogo });
file.save().then(() => {});

return new Promise((resolve) => {
const intervalId = setInterval(() => {
if (file._requestTask && typeof file._requestTask.abort === 'function') {
file.cancel();
clearInterval(intervalId);
resolve();
}
}, 1);
});
});
await promise;
expect(requestsCount).toBe(1);
expect(abortedCount).toBe(1);
});
});
}
42 changes: 40 additions & 2 deletions integration/test/ParseLiveQueryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Parse LiveQuery', () => {
query.equalTo('objectId', object.id);
const subscription = await client.subscribe(query);
const promise = resolvingPromise();
subscription.on('update', async (object) => {
subscription.on('update', async object => {
assert.equal(object.get('foo'), 'bar');
await client.close();
promise.resolve();
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Parse LiveQuery', () => {
subscription.on('update', async object => {
assert.equal(object.get('foo'), 'bar');
await Parse.User.logOut();
promise.resolve()
promise.resolve();
});
await object.save({ foo: 'bar' });
await promise;
Expand Down Expand Up @@ -276,6 +276,44 @@ describe('Parse LiveQuery', () => {
await promise;
});

it('can subscribe to query with watch', async () => {
const query = new Parse.Query(TestObject);
query.watch('yolo');
const subscription = await query.subscribe();
const spy = {
create(obj) {
if (!obj.get('yolo')) {
fail('create should not have been called');
}
},
update(object, original) {
if (object.get('yolo') === original.get('yolo')) {
fail('create should not have been called');
}
},
};
const createSpy = spyOn(spy, 'create').and.callThrough();
const updateSpy = spyOn(spy, 'update').and.callThrough();
subscription.on('create', spy.create);
subscription.on('update', spy.update);
const obj = new TestObject();
obj.set('foo', 'bar');
await obj.save();
obj.set('foo', 'xyz');
obj.set('yolo', 'xyz');
await obj.save();
const obj2 = new TestObject();
obj2.set('foo', 'bar');
obj2.set('yolo', 'bar');
await obj2.save();
obj2.set('foo', 'bart');
await obj2.save();
await sleep(1000);
await subscription.unsubscribe();
expect(createSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledTimes(1);
});

it('live query can handle beforeConnect and beforeSubscribe errors', async () => {
await reconfigureServer({
cloud({ Cloud }) {
Expand Down
31 changes: 31 additions & 0 deletions integration/test/ParseUserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ describe('Parse User', () => {
expect(sessions[1].get('sessionToken')).toBe(installationUser.getSessionToken());
});

it('can login with userId', async () => {
Parse.User.enableUnsafeCurrentUser();

const user = await Parse.User.signUp('parsetest', 'parse', { code: 'red' });
assert.equal(Parse.User.current(), user);
await Parse.User.logOut();
assert(!Parse.User.current());

const newUser = await Parse.User.loginAs(user.id);
assert.equal(Parse.User.current(), newUser);
assert(newUser);
assert.equal(user.id, newUser.id);
assert.equal(user.get('code'), 'red');

await Parse.User.logOut();
assert(!Parse.User.current());
await expectAsync(Parse.User.loginAs('garbage')).toBeRejectedWithError(
'user not found'
);
});

it('can become a user', done => {
Parse.User.enableUnsafeCurrentUser();
let session = null;
Expand Down Expand Up @@ -782,6 +803,16 @@ describe('Parse User', () => {
expect(user.doSomething()).toBe(5);
});

it('can loginAs user with subclass static', async () => {
Parse.User.enableUnsafeCurrentUser();

let user = await CustomUser.signUp('username', 'password');

user = await CustomUser.loginAs(user.id);
expect(user instanceof CustomUser).toBe(true);
expect(user.doSomething()).toBe(5);
});

it('can get user (me) with subclass static', async () => {
Parse.User.enableUnsafeCurrentUser();

Expand Down
Loading

0 comments on commit 37c7de1

Please sign in to comment.