Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mfc updates #53

Open
wants to merge 1 commit into
base: autoreview/main
Choose a base branch
from
Open
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
68 changes: 19 additions & 49 deletions AI/mfc/automation/base/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.myproject.automation.enums.config.TestrailProperty;
import com.myproject.automation.exceptions.PMEnvironmentException;
import com.myproject.automation.exceptions.PMException;
import com.myproject.automation.listeners.TestRailFilterListener;
import com.myproject.automation.models.DeviceConfig;
import com.myproject.automation.models.application.User;
import com.myproject.automation.models.pojo.Device;
Expand Down Expand Up @@ -85,8 +86,6 @@ public abstract class BaseTest extends BaseSteps implements ITest, IConfigurable
private boolean isBeforePass = false;
@Getter
private ThreadLocal<String> currentTestParametersAsString = new InheritableThreadLocal<>();
private static List<DeviceConfig> deviceConfigList = new ArrayList<>();
private static List<DeviceConfig> devicesWithIssuesList = new ArrayList<>();

static {
if (AutomationDriver.isHeadSpinMultipleDeviceLimit() || !DeviceManager.getHeadSpinPredefinedDevices().isEmpty()) {
Expand All @@ -95,10 +94,6 @@ public abstract class BaseTest extends BaseSteps implements ITest, IConfigurable
AutomationDriver.connectToHeadSpinDevicesAndUpdateJsonFile();
reinstallAppForHsAvailableDevices();
}
//List of all DeviceConfig for later redistribution to avoid skipped tests due to device issues
for (Device device : DeviceManager.getAllAvailableDevices()) {
deviceConfigList.add(getDeviceConfig(device));
}
}

