|
|
|
@ -21,8 +21,8 @@ chai.use(chaiAsPromised);
|
|
|
|
|
chai.config.includeStack = true;
|
|
|
|
|
|
|
|
|
|
// From https://github.com/chaijs/chai/issues/200
|
|
|
|
|
chai.use(function (_chai, _) {
|
|
|
|
|
_chai.Assertion.addMethod('withMessage', function (msg) {
|
|
|
|
|
chai.use((_chai, _) => {
|
|
|
|
|
_chai.Assertion.addMethod('withMessage', msg => {
|
|
|
|
|
_.flag(this, 'message', msg);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -250,7 +250,6 @@ module.exports = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async makeFriends(app1, client2) {
|
|
|
|
|
|
|
|
|
|
const [app2, pubkey2] = client2;
|
|
|
|
|
|
|
|
|
|
/** add each other as friends */
|
|
|
|
@ -259,11 +258,7 @@ module.exports = {
|
|
|
|
|
await app1.client.element(ConversationPage.contactsButtonSection).click();
|
|
|
|
|
await app1.client.element(ConversationPage.addContactButton).click();
|
|
|
|
|
|
|
|
|
|
await this.setValueWrapper(
|
|
|
|
|
app1,
|
|
|
|
|
ConversationPage.sessionIDInput,
|
|
|
|
|
pubkey2
|
|
|
|
|
);
|
|
|
|
|
await this.setValueWrapper(app1, ConversationPage.sessionIDInput, pubkey2);
|
|
|
|
|
await app1.client.element(ConversationPage.nextButton).click();
|
|
|
|
|
await app1.client.waitForExist(
|
|
|
|
|
ConversationPage.sendFriendRequestTextarea,
|
|
|
|
@ -310,10 +305,6 @@ module.exports = {
|
|
|
|
|
ConversationPage.acceptedFriendRequestMessage,
|
|
|
|
|
5000
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// click away to close the current pane and make further FR possible
|
|
|
|
|
await app1.client.element(ConversationPage.globeButtonSection).click();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async startAppsAsFriends() {
|
|
|
|
@ -340,7 +331,6 @@ module.exports = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async addFriendToNewClosedGroup(members, useSenderKeys) {
|
|
|
|
|
|
|
|
|
|
const [app, ...others] = members;
|
|
|
|
|
|
|
|
|
|
await this.setValueWrapper(
|
|
|
|
@ -348,19 +338,26 @@ module.exports = {
|
|
|
|
|
ConversationPage.closedGroupNameTextarea,
|
|
|
|
|
this.VALID_CLOSED_GROUP_NAME1
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await app.client
|
|
|
|
|
.element(ConversationPage.closedGroupNameTextarea)
|
|
|
|
|
.getValue()
|
|
|
|
|
.should.eventually.equal(this.VALID_CLOSED_GROUP_NAME1);
|
|
|
|
|
|
|
|
|
|
// This assumes that app does not have any other friends
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < others.length; i += 1) {
|
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
|
await app.client
|
|
|
|
|
.element(ConversationPage.createClosedGroupMemberItem)
|
|
|
|
|
.element(ConversationPage.createClosedGroupMemberItem(i))
|
|
|
|
|
.isVisible().should.eventually.be.true;
|
|
|
|
|
|
|
|
|
|
// select the first friend as a member of the groups being created
|
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
|
await app.client
|
|
|
|
|
.element(ConversationPage.createClosedGroupMemberItem)
|
|
|
|
|
.element(ConversationPage.createClosedGroupMemberItem(i))
|
|
|
|
|
.click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await app.client
|
|
|
|
|
.element(ConversationPage.createClosedGroupMemberItemSelected)
|
|
|
|
|
.isVisible().should.eventually.be.true;
|
|
|
|
@ -384,8 +381,9 @@ module.exports = {
|
|
|
|
|
await app.client.isExisting(
|
|
|
|
|
ConversationPage.headerTitleGroupName(this.VALID_CLOSED_GROUP_NAME1)
|
|
|
|
|
).should.eventually.be.true;
|
|
|
|
|
await app.client.element(ConversationPage.headerTitleMembers(2)).isVisible()
|
|
|
|
|
.should.eventually.be.true;
|
|
|
|
|
await app.client
|
|
|
|
|
.element(ConversationPage.headerTitleMembers(members.length))
|
|
|
|
|
.isVisible().should.eventually.be.true;
|
|
|
|
|
|
|
|
|
|
// validate overlay is closed
|
|
|
|
|
await app.client
|
|
|
|
@ -575,6 +573,10 @@ module.exports = {
|
|
|
|
|
app1.webContents.executeJavaScript(
|
|
|
|
|
'window.LokiMessageAPI = window.StubMessageAPI;'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
app1.webContents.executeJavaScript(
|
|
|
|
|
'window.LokiSnodeAPI = window.StubLokiSnodeAPI;'
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
logsContainsString: async (app1, str) => {
|
|
|
|
@ -589,13 +591,24 @@ module.exports = {
|
|
|
|
|
const { query } = url.parse(request.url, true);
|
|
|
|
|
const { pubkey, data, timestamp } = query;
|
|
|
|
|
|
|
|
|
|
if (pubkey) {
|
|
|
|
|
if (!pubkey) {
|
|
|
|
|
console.warn('NO PUBKEY');
|
|
|
|
|
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
|
|
|
response.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (request.method === 'POST') {
|
|
|
|
|
if (ENABLE_LOG) {
|
|
|
|
|
console.warn('POST', [data, timestamp]);
|
|
|
|
|
console.warn(
|
|
|
|
|
'POST',
|
|
|
|
|
pubkey.substr(2, 3),
|
|
|
|
|
data.substr(4, 10),
|
|
|
|
|
timestamp
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let ori = this.messages[pubkey];
|
|
|
|
|
|
|
|
|
|
if (!this.messages[pubkey]) {
|
|
|
|
|
ori = [];
|
|
|
|
|
}
|
|
|
|
@ -605,19 +618,18 @@ module.exports = {
|
|
|
|
|
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
|
|
|
response.end();
|
|
|
|
|
} else {
|
|
|
|
|
const retrievedMessages = { messages: this.messages[pubkey] };
|
|
|
|
|
const retrievedMessages = { messages: this.messages[pubkey] || [] };
|
|
|
|
|
|
|
|
|
|
if (ENABLE_LOG) {
|
|
|
|
|
console.warn('GET', pubkey, retrievedMessages);
|
|
|
|
|
const messages = retrievedMessages.messages.map(m =>
|
|
|
|
|
m.data.substr(4, 10)
|
|
|
|
|
);
|
|
|
|
|
console.warn('GET', pubkey.substr(2, 3), messages);
|
|
|
|
|
}
|
|
|
|
|
if (this.messages[pubkey]) {
|
|
|
|
|
response.writeHead(200, { 'Content-Type': 'application/json' });
|
|
|
|
|
response.write(JSON.stringify(retrievedMessages));
|
|
|
|
|
this.messages[pubkey] = [];
|
|
|
|
|
}
|
|
|
|
|
response.end();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
response.end();
|
|
|
|
|
});
|
|
|
|
|
this.stubSnode.listen(STUB_SNODE_SERVER_PORT);
|
|
|
|
|
} else {
|
|
|
|
|