Skip to content

Commit

Permalink
Troubleshoot why .copyitem test incorrectly passes on GHA
Browse files Browse the repository at this point in the history
It fails on my machine...
  • Loading branch information
Alexander01998 committed Nov 27, 2024
1 parent 62075b4 commit cc59811
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/net/wurstclient/test/CopyItemCmdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ public enum CopyItemCmdTest
public static void testCopyItemCmd()
{
System.out.println("Testing .copyitem command");
setPerspective(Perspective.THIRD_PERSON_FRONT);

// Put on a golden helmet
runChatCommand("give @s golden_helmet");
rightClickInGame();
assertOneItemInSlot(39, Items.GOLDEN_HELMET);
assertNoItemInSlot(0);
takeScreenshot("copyitem_command_setup");

// .copyitem the helmet
String playerName = submitAndGet(mc -> mc.player.getName().getString());
runWurstCommand("copyitem " + playerName + " head");
setPerspective(Perspective.THIRD_PERSON_FRONT);
takeScreenshot("copyitem_command_result");
assertOneItemInSlot(0, Items.GOLDEN_HELMET);

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/wurstclient/test/WurstClientTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,15 @@ public static void assertOneItemInSlot(int slot, Item item)
+ stack.getItem().getName().getString() + " instead");
});
}

public static void assertNoItemInSlot(int slot)
{
submitAndWait(mc -> {
ItemStack stack = mc.player.getInventory().getStack(slot);
if(!stack.isEmpty())
throw new RuntimeException("Expected no item in slot " + slot
+ ", found " + stack.getCount() + " "
+ stack.getItem().getName().getString() + " instead");
});
}
}

0 comments on commit cc59811

Please sign in to comment.