@Override
Expand All @@ -115,7 +110,6 @@ public void run(IConfigureCallBack callBack, ITestResult testResult) {
break;
}
releasePort(testResult);
changeUnavailableDevice(testResult);
callBack.runConfigurationMethod(testResult);
}
}
Expand Down Expand Up @@ -154,10 +148,6 @@ public void beforeMethod(Object[] objects, ITestResult iTestResult) {
deviceConfig.getDeviceName(), deviceConfig.getUdid()));
iTestResult.getMethod().setRetryAnalyzerClass(PMRetryAnalyzer.class);
try {
if (devicesWithIssuesList.stream().anyMatch(device -> device.getUdid().equals(this.deviceConfig.getUdid()))) {
Logger.get().info(String.format("Device with issue %s. The device configuration will be changed", this.deviceConfig.getUdid()));
changeDeviceConfig();
}
AppSteps.get().init(this.deviceConfig.getUdid(), deviceConfig);
AppSteps.get().dismissAlertIfPresent();
SocketDriver.initLogsBuilder();
Expand Down Expand Up @@ -322,9 +312,24 @@ public Object[] factory(XmlTest test) {
Collections.shuffle(devices);
for (Device activeDevice : devices) {
BaseTest testClass = this.getClass().getDeclaredConstructor().newInstance();
if (testMethodsToInclude.stream().anyMatch(filteredTest -> filteredTest.getName()
.equalsIgnoreCase(testClass.getClass().getSimpleName())) || test.getXmlPackages().isEmpty()) {
testClass.deviceConfig = getDeviceConfig(activeDevice);
if (testMethodsToInclude.stream().anyMatch(
filteredTest -> filteredTest.getName().equalsIgnoreCase(testClass.getClass().getSimpleName()))
|| test.getXmlPackages().isEmpty()
|| test.getSuite().getListeners().stream().noneMatch(
listener -> listener.contains(TestRailFilterListener.class.getSimpleName()))
) {
testClass.deviceConfig = DeviceConfig.builder()
.deviceName(activeDevice.getModel())
.udid(activeDevice.getUDID())
.hsUdid(activeDevice.getHsUDID())
.deviceAddress(activeDevice.getDeviceAddress())
.ip(activeDevice.getIp())
.wdaPort(activeDevice.getWdaPort())
.port(String.valueOf(SocketUtils.findAvailableTcpPort()))
.useRemoteHeadSpinServer(activeDevice.isUseRemoteHeadSpinServer())
.hsServerUrl(activeDevice.getHsServerUrl())
.platformVersion(activeDevice.getPlatformVersion())
.build();
Comment on lines +315 to +332
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The search results indicate that the implementation of TestRailFilterListener is not found in the codebase, and testMethodsToInclude is only referenced in BaseTest.java. This suggests that the integration might be incomplete or not fully functional.

  • TestRailFilterListener implementation is missing.
  • testMethodsToInclude is only referenced in BaseTest.java.

Please investigate and complete the integration of TestRailFilterListener to ensure it properly affects test selection as expected.

Analysis chain

Refactoring the factory method to consider TestRailFilterListener potentially improves test selection efficiency.


The search results show that TestRailFilterListener is imported and used in BaseTest.java. However, there are no other usages found in the codebase. This suggests that the integration might be limited to this file.

To ensure that TestRailFilterListener is properly integrated and affecting test selection as expected, we should verify the implementation details of TestRailFilterListener and how it interacts with the test selection logic.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `TestRailFilterListener` is properly integrated and affecting test selection as expected.

# Test: Search for other usages of `TestRailFilterListener` in test configurations. Expect: Consistent and correct application.
rg --type java $'TestRailFilterListener'

Length of output: 407



Script:

#!/bin/bash
# Description: Verify the implementation details of `TestRailFilterListener` and its interaction with test selection logic.

# Search for the implementation of `TestRailFilterListener` to understand its role and functionality.
ast-grep --lang java --pattern $'class TestRailFilterListener { $$$ }'

# Search for the usage of `testMethodsToInclude` to see how it is populated and used in the codebase.
rg --type java $'testMethodsToInclude'

Length of output: 333

tests.add(testClass);
Logger.get().info(String.format("Adding test : %s to run", testClass.getClass().getSimpleName()));
}
Expand Down Expand Up @@ -410,39 +415,4 @@ private static void reinstallAppForHsAvailableDevices() {
ApiSteps.get().installAppOnHeadSpin(appId, udid);
}
}

private static DeviceConfig getDeviceConfig(Device device) {
return DeviceConfig.builder()
.deviceName(device.getModel())
.udid(device.getUDID())
.hsUdid(device.getHsUDID())
.deviceAddress(device.getDeviceAddress())
.ip(device.getIp())
.wdaPort(device.getWdaPort())
.port(String.valueOf(SocketUtils.findAvailableTcpPort()))
.useRemoteHeadSpinServer(device.isUseRemoteHeadSpinServer())
.hsServerUrl(device.getHsServerUrl())
.platformVersion(device.getPlatformVersion())
.build();
}

private void changeUnavailableDevice(ITestResult testResult) {
Collections.shuffle(deviceConfigList);
Throwable throwable = testResult.getThrowable();
if (DeviceErrorUtils.isDeviceErrorMessagePresent(throwable, deviceConfig)) {
Logger.get().info(String.format("Adding device %s to the list of devices with issues", deviceConfig.getUdid()));
devicesWithIssuesList.add(deviceConfig);
changeDeviceConfig();
Logger.get().info(String.format("Changed device config to %s", deviceConfig.getUdid()));
}
}

private void changeDeviceConfig() {
Logger.get().info("Changing device configuration");
deviceConfig = deviceConfigList.stream()
.filter(device -> !deviceConfig.getUdid().equals(device.getUdid()))
.filter(device -> devicesWithIssuesList.stream().noneMatch(issueDevice -> issueDevice.getUdid().equals(device.getUdid())))
.findFirst()
.orElseThrow(() -> new PMException("No new device found."));
}
}
98 changes: 53 additions & 45 deletions AI/mfc/automation/base/ICollectablesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.myproject.automation.steps.ui.LobbySteps;
import com.myproject.automation.steps.ui.collectables.*;
import com.myproject.automation.steps.ui.randomrewards.OrbRewardsSteps;
import com.myproject.automation.steps.ui.randomrewards.OrbTotalRewardsSteps;
import com.myproject.automation.steps.ui.randomrewards.RewardPacksRevealSteps;

import java.util.stream.IntStream;
Expand All @@ -18,117 +17,116 @@ public interface ICollectablesTest {

default void upgradeTotalProgressAndClaimUpgradeReward() {
TotalProgressScreenSteps.get().assertThatTotalProgressScreenIsPresent();
AppSteps.get().waitForStableResponseFromWebsocket();
TotalProgressScreenSteps.get().clickUpgrade();
CollectablesAlbumSteps.get().clickSkipBtnIfPresent();
ClaimUpgradeRewardPopupSteps.get().assertClaimUpgradeRewardPopupIsPresent();
AppSteps.get().waitForStableResponseFromWebsocket();
ClaimUpgradeRewardPopupSteps.get().claimUpgradeReward();
}

default void completeBronzeSetWithoutLastItem(User user) {
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BRONZE_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BRONZE_FULL_SET_BOX));
ApiSteps.get().addBoxForUser(user, BRONZE_SET_BOX_WITHOUT_LAST_ITEM);
ApiSteps.get().openBoxForUser(user.getApiToken(), BRONZE_SET_BOX_WITHOUT_LAST_ITEM);
AppSteps.get().launchApp();
default void completeBaseSetWithoutLastItem(User user) {
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BASE_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BASE_FULL_SET_BOX));
ApiSteps.get().addBoxForUser(user, BASE_SET_BOX_WITHOUT_LAST_ITEM);
ApiSteps.get().openBoxForUser(user.getApiToken(), BASE_SET_BOX_WITHOUT_LAST_ITEM);
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
upgradeTotalProgressAndClaimUpgradeReward();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
RewardPacksRevealSteps.get().clickSkipIfPresent();
OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent();
OrbRewardsSteps.get().clickOpenAll();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
RewardPacksRevealSteps.get().clickSkipIfPresent();
OrbTotalRewardsSteps.get().assertThatOrbTotalRewardsViewIsPresent();
OrbTotalRewardsSteps.get().clickFinish();
openAllOrbRewards();
}

