diff --git a/e2e/data.ts b/e2e/data.ts index fd78d02d5..d6decfccb 100644 --- a/e2e/data.ts +++ b/e2e/data.ts @@ -15,8 +15,7 @@ export type TUserRegularChannels = keyof typeof data.userRegularChannels; export type TDataGroups = keyof typeof data.groups; export type TDataTeams = keyof typeof data.teams; -// @ts-ignore -const value = globalThis.random; +const value = process.env.TEST_SESSION; const data = { server: 'https://mobile.rocket.chat', ...account, @@ -97,100 +96,4 @@ const data = { 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; diff --git a/e2e/globalSetup.ts b/e2e/globalSetup.ts index 467e256eb..7b6563c2d 100644 --- a/e2e/globalSetup.ts +++ b/e2e/globalSetup.ts @@ -1,14 +1,6 @@ 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(); - // @ts-ignore - globalThis.random = random(20); await setup(); }; diff --git a/e2e/helpers/data_setup.ts b/e2e/helpers/data_setup.ts index 8beb60fff..9e5f16bed 100644 --- a/e2e/helpers/data_setup.ts +++ b/e2e/helpers/data_setup.ts @@ -1,6 +1,6 @@ import axios from 'axios'; -import data, { Data, TDataChannels, TDataGroups, TDataTeams, TDataUsers, TUserRegularChannels } from '../data'; +import data, { TDataChannels, TDataGroups, TDataTeams, TDataUsers, TUserRegularChannels } from '../data'; const TEAM_TYPE = { PUBLIC: 0, @@ -106,8 +106,7 @@ const changeChannelJoinCode = async (roomId: string, joinCode: string) => { await rocketchat.post('method.call/saveRoomSettings', { message: JSON.stringify({ msg: 'method', - // @ts-ignore - id: globalThis.random, + id: process.env.TEST_SESSION, method: 'saveRoomSettings', params: [roomId, { joinCode }] }) @@ -131,9 +130,6 @@ const sendMessage = async (user: { username: string; password: string }, channel }; const setup = async () => { - // @ts-ignore - const data = new Data(globalThis.random); - await login(data.adminUser, data.adminPassword); for (const userKey in data.users) { @@ -188,8 +184,6 @@ const get = (endpoint: string) => { }; const post = async (endpoint: string, body: any) => { - // @ts-ignore - const data = new Data(globalThis.random); await login(data.users.regular.username, data.users.regular.password); console.log(`POST /${endpoint} ${JSON.stringify(body)}`); return rocketchat.post(endpoint, body); diff --git a/e2e/jest.config.js b/e2e/jest.config.js index d6f0625b9..fcc965fb9 100644 --- a/e2e/jest.config.js +++ b/e2e/jest.config.js @@ -4,7 +4,7 @@ module.exports = { testSequencer: '/e2e/testSequencer.js', testMatch: ['/e2e/tests/**/*.spec.ts'], testTimeout: 120000, - maxWorkers: 1, + maxWorkers: 2, globalSetup: '/e2e/globalSetup.ts', globalTeardown: 'detox/runners/jest/globalTeardown', reporters: ['detox/runners/jest/reporter'], diff --git a/package.json b/package.json index 0520701b5..bb245e24c 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "e2e:ios-build": "yarn detox build -c ios.sim.release", "e2e:ios-test": "yarn detox test -c ios.sim.release --cleanup --headless --take-screenshots failing", "e2e:ios-build-debug": "yarn detox build -c ios.sim.debug", - "e2e:ios-test-debug": "yarn detox test -c ios.sim.debug --take-screenshots failing" + "e2e:ios-test-debug": "TEST_SESSION=`openssl rand -hex 10` yarn detox test -c ios.sim.debug --take-screenshots failing -R" }, "lint-staged": { "*.{js,ts,tsx}": [