mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-20 02:18:15 +00:00
test(e2e): stabilize Detox and Maestro suites and harden CI - Re-enable stabilized cases and document remaining iOS skips. - Improve selectors, navigation recovery, state assertions, and retry limits. - Harden API retries, fixture setup, and server configuration cleanup. - Increase Detox shards to 24 and improve reporting, artifact uploads, and timeout handling. - Add testIDs and unit-test fixes; revert unproven app behavior changes.
182 lines
8.6 KiB
TypeScript
182 lines
8.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {isAndroid, isIos, timeouts, wait, waitForElementToExist} from '@support/utils';
|
|
import {device, expect, waitFor} from 'detox';
|
|
|
|
import ProfilePicture from './profile_picture';
|
|
|
|
class Autocomplete {
|
|
testID = {
|
|
atMentionItemPrefix: 'autocomplete.at_mention_item.',
|
|
groupMentionItemPrefix: 'autocomplete.group_mention_item.',
|
|
specialMentionItemPrefix: 'autocomplete.special_mention_item.',
|
|
channelMentionItemPrefix: 'autocomplete.channel_mention_item.',
|
|
emojiSuggestionItemPrefix: 'autocomplete.emoji_suggestion_item.',
|
|
slashSuggestionItemPrefix: 'autocomplete.slash_suggestion_item.',
|
|
autocomplete: 'autocomplete',
|
|
sectionAtMentionList: 'autocomplete.at_mention.section_list',
|
|
sectionChannelMentionList: 'autocomplete.channel_mention.section_list',
|
|
flatEmojiSuggestionList: 'autocomplete.emoji_suggestion.flat_list',
|
|
flatSlashSuggestionList: 'autocomplete.slash_suggestion.flat_list',
|
|
};
|
|
|
|
autocomplete = element(by.id(this.testID.autocomplete));
|
|
sectionAtMentionList = element(by.id(this.testID.sectionAtMentionList));
|
|
sectionChannelMentionList = element(by.id(this.testID.sectionChannelMentionList));
|
|
flatEmojiSuggestionList = element(by.id(this.testID.flatEmojiSuggestionList));
|
|
flatSlashSuggestionList = element(by.id(this.testID.flatSlashSuggestionList));
|
|
|
|
getAtMentionItem = (userId: string) => {
|
|
const atMentionItemTestId = `${this.testID.atMentionItemPrefix}${userId}`;
|
|
const atMentionItemMatcher = by.id(atMentionItemTestId);
|
|
const atMentionItemProfilePictureMatcher = ProfilePicture.getProfilePictureItemMatcher(this.testID.atMentionItemPrefix, userId);
|
|
const atMentionItemAgentTagMatcher = by.id(`${atMentionItemTestId}.agent.tag`);
|
|
const atMentionItemBotTagMatcher = by.id(`${atMentionItemTestId}.bot.tag`);
|
|
const atMentionItemGuestTagMatcher = by.id(`${atMentionItemTestId}.guest.tag`);
|
|
const atMentionItemUserDisplayNameMatcher = by.id(`${atMentionItemTestId}.display_name`);
|
|
const atMentionItemCurrentUserIndicatorMatcher = by.id(`${atMentionItemTestId}.current_user_indicator`);
|
|
const atMentionItemUsernameMatcher = by.id(`${atMentionItemTestId}.username`);
|
|
|
|
return {
|
|
atMentionItem: element(atMentionItemMatcher),
|
|
atMentionItemProfilePicture: element(atMentionItemProfilePictureMatcher),
|
|
atMentionItemAgentTag: element(atMentionItemAgentTagMatcher),
|
|
atMentionItemBotTag: element(atMentionItemBotTagMatcher),
|
|
atMentionItemGuestTag: element(atMentionItemGuestTagMatcher),
|
|
atMentionItemUserDisplayName: element(atMentionItemUserDisplayNameMatcher),
|
|
atMentionItemCurrentUserIndicator: element(atMentionItemCurrentUserIndicatorMatcher),
|
|
atMentionItemUsername: element(atMentionItemUsernameMatcher),
|
|
};
|
|
};
|
|
|
|
getGrouptMentionItem = (groupName: string) => {
|
|
const groupMentionItemTestId = `${this.testID.groupMentionItemPrefix}${groupName}`;
|
|
const groupMentionItemMatcher = by.id(groupMentionItemTestId);
|
|
const groupMentionItemGroupDisplayNameMatcher = by.id(`${groupMentionItemTestId}.display_name`);
|
|
const groupMentionItemGroupNameMatcher = by.id(`${groupMentionItemTestId}.name`);
|
|
|
|
return {
|
|
groupMentionItem: element(groupMentionItemMatcher),
|
|
groupMentionItemGroupDisplayName: element(groupMentionItemGroupDisplayNameMatcher),
|
|
groupMentionItemGroupName: element(groupMentionItemGroupNameMatcher),
|
|
};
|
|
};
|
|
|
|
getSpecialMentionItem = (handleName: string) => {
|
|
const specialMentionItemTestId = `${this.testID.specialMentionItemPrefix}${handleName}`;
|
|
const specialMentionItemMatcher = by.id(specialMentionItemTestId);
|
|
const specialMentionItemGroupDisplayNameMatcher = by.id(`${specialMentionItemTestId}.display_name`);
|
|
const specialMentionItemGroupNameMatcher = by.id(`${specialMentionItemTestId}.name`);
|
|
|
|
return {
|
|
specialMentionItem: element(specialMentionItemMatcher),
|
|
specialMentionItemGroupDisplayName: element(specialMentionItemGroupDisplayNameMatcher),
|
|
specialMentionItemGroupName: element(specialMentionItemGroupNameMatcher),
|
|
};
|
|
};
|
|
|
|
getChannelMentionItem = (channelName: string) => {
|
|
const channelMentionItemTestId = `${this.testID.channelMentionItemPrefix}${channelName}`;
|
|
const channelMentionItemMatcher = by.id(channelMentionItemTestId);
|
|
const channelMentionItemChannelDisplayNameMatcher = by.id(`${channelMentionItemTestId}.display_name`);
|
|
const channelMentionItemChannelNameMatcher = by.id(`${channelMentionItemTestId}.name`);
|
|
|
|
return {
|
|
channelMentionItem: element(channelMentionItemMatcher),
|
|
channelMentionItemChannelDisplayName: element(channelMentionItemChannelDisplayNameMatcher),
|
|
channelMentionItemChannelName: element(channelMentionItemChannelNameMatcher),
|
|
};
|
|
};
|
|
|
|
getEmojiSuggestionItem = (emojiName: string) => {
|
|
const emojiSuggestionItemTestId = `${this.testID.emojiSuggestionItemPrefix}${emojiName}`;
|
|
const emojiSuggestionItemMatcher = by.id(emojiSuggestionItemTestId);
|
|
const emojiSuggestionItemEmojiNameMatcher = by.id(`${emojiSuggestionItemTestId}.name`);
|
|
|
|
return {
|
|
emojiSuggestionItem: element(emojiSuggestionItemMatcher),
|
|
emojiSuggestionItemEmojiName: element(emojiSuggestionItemEmojiNameMatcher),
|
|
};
|
|
};
|
|
|
|
getSlashSuggestionItem = (slashCommand: string) => {
|
|
const slashSuggestionItemTestId = `${this.testID.slashSuggestionItemPrefix}/${slashCommand}`;
|
|
const slashSuggestionItemMatcher = by.id(slashSuggestionItemTestId);
|
|
const slashSuggestionItemSlashCommandNameMatcher = by.id(`${slashSuggestionItemTestId}.name`);
|
|
const slashSuggestionItemSlashCommandDescriptionMatcher = by.id(`${slashSuggestionItemTestId}.description`);
|
|
|
|
return {
|
|
slashSuggestionItem: element(slashSuggestionItemMatcher),
|
|
slashSuggestionItemSlashCommandName: element(slashSuggestionItemSlashCommandNameMatcher),
|
|
slashSuggestionItemSlashCommandDescription: element(slashSuggestionItemSlashCommandDescriptionMatcher),
|
|
};
|
|
};
|
|
|
|
// Detox often mis-measures suggestion rows (Reanimated / transparent hit).
|
|
// Wait for existence, prefer opaque label. iOS tapAtPoint for bad frames;
|
|
// Android plain tap first, corner only on miss.
|
|
tapSuggestion = async (
|
|
item: Detox.IndexableNativeElement,
|
|
label?: Detox.IndexableNativeElement,
|
|
) => {
|
|
await waitForElementToExist(item, timeouts.TEN_SEC);
|
|
const target = label ?? item;
|
|
try {
|
|
await waitFor(target).toBeVisible(isAndroid() ? 40 : 25).withTimeout(timeouts.FIVE_SEC);
|
|
} catch {
|
|
// Visibility % flaky — still attempt platform tap below.
|
|
}
|
|
if (isIos()) {
|
|
// Sync + keyboard often report false "not hittable"; disable briefly like alert dismiss.
|
|
try {
|
|
await device.disableSynchronization();
|
|
} catch {
|
|
// already off
|
|
}
|
|
try {
|
|
try {
|
|
await target.tapAtPoint({x: 12, y: 12});
|
|
} catch {
|
|
try {
|
|
await target.tapAtPoint({x: 24, y: 8});
|
|
} catch {
|
|
await target.tap();
|
|
}
|
|
}
|
|
} finally {
|
|
try {
|
|
await device.enableSynchronization();
|
|
} catch {
|
|
// ignore
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
try {
|
|
await target.tap();
|
|
} catch {
|
|
await target.tap({x: 1, y: 1});
|
|
}
|
|
};
|
|
|
|
toBeVisible = async (isVisible = true) => {
|
|
if (isVisible) {
|
|
try {
|
|
await waitFor(this.autocomplete.atIndex(0)).toBeVisible(1).withTimeout(timeouts.TEN_SEC);
|
|
} catch {
|
|
// Reanimated frames often report 0% visible; existence still means mounted.
|
|
await waitFor(this.autocomplete.atIndex(0)).toExist().withTimeout(timeouts.TEN_SEC);
|
|
}
|
|
return this.autocomplete;
|
|
}
|
|
|
|
await wait(timeouts.ONE_SEC);
|
|
await expect(this.autocomplete).not.toBeVisible();
|
|
return null;
|
|
};
|
|
}
|
|
|
|
const autocomplete = new Autocomplete();
|
|
export default autocomplete;
|