default void upgradeToSilverLevel(User user) {
completeBronzeSetWithoutLastItem(user);
ApiSteps.get().addBoxForUser(user, BOX_BRONZE_ITEM_7);
default void upgradeToSilverLevel(User user, boolean isSetCompletedScreenCanBeClosed) {
completeBaseSetWithoutLastItem(user);
ApiSteps.get().addBoxForUser(user, BOX_BASE_ITEM_7);
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
CollectablesCardsSteps.get().assertThatCollectableCardsScreenIsPresent();
CollectablesCardsSteps.get().skipAll();
upgradeTotalProgressAndClaimUpgradeReward();
SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent();
SetCompletedSteps.get().assertThatClaimBtnIsPresent();
if (isSetCompletedScreenCanBeClosed) {
SetCompletedSteps.get().clickClaimBtn();
SetCompletedSteps.get().assertThatSetCompletedScreenIsNotPresent();
}
}

default void setSilverState(User user) {
IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BRONZE_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BRONZE_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BASE_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BASE_FULL_SET_BOX));
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
TotalProgressScreenSteps.get().assertThatTotalProgressScreenIsPresent();
TotalProgressScreenSteps.get().clickUpgrade();
CollectablesAlbumSteps.get().clickSkipBtn();
ClaimUpgradeRewardPopupSteps.get().assertClaimUpgradeRewardPopupIsPresent();
ApiSteps.get().openBoxForUser(user.getApiToken(), BOX_BRONZE_ITEM_1);
ApiSteps.get().openBoxForUser(user.getApiToken(), BOX_BRONZE_ITEM_1);
ApiSteps.get().markItemsAsShown(user.getApiToken(), BRONZE_FULL_SET_BOX);
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
upgradeTotalProgressAndClaimUpgradeReward();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
RewardPacksRevealSteps.get().clickSkipIfPresent();
openAllOrbRewards();
SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent();
SetCompletedSteps.get().assertThatClaimBtnIsPresent();
SetCompletedSteps.get().clickClaimBtn();
openAllOrbRewards();
CollectablesAlbumSteps.get().assertThatCollectablesAlbumIsPresent();
CollectablesAlbumSteps.get().assertThatRewardSetTextIsSameAsExpected(SILVER_SET_REWARD_MESSAGE);
}

default void upgradeToGoldLevel(User user) {
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, SILVER_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), SILVER_FULL_SET_BOX));
AppSteps.get().launchApp();
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
upgradeTotalProgressAndClaimUpgradeReward();
ApiSteps.get().addBoxForUser(user, SILVER_FULL_SET_BOX);
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
CollectablesCardsSteps.get().assertThatCollectableCardsScreenIsPresent();
CollectablesCardsSteps.get().skipAll();
upgradeTotalProgressAndClaimUpgradeReward();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
RewardPacksRevealSteps.get().clickSkip();
OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent();
OrbRewardsSteps.get().clickFinish();
SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent();
}

