Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion spec/MongoSchemaCollectionAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ describe('MongoSchemaCollection', () => {
"create":{"*":true},
"delete":{"*":true},
"addField":{"*":true},
},
"indexes": {
"name1":{"deviceToken":1}
}
},
"installationId":"string",
Expand Down Expand Up @@ -66,7 +69,10 @@ describe('MongoSchemaCollection', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
}
},
indexes: {
name1: {deviceToken: 1}
},
});
done();
});
Expand Down
94 changes: 61 additions & 33 deletions spec/ParseQuery.FullTextSearch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const fullTextHelper = () => {
const request = {
method: "POST",
body: {
subject: subjects[i]
subject: subjects[i],
comment: subjects[i],
},
path: "/1/classes/TestObject"
};
Expand Down Expand Up @@ -280,42 +281,69 @@ describe('Parse.Query Full Text Search testing', () => {
});

describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
it('fullTextSearch: $search, only one text index', (done) => {
return reconfigureServer({
appId: 'test',
restAPIKey: 'test',
publicServerURL: 'http://localhost:8378/1',
databaseAdapter: new MongoStorageAdapter({ uri: mongoURI })
it('fullTextSearch: does not create text index if compound index exist', (done) => {
fullTextHelper().then(() => {
return databaseAdapter.dropAllIndexes('TestObject');
}).then(() => {
return rp.post({
url: 'http://localhost:8378/1/batch',
body: {
requests: [
{
method: "POST",
body: {
subject: "coffee is java"
},
path: "/1/classes/TestObject"
},
{
method: "POST",
body: {
subject: "java is coffee"
},
path: "/1/classes/TestObject"
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(1);
return databaseAdapter.createIndex('TestObject', {subject: 'text', comment: 'text'});
}).then(() => {
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
const where = {
subject: {
$text: {
$search: {
$term: 'coffee'
}
]
},
json: true,
}
}
};
return rp.post({
url: 'http://localhost:8378/1/classes/TestObject',
json: { where, '_method': 'GET' },
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'test'
}
});
}).then((resp) => {
expect(resp.results.length).toEqual(3);
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
done();
}).catch(done.fail);
});

it('fullTextSearch: does not create text index if schema compound index exist', (done) => {
fullTextHelper().then(() => {
return databaseAdapter.dropAllIndexes('TestObject');
}).then(() => {
return databaseAdapter.createIndex('TestObject', {random: 'text'});
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(1);
return rp.put({
url: 'http://localhost:8378/1/schemas/TestObject',
json: true,
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'test',
'X-Parse-Master-Key': 'test',
},
body: {
indexes: {
text_test: { subject: 'text', comment: 'text'},
},
},
});
}).then(() => {
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
const where = {
subject: {
$text: {
Expand All @@ -334,12 +362,12 @@ describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
}
});
}).then((resp) => {
fail(`Should not be more than one text index: ${JSON.stringify(resp)}`);
done();
}).catch((err) => {
expect(err.error.code).toEqual(Parse.Error.INTERNAL_SERVER_ERROR);
expect(resp.results.length).toEqual(3);
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
done();
});
}).catch(done.fail);
});

it('fullTextSearch: $diacriticSensitive - false', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe('SchemaController', () => {
fooSixteen: {type: 'String'},
fooEighteen: {type: 'String'},
fooNineteen: {type: 'String'},
}, levelPermissions, config.database))
}, levelPermissions, {}, config.database))
.then(actualSchema => {
const expectedSchema = {
className: 'NewClass',
Expand Down
Loading