Skip to content
Draft
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
116 changes: 84 additions & 32 deletions .maestro/scripts/data-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const getDeepLink = (method, server, ...params) => {
return deeplink;
};


const login = (username, password) => {
const response = http.post(`${data.server}/api/v1/login`, {
headers: {
Expand All @@ -43,7 +42,6 @@ const createUser = (customProps) => {
const user = output.randomUser();

login(output.account.adminUser, output.account.adminPassword);

http.post(`${data.server}/api/v1/users.create`, {
headers: {
'Content-Type': 'application/json',
Expand All @@ -70,29 +68,6 @@ const createUserWithPasswordChange = () => {
return createUser({ requirePasswordChange: true });
}

const deleteCreatedUser = async ({ username: usernameToDelete }) => {
try {
login(output.account.adminUser, output.account.adminPassword);

const result = http.get(`${data.server}/api/v1/users.info?username=${usernameToDelete}`, {
headers: {
'Content-Type': 'application/json',
...headers
}
});

const userId = json(result.body)?.data?.user?._id;
http.post(`${data.server}/api/v1/users.delete`, { userId, confirmRelinquish: true }, {
headers: {
'Content-Type': 'application/json',
...headers
}
});
} catch (error) {
console.log(JSON.stringify(error));
}
};

const createRandomTeam = (username, password) => {
login(username, password);

Expand All @@ -106,6 +81,10 @@ const createRandomTeam = (username, password) => {
body: JSON.stringify({ "name": teamName, "members": [], "type": 1, "room": { "readOnly": false, "extraData": { "topic": "", "broadcast": false, "encrypted": false } } })
});

data.teams.push({
name: teamName
});

return teamName;
}

Expand All @@ -123,6 +102,11 @@ const createRandomRoom = (username, password, type = 'c') => {

const result = json(response.body);

data.rooms.push({
name: type === 'c' ? result.channel.name : result.group.name,
_id: type === 'c' ? result.channel._id : result.group._id
});

return {
_id: type === 'c' ? result.channel._id : result.group._id,
name: type === 'c' ? result.channel.name : result.group.name
Expand Down Expand Up @@ -195,24 +179,92 @@ const createDM = (username, password, otherUsername) => {
return json(result.body);
}

// Delete created users to avoid use all the Seats Available on the server
const deleteCreatedUser = async (username) => {
try {
http.post(`${data.server}/api/v1/users.delete`, {
headers: {
'Content-Type': 'application/json',
...headers
},
body: JSON.stringify({
username,
confirmRelinquish: true
})
});
} catch (error) {
console.log(JSON.stringify(error));
}
};

const deleteCreatedUsers = () => {
if (data.accounts.length) {
for (const deleteUser of data.accounts) {
deleteCreatedUser(deleteUser);
deleteCreatedUser(deleteUser.username);
}
}
};

function logAccounts() {
console.log(JSON.stringify(data.accounts));
}
const deleteCreatedRoom = async (roomId) => {
try {
http.post(`${data.server}/api/v1/rooms.delete`, {
headers: {
'Content-Type': 'application/json',
...headers
},
body: JSON.stringify({
roomId
})
});
} catch (error) {
console.log(JSON.stringify(error));
}
};

const deleteCreatedRooms = () => {
if (data.rooms.length) {
for (const deleteRoom of data.rooms) {
deleteCreatedRoom(deleteRoom._id);
}
}
};

const deleteCreatedTeam = async (teamName) => {
try {
http.post(`${data.server}/api/v1/teams.delete`, {
headers: {
'Content-Type': 'application/json',
...headers
},
body: JSON.stringify({
teamName
})
});
} catch (error) {
console.log(JSON.stringify(error));
}
};

const deleteCreatedTeams = () => {
if (data.teams.length) {
for (const deleteTeam of data.teams) {
deleteCreatedTeam(deleteTeam.name);
}
}
};

const cleanUp = () => {
login(output.account.adminUser, output.account.adminPassword);

deleteCreatedUsers();
deleteCreatedRooms();
deleteCreatedTeams();
};


output.utils = {
createUser,
createUserWithPasswordChange,
logAccounts,
deleteCreatedUsers,
cleanUp,
createRandomTeam,
createRandomRoom,
sendMessage,
Expand Down
2 changes: 2 additions & 0 deletions .maestro/scripts/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const data = {
alternateServer: 'https://stable.rocket.chat',
...output.account,
accounts: [],
rooms: [],
teams: [],
channels: {
detoxpublic: {
name: 'detox-public'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ appId: chat.rocket.reactnative
name: Toasts and Dialogs
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowEnd:
- evalScript: ${output.utils.deleteCreatedUsers()}
onFlowComplete:
- evalScript: ${output.utils.cleanUp()}
tags:
- test-13

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/accessibility-and-appearance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Accessibility and Appearance
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-5
- android-only
Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/broadcast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Broadcast
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-5

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/change-avatar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Change Avatar
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-5

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/changeserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Change Server
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-5

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/deeplink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: DeepLink Test
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-6

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/delete-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Delete Server
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-6

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/display-perf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Display Perf
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-6

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/e2e-encryption.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: E2E Encryption
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-9

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/i18n.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: I18N Test
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-6

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/in-app-notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: In App Notification
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-7

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/join-from-directory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Join From Directory
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-7

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/join-protected-room.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Join Protected Room
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-7

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/join-public-room.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Join Public Room
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-7

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Profile
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-8

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/setting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Setting
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-8

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Status
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-8

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/assorted/user-preferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: User Preferences
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-8

Expand Down
4 changes: 2 additions & 2 deletions .maestro/tests/onboarding/change-password.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Required Password Change
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
- evalScript: ${output.createdUser = output.utils.createUserWithPasswordChange()}
onFlowEnd:
- evalScript: ${output.utils.deleteCreatedUsers()}
onFlowComplete:
- evalScript: ${output.utils.cleanUp()}
tags:
- test-1

Expand Down
4 changes: 2 additions & 2 deletions .maestro/tests/onboarding/login/invalid-credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ appId: chat.rocket.reactnative
name: Login (Invalid Credentials)
onFlowStart:
- runFlow: '../../../helpers/setup.yaml'
onFlowEnd:
- evalScript: ${output.utils.deleteCreatedUsers()}
onFlowComplete:
- evalScript: ${output.utils.cleanUp()}
tags:
- test-2

Expand Down
2 changes: 1 addition & 1 deletion .maestro/tests/onboarding/login/login.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ onFlowStart:
- runFlow: ../../../helpers/setup.yaml
- evalScript: ${output.createdUser = output.utils.createUser()}
onFlowComplete:
- evalScript: ${output.utils.deleteCreatedUsers()}
- evalScript: ${output.utils.cleanUp()}
tags:
- test-2

Expand Down
4 changes: 2 additions & 2 deletions .maestro/tests/onboarding/roomslist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ appId: chat.rocket.reactnative
name: Rooms List
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowEnd:
- evalScript: ${output.utils.deleteCreatedUsers()}
onFlowComplete:
- evalScript: ${output.utils.cleanUp()}
tags:
- test-1

Expand Down
4 changes: 2 additions & 2 deletions .maestro/tests/onboarding/server-history.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ appId: chat.rocket.reactnative
name: Server History
onFlowStart:
- runFlow: '../../helpers/setup.yaml'
onFlowEnd:
- evalScript: ${output.utils.deleteCreatedUsers()}
onFlowComplete:
- evalScript: ${output.utils.cleanUp()}
tags:
- test-3

Expand Down
Loading
Loading