GlobalSetup workaround
This commit is contained in:
parent
6e3f4aa6fb
commit
b2204619e8
100
e2e/data.ts
100
e2e/data.ts
|
@ -1,5 +1,3 @@
|
||||||
/* eslint-disable import/extensions, import/no-unresolved */
|
|
||||||
import random from './helpers/random';
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import account from './e2e_account';
|
import account from './e2e_account';
|
||||||
|
|
||||||
|
@ -17,7 +15,7 @@ export type TUserRegularChannels = keyof typeof data.userRegularChannels;
|
||||||
export type TDataGroups = keyof typeof data.groups;
|
export type TDataGroups = keyof typeof data.groups;
|
||||||
export type TDataTeams = keyof typeof data.teams;
|
export type TDataTeams = keyof typeof data.teams;
|
||||||
|
|
||||||
const value: string = random(20);
|
const value = globalThis.random;
|
||||||
const data = {
|
const data = {
|
||||||
server: 'https://mobile.rocket.chat',
|
server: 'https://mobile.rocket.chat',
|
||||||
...account,
|
...account,
|
||||||
|
@ -98,4 +96,100 @@ const data = {
|
||||||
random: value
|
random: value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: awkward TEMP workaround :(
|
||||||
|
class Data {
|
||||||
|
adminUser!: string;
|
||||||
|
adminPassword!: string;
|
||||||
|
server: string;
|
||||||
|
alternateServer: string;
|
||||||
|
users: any;
|
||||||
|
channels: any;
|
||||||
|
userRegularChannels: any;
|
||||||
|
groups: any;
|
||||||
|
teams: any;
|
||||||
|
registeringUser: any;
|
||||||
|
random: string;
|
||||||
|
constructor(random: string) {
|
||||||
|
const value = random;
|
||||||
|
Object.assign(this, account);
|
||||||
|
this.server = 'https://mobile.rocket.chat';
|
||||||
|
this.alternateServer = 'https://stable.rocket.chat';
|
||||||
|
this.users = {
|
||||||
|
regular: {
|
||||||
|
username: `userone${value}`,
|
||||||
|
password: '123',
|
||||||
|
email: `mobile+regular${value}@rocket.chat`
|
||||||
|
},
|
||||||
|
alternate: {
|
||||||
|
username: `usertwo${value}`,
|
||||||
|
password: '123',
|
||||||
|
email: `mobile+alternate${value}@rocket.chat`,
|
||||||
|
totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ'
|
||||||
|
},
|
||||||
|
profileChanges: {
|
||||||
|
username: `userthree${value}`,
|
||||||
|
password: '123',
|
||||||
|
email: `mobile+profileChanges${value}@rocket.chat`
|
||||||
|
},
|
||||||
|
existing: {
|
||||||
|
username: `existinguser${value}`,
|
||||||
|
password: '123',
|
||||||
|
email: `mobile+existing${value}@rocket.chat`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.channels = {
|
||||||
|
detoxpublic: {
|
||||||
|
name: 'detox-public'
|
||||||
|
},
|
||||||
|
detoxpublicprotected: {
|
||||||
|
name: 'detox-public-protected',
|
||||||
|
joinCode: '123'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.userRegularChannels = {
|
||||||
|
detoxpublic: {
|
||||||
|
name: `detox-public-${value}`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.groups = {
|
||||||
|
private: {
|
||||||
|
name: `detox-private-${value}`
|
||||||
|
},
|
||||||
|
alternate: {
|
||||||
|
name: `detox-alternate-${value}`
|
||||||
|
},
|
||||||
|
alternate2: {
|
||||||
|
name: `detox-alternate2-${value}`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.teams = {
|
||||||
|
private: {
|
||||||
|
name: `detox-team-${value}`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.registeringUser = {
|
||||||
|
username: `newuser${value}`,
|
||||||
|
password: `password${value}`,
|
||||||
|
email: `mobile+registering${value}@rocket.chat`
|
||||||
|
};
|
||||||
|
this.registeringUser = {
|
||||||
|
username: `newusertwo${value}`,
|
||||||
|
password: `passwordtwo${value}`,
|
||||||
|
email: `mobile+registeringtwo${value}@rocket.chat`
|
||||||
|
};
|
||||||
|
this.registeringUser = {
|
||||||
|
username: `newuserthree${value}`,
|
||||||
|
password: `passwordthree${value}`,
|
||||||
|
email: `mobile+registeringthree${value}@rocket.chat`
|
||||||
|
};
|
||||||
|
this.registeringUser = {
|
||||||
|
username: `newuserfour${value}`,
|
||||||
|
password: `passwordfour${value}`,
|
||||||
|
email: `mobile+registeringfour${value}@rocket.chat`
|
||||||
|
};
|
||||||
|
this.random = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Data };
|
||||||
export default data;
|
export default data;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { setup } from './helpers/data_setup';
|
||||||
|
import random from './helpers/random';
|
||||||
|
|
||||||
|
// declare global {
|
||||||
|
// // eslint-disable-next-line no-var
|
||||||
|
// var random: string;
|
||||||
|
// }
|
||||||
|
|
||||||
|
module.exports = async () => {
|
||||||
|
await require('detox/runners/jest/index').globalSetup();
|
||||||
|
globalThis.random = random(20);
|
||||||
|
await setup();
|
||||||
|
};
|
|
@ -1,7 +1,6 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import data, { TDataChannels, TDataGroups, TDataTeams, TDataUsers, TUserRegularChannels } from '../data';
|
import data, { Data, TDataChannels, TDataGroups, TDataTeams, TDataUsers, TUserRegularChannels } from '../data';
|
||||||
import random from './random';
|
|
||||||
|
|
||||||
const TEAM_TYPE = {
|
const TEAM_TYPE = {
|
||||||
PUBLIC: 0,
|
PUBLIC: 0,
|
||||||
|
@ -108,7 +107,7 @@ const changeChannelJoinCode = async (roomId: string, joinCode: string) => {
|
||||||
await rocketchat.post('method.call/saveRoomSettings', {
|
await rocketchat.post('method.call/saveRoomSettings', {
|
||||||
message: JSON.stringify({
|
message: JSON.stringify({
|
||||||
msg: 'method',
|
msg: 'method',
|
||||||
id: random(10),
|
id: globalThis.random,
|
||||||
method: 'saveRoomSettings',
|
method: 'saveRoomSettings',
|
||||||
params: [roomId, { joinCode }]
|
params: [roomId, { joinCode }]
|
||||||
})
|
})
|
||||||
|
@ -132,6 +131,8 @@ const sendMessage = async (user: { username: string; password: string }, channel
|
||||||
};
|
};
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
|
const data = new Data(globalThis.random);
|
||||||
|
|
||||||
await login(data.adminUser, data.adminPassword);
|
await login(data.adminUser, data.adminPassword);
|
||||||
|
|
||||||
for (const userKey in data.users) {
|
for (const userKey in data.users) {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/** @type {import('@jest/types').Config.InitialOptions} */
|
/** @type {import('@jest/types').Config.InitialOptions} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
rootDir: '..',
|
rootDir: '..',
|
||||||
setupFilesAfterEnv: ['<rootDir>/e2e/tests/init.ts'],
|
testMatch: ['<rootDir>/e2e/tests/**/*.spec.ts'],
|
||||||
testMatch: ['<rootDir>/e2e/tests/onboarding/05-login.spec.ts'],
|
|
||||||
testTimeout: 120000,
|
testTimeout: 120000,
|
||||||
maxWorkers: 1,
|
maxWorkers: 1,
|
||||||
globalSetup: 'detox/runners/jest/globalSetup',
|
globalSetup: '<rootDir>/e2e/globalSetup.ts',
|
||||||
globalTeardown: 'detox/runners/jest/globalTeardown',
|
globalTeardown: 'detox/runners/jest/globalTeardown',
|
||||||
reporters: ['detox/runners/jest/reporter'],
|
reporters: ['detox/runners/jest/reporter'],
|
||||||
testEnvironment: 'detox/runners/jest/testEnvironment',
|
testEnvironment: 'detox/runners/jest/testEnvironment',
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
// import detox from 'detox';
|
|
||||||
// import adapter from 'detox/runners/mocha/adapter';
|
|
||||||
|
|
||||||
// import { detox as config } from '../../package.json';
|
|
||||||
import { setup } from '../helpers/data_setup';
|
|
||||||
// import { prepareAndroid } from '../helpers/app';
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
await setup();
|
|
||||||
// await Promise.all([setup(), detox.init(config, { launchApp: false })]);
|
|
||||||
// await prepareAndroid(); // Make Android less flaky
|
|
||||||
// await dataSetup()
|
|
||||||
// await detox.init(config, { launchApp: false });
|
|
||||||
// await device.launchApp({ permissions: { notifications: 'YES' } });
|
|
||||||
});
|
|
||||||
|
|
||||||
// beforeEach(async function () {
|
|
||||||
// // @ts-ignore
|
|
||||||
// await adapter.beforeEach(this);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// afterEach(async function () {
|
|
||||||
// // @ts-ignore
|
|
||||||
// await adapter.afterEach(this);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// afterAll(async () => {
|
|
||||||
// await detox.cleanup();
|
|
||||||
// });
|
|
Loading…
Reference in New Issue