move stub of integration tests to typescript
parent
fec0ead1de
commit
c12c3b5f64
@ -1,37 +1,42 @@
|
|||||||
/* eslint-disable func-names */
|
/* eslint-disable func-names */
|
||||||
/* eslint-disable import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
const { afterEach, beforeEach, describe, it } = require('mocha');
|
// tslint:disable: await-promise
|
||||||
const common = require('./common');
|
// tslint:disable: no-implicit-dependencies
|
||||||
|
// tslint:disable: no-invalid-this
|
||||||
|
|
||||||
const ConversationPage = require('./page-objects/conversation.page');
|
import { afterEach, beforeEach, describe, it } from 'mocha';
|
||||||
|
import { Common } from './common';
|
||||||
|
import { Application } from 'spectron';
|
||||||
|
|
||||||
|
import ConversationPage from './page-objects/conversation.page';
|
||||||
|
|
||||||
describe('Closed groups', function() {
|
describe('Closed groups', function() {
|
||||||
let app;
|
|
||||||
let app2;
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
this.slow(15000);
|
this.slow(20000);
|
||||||
|
let app: Application;
|
||||||
|
let app2: Application;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await common.killallElectron();
|
await Common.killallElectron();
|
||||||
await common.stopStubSnodeServer();
|
await Common.stopStubSnodeServer();
|
||||||
|
|
||||||
[app, app2] = await common.startAppsAsFriends();
|
[app, app2] = await Common.startAppsAsFriends();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await common.stopApp(app);
|
await Common.stopApp(app);
|
||||||
await common.killallElectron();
|
await Common.killallElectron();
|
||||||
await common.stopStubSnodeServer();
|
await Common.stopStubSnodeServer();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('closedGroup: can create a closed group with a friend and send/receive a message', async () => {
|
it('closedGroup: can create a closed group with a friend and send/receive a message', async () => {
|
||||||
const useSenderKeys = false;
|
const useSenderKeys = false;
|
||||||
|
|
||||||
// create group and add new friend
|
// create group and add new friend
|
||||||
await common.addFriendToNewClosedGroup([app, app2], useSenderKeys);
|
await Common.addFriendToNewClosedGroup([app, app2], useSenderKeys);
|
||||||
|
|
||||||
// send a message from app and validate it is received on app2
|
// send a message from app and validate it is received on app2
|
||||||
const textMessage = common.generateSendMessageText();
|
const textMessage = Common.generateSendMessageText();
|
||||||
await app.client
|
await app.client
|
||||||
.element(ConversationPage.sendMessageTextarea)
|
.element(ConversationPage.sendMessageTextarea)
|
||||||
.setValue(textMessage);
|
.setValue(textMessage);
|
@ -1,22 +1,30 @@
|
|||||||
/* global clearTimeout, dcodeIO, Buffer, TextDecoder, process */
|
import { StringUtils } from '../../../../session/utils';
|
||||||
const nodeFetch = require('node-fetch');
|
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
class StubMessageAPI {
|
class StubMessageAPI {
|
||||||
constructor(ourKey) {
|
public ourKey: string;
|
||||||
|
public baseUrl: string;
|
||||||
|
constructor(ourKey: string) {
|
||||||
this.ourKey = ourKey;
|
this.ourKey = ourKey;
|
||||||
this.baseUrl = 'http://localhost:3000';
|
this.baseUrl = 'http://localhost:3000';
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
async sendMessage(pubKey, data, messageTimeStamp, ttl, options = {}) {
|
public async sendMessage(
|
||||||
|
pubKey: string,
|
||||||
|
data: any,
|
||||||
|
messageTimeStamp: number,
|
||||||
|
ttl: number,
|
||||||
|
options = {}
|
||||||
|
) {
|
||||||
// console.warn('STUBBED message api ', pubKey, ttl);
|
// console.warn('STUBBED message api ', pubKey, ttl);
|
||||||
const post = {
|
const post = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
};
|
};
|
||||||
|
|
||||||
const data64 = dcodeIO.ByteBuffer.wrap(data).toString('base64');
|
const data64 = StringUtils.decode(data, 'base64');
|
||||||
|
await fetch(
|
||||||
await nodeFetch(
|
|
||||||
`${
|
`${
|
||||||
this.baseUrl
|
this.baseUrl
|
||||||
}/messages?pubkey=${pubKey}×tamp=${messageTimeStamp}&data=${encodeURIComponent(
|
}/messages?pubkey=${pubKey}×tamp=${messageTimeStamp}&data=${encodeURIComponent(
|
Loading…
Reference in New Issue