Feature Testing
Group Mode
Design Philosophy
Group Mode test cases have their own complexities due to the state of the group that users exist within having a direct effect on test outcome. In order to ensure that we have a clean slate for each test, we're enforcing:
- Groups should be permanent where necessary for them to be so.
- Test users for specific suites should remain within their associated group unless their test requires them to leave.
- Group state should be reset in between each test.
- Actions within a group that aren't the focus of the test case should be performed via API where possible. Idea is to increase test speed and reduce points of failure.
- Groups should be appropriately named according to their testing context.
Setting Up a Test
The majority of the setup requirements for Group Mode have already been framed out. Typically you'll follow the process of initialising the API helper, running our setup function and then performing actions with the API as necessary:
Please see these examples of setting up groups and also pots
export const setupActiveShortPotWithThreeMembers = async (): Promise<void> => {
await basicTestSetup();
// Auth group owner
const ownerCredentials = getTestCredentials('POT_LEAVE_ADMIN');
const groupOwnerAPI = new GroupModeAPIHelper(ownerCredentials.username, ownerCredentials.password);
await groupOwnerAPI.init();
const owner_id = (await groupOwnerAPI.chatUser()).user.id;
await groupOwnerAPI.leaveAllGroups();
// Create new group
const { channel_id: channelId, code: channelCode } = (await groupOwnerAPI.createGroup('ActivePotWithThreeMembers', '🧪')).channel.channel_code;
// Create new pot within group
const { id: newPotId } = (await groupOwnerAPI.createBettingGroup(String(channelId), owner_id, 'SHORT', 5, 0, 'QA Test Pot')).group;
// Auth first group member
const firstMemberCredentials = getTestCredentials('POT_LEAVE_MEMBER_FIRST');
const firstGroupMemberAPI = new GroupModeAPIHelper(firstMemberCredentials.username, firstMemberCredentials.password);
await firstGroupMemberAPI.init();
// Leave all groups
await firstGroupMemberAPI.leaveAllGroups();
// Join recently created group
await firstGroupMemberAPI.joinGroup(channelId, channelCode);
await firstGroupMemberAPI.joinBettingGroup(newPotId);
// Auth second group member
const secondMemberCredentials = getTestCredentials('POT_LEAVE_MEMBER_SECOND');
const secondGroupMemberAPI = new GroupModeAPIHelper(secondMemberCredentials.username, secondMemberCredentials.password);
await secondGroupMemberAPI.init();
// Leave all groups
await secondGroupMemberAPI.leaveAllGroups();
// Join recently created group
await secondGroupMemberAPI.joinGroup(channelId, channelCode);
await secondGroupMemberAPI.joinBettingGroup(newPotId);
// Group owner activates pot after member joined
await groupOwnerAPI.activateBettingGroup(newPotId);
clearGroupModeNotificationUpdate(firstMemberCredentials.clientId);
clearGroupModeNotificationUpdate(secondMemberCredentials.clientId);
clearGroupModeNotificationUpdate(ownerCredentials.clientId);
};
Check through e2e/utils/api/group-mode/group-mode.ts
and e2e/utils/setup/setup.ts
to see what you have available to you both from the API and the setup phase.