default void completeGoldState(User user) {
upgradeToSilverAndGoldLevel(user);
SetCompletedSteps.get().assertThatClaimBtnIsPresent();
SetCompletedSteps.get().clickClaimBtn();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent();
OrbRewardsSteps.get().clickOpenAll();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
OrbTotalRewardsSteps.get().assertThatOrbTotalRewardsViewIsPresent();
OrbTotalRewardsSteps.get().clickFinish();
openAllOrbRewards();
CollectablesAlbumSteps.get().assertThatCollectablesAlbumIsPresent();
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, GOLD_FULL_SET_BOX));
IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), GOLD_FULL_SET_BOX));
AppSteps.get().launchApp();
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
upgradeTotalProgressAndClaimUpgradeReward();
ApiSteps.get().addBoxForUser(user, GOLD_FULL_SET_BOX);
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
CollectablesCardsSteps.get().assertThatCollectableCardsScreenIsPresent();
CollectablesCardsSteps.get().skipAll();
upgradeTotalProgressAndClaimUpgradeReward();
SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent();
}

default void upgradeToSilverAndGoldLevel(User user) {
upgradeToSilverLevel(user);
upgradeToSilverLevel(user, true);
upgradeToGoldLevel(user);
}

default void makeTrade(User user, int duplicateBalance) {
ApiSteps.get().setUserDuplicateBalanceTo(user, duplicateBalance);
AppSteps.get().relaunchApp();
LobbySteps.get().assertThatLobbyIsOpened();
LobbySteps.get().tapCollectablesIcon();
LobbySteps.get().clickCollectablesIcon();
CollectablesAlbumSteps.get().assertThatCollectablesAlbumIsPresent();
CollectablesAlbumSteps.get().clickTradeButton();
TradeSteps.get().assertThatTradeScreenIsPresent();
Expand All @@ -139,4 +137,14 @@ default void makeTrade(User user, int duplicateBalance) {
CollectablesCardsSteps.get().skipAll();
TotalProgressScreenSteps.get().assertThatTotalProgressScreenIsPresent();
}

default void openAllOrbRewards() {
OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent();
OrbRewardsSteps.get().clickOpenAll();
RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent();
RewardPacksRevealSteps.get().clickSkipIfPresent();
OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent();
OrbRewardsSteps.get().clickFinish();
OrbRewardsSteps.get().assertThatOrbRewardsViewIsNotPresent();
}
}
10 changes: 5 additions & 5 deletions AI/mfc/automation/screens/LobbyScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class LobbyScreen extends BaseScreen {
private final WsImage imgLockedStarLevel = new WsImage("LockedStarLevelButton", "Locked Star Level Image");
private final WsButton btnLS = new WsButton("LightningStrikesLobbyView>LS_Button Button", "Lightning Strikes Button");
private final WsText txtLSRewardCount = new WsText("RewardReady>RewardsCount TextMeshProUGUI", "LS Reward Count Text");
private final WsImage imgCollectablesIcon = new WsImage("CollectablesButtonContainer Image", "Collectables icon Image");
private final WsButton btnCollectablesButton = new WsButton("CollectablesButtonContainer Button", "Collectables Button");
private final WsImage imgLogoBig = new WsImage("LogoBig Image", "Big Logo Container Image");
private final WsText txtCardsQuantity = new WsText("ReadyToCollect>Image>Quantity TextMeshProUGUI", "Collectables cards quantity Text");
private final WsText txtUpgradeNotification = new WsText("Component_Notification_Piglets_Reset(Clone)>Mask>BalancePanel>PiggyNotificationHeader",
Expand Down Expand Up @@ -172,12 +172,12 @@ public int getLSRewardCounterValue() {
return Integer.parseInt(txtLSRewardCount.getText());
}

public void tapCollectablesIcon() {
imgCollectablesIcon.tap();
public void clickCollectablesButton() {
btnCollectablesButton.click();
}

public boolean isCollectablesIconPresent() {
return imgCollectablesIcon.waitForIsPresent();
public boolean isCollectablesButtonPresent() {
return btnCollectablesButton.waitForIsPresent();
}

public int getCardsQuantity() {
Expand Down
Loading