11describe (" TestImportReimport" , function ()
2- local dkjson = require " dkjson"
32 local DEFAULT_CHARACTER_LEVEL = 12
43 local DEFAULT_ITEM_LEVEL = 10
54 local TEST_IMPORT_ITEM_ID = " test-import-item-1"
6- local DEFAULT_SOCKET_COLOR = " R"
75
86 before_each (function ()
97 newBuild ()
@@ -16,25 +14,17 @@ describe("TestImportReimport", function()
1614 }
1715 end
1816
19- local function makeSocketedGemEntry ( socket , support , typeLine , level )
17+ local function makeGemEntry ( support , typeLine , level , socketedItems )
2018 return {
21- socket = socket ,
2219 support = support ,
2320 typeLine = typeLine ,
2421 properties = makeGemProperties (level ),
22+ socketedItems = socketedItems ,
2523 }
2624 end
2725
2826 -- Build a minimal import item so the tests stay focused on state, not fixture noise.
29- local function makeImportItem (itemTypeLine , inventoryId , socketedItems , itemId )
30- local maxSocketIndex = 0
31- for _ , socketedItem in ipairs (socketedItems ) do
32- maxSocketIndex = math.max (maxSocketIndex , socketedItem .socket + 1 )
33- end
34- local sockets = {}
35- for index = 1 , maxSocketIndex do
36- sockets [index ] = { group = 0 , sColour = DEFAULT_SOCKET_COLOR }
37- end
27+ local function makeImportItem (itemTypeLine , inventoryId , itemId )
3828 return {
3929 id = itemId or TEST_IMPORT_ITEM_ID ,
4030 frameType = 0 ,
@@ -43,43 +33,41 @@ describe("TestImportReimport", function()
4333 inventoryId = inventoryId ,
4434 ilvl = DEFAULT_ITEM_LEVEL ,
4535 properties = {},
46- sockets = sockets ,
47- socketedItems = socketedItems ,
4836 }
4937 end
5038
5139 -- Build a minimal import payload so the tests stay focused on state, not fixture noise.
52- local function buildImportPayload (items )
53- return dkjson .encode ({
54- character = { level = DEFAULT_CHARACTER_LEVEL },
55- items = items ,
56- })
40+ local function buildImportPayload (items , skills )
41+ return {
42+ level = DEFAULT_CHARACTER_LEVEL ,
43+ equipment = items ,
44+ skills = skills ,
45+ }
5746 end
5847
59- local function reimportSocketedItemsWithOptions (itemTypeLine , inventoryId , socketedItems , clearItems )
48+ local function reimportSkillsWithOptions (itemTypeLine , inventoryId , skills , clearItems )
6049 build .importTab .controls .charImportItemsClearSkills .state = true
6150 build .importTab .controls .charImportItemsClearItems .state = clearItems
6251 build .importTab :ImportItemsAndSkills (buildImportPayload ({
63- makeImportItem (itemTypeLine , inventoryId , socketedItems ),
64- }))
52+ makeImportItem (itemTypeLine , inventoryId ),
53+ }, skills ))
6554 runCallback (" OnFrame" )
6655 end
6756
68- local function reimportSingleSocketedGemWithOptions (itemTypeLine , inventoryId , gemName , clearItems )
69- reimportSocketedItemsWithOptions (itemTypeLine , inventoryId , {
70- makeSocketedGemEntry ( 0 , false , gemName , 20 ),
57+ local function reimportSingleGemWithOptions (itemTypeLine , inventoryId , gemName , clearItems )
58+ reimportSkillsWithOptions (itemTypeLine , inventoryId , {
59+ makeGemEntry ( false , gemName , 20 ),
7160 }, clearItems )
7261 end
7362
74- local function reimportSingleSocketedGem (itemTypeLine , inventoryId , gemName )
75- reimportSingleSocketedGemWithOptions (itemTypeLine , inventoryId , gemName , false )
63+ local function reimportSingleGem (itemTypeLine , inventoryId , gemName )
64+ reimportSingleGemWithOptions (itemTypeLine , inventoryId , gemName , false )
7665 end
7766
78- local function assertReimportPreservesSkillSubstate (slotName , itemTypeLine , inventoryId , gemName , fieldName , fieldValue )
67+ local function assertReimportPreservesSkillSubstate (itemTypeLine , inventoryId , gemName , fieldName , fieldValue )
7968 build .skillsTab :PasteSocketGroup (string.format ([[
80- Slot: %s
8169%s 20/0 1
82- ]] , slotName , gemName ))
70+ ]] , gemName ))
8371 runCallback (" OnFrame" )
8472
8573 local socketGroup = build .skillsTab .socketGroupList [1 ]
@@ -90,7 +78,7 @@ Slot: %s
9078 build .buildFlag = true
9179 runCallback (" OnFrame" )
9280
93- reimportSingleSocketedGem (itemTypeLine , inventoryId , gemName )
81+ reimportSingleGem (itemTypeLine , inventoryId , gemName )
9482
9583 socketGroup = build .skillsTab .socketGroupList [1 ]
9684 srcInstance = socketGroup .displaySkillList [1 ].activeEffect .srcInstance
@@ -100,10 +88,8 @@ Slot: %s
10088
10189 it (" preserves full DPS state and manually disabled gems when reimporting items and skills" , function ()
10290 build .skillsTab :PasteSocketGroup ([[
103- Slot: Helmet
104- Cleave 1/0 1
105- Heavy Strike 1/0 1
106- Added Fire Damage 1/0 DISABLED 1
91+ Dark Effigy 1/0 1
92+ Controlled Destruction 1/0 DISABLED 1
10793]] )
10894 runCallback (" OnFrame" )
10995
@@ -115,28 +101,25 @@ Added Fire Damage 1/0 DISABLED 1
115101 build .importTab .controls .charImportItemsClearSkills .state = true
116102 build .importTab .controls .charImportItemsClearItems .state = false
117103 build .importTab :ImportItemsAndSkills (buildImportPayload ({
118- makeImportItem (" Iron Hat " , " Helm" , {
119- makeSocketedGemEntry ( 0 , false , " Cleave " , 1 ),
120- makeSocketedGemEntry ( 1 , false , " Heavy Strike " , 1 ),
121- makeSocketedGemEntry ( 2 , true , " Added Fire Damage Support " , 2 ),
104+ makeImportItem (" Wrapped Cap " , " Helm" ),
105+ }, {
106+ makeGemEntry ( false , " Dark Effigy " , 2 , {
107+ makeGemEntry ( true , " Controlled Destruction " , 1 ),
122108 }),
123109 }))
124110 runCallback (" OnFrame" )
125111
126112 socketGroup = build .skillsTab .socketGroupList [1 ]
127- assert .are .equal (" Helmet" , socketGroup .slot )
128113 assert .is_true (socketGroup .includeInFullDPS )
129114 assert .are .equal (2 , socketGroup .mainActiveSkill )
130- assert .are .equal (2 , socketGroup .gemList [3 ].level )
131- assert .is_false (socketGroup .gemList [3 ].enabled )
115+ assert .are .equal (2 , socketGroup .gemList [1 ].level )
116+ assert .is_false (socketGroup .gemList [2 ].enabled )
132117 end )
133118
134119 it (" preserves full DPS state and disabled gems when reimporting with deleted equipment" , function ()
135120 build .skillsTab :PasteSocketGroup ([[
136- Slot: Helmet
137- Cleave 1/0 1
138- Heavy Strike 1/0 1
139- Added Fire Damage 1/0 DISABLED 1
121+ Dark Effigy 1/0 1
122+ Controlled Destruction 1/0 DISABLED 1
140123]] )
141124 runCallback (" OnFrame" )
142125
@@ -145,82 +128,73 @@ Added Fire Damage 1/0 DISABLED 1
145128 socketGroup .mainActiveSkill = 2
146129 runCallback (" OnFrame" )
147130
148- reimportSocketedItemsWithOptions ( " Iron Hat " , " Helm" , {
149- makeSocketedGemEntry ( 0 , false , " Cleave " , 1 ),
150- makeSocketedGemEntry ( 1 , false , " Heavy Strike " , 1 ),
151- makeSocketedGemEntry ( 2 , true , " Added Fire Damage Support " , 2 ),
131+ reimportSkillsWithOptions ( " Wrapped Cap " , " Helm" , {
132+ makeGemEntry ( false , " Dark Effigy " , 2 , {
133+ makeGemEntry ( true , " Controlled Destruction " , 1 ),
134+ } ),
152135 }, true )
153136
154137 socketGroup = build .skillsTab .socketGroupList [1 ]
155- assert .are .equal (" Helmet" , socketGroup .slot )
156138 assert .is_true (socketGroup .includeInFullDPS )
157139 assert .are .equal (2 , socketGroup .mainActiveSkill )
158- assert .are .equal (2 , socketGroup .gemList [3 ].level )
159- assert .is_false (socketGroup .gemList [3 ].enabled )
140+ assert .are .equal (2 , socketGroup .gemList [1 ].level )
141+ assert .is_false (socketGroup .gemList [2 ].enabled )
160142 end )
161143
162144 it (" preserves two socket groups when reimporting items and skills" , function ()
163145 build .skillsTab :PasteSocketGroup ([[
164- Slot: Helmet
165- Cleave 1/0 1
166- Heavy Strike 1/0 1
167- Added Fire Damage 1/0 DISABLED 1
146+ Dark Effigy 1/0 1
147+ Controlled Destruction 1/0 DISABLED 1
168148]] )
169149 runCallback (" OnFrame" )
170150
171151 build .skillsTab :PasteSocketGroup ([[
172- Slot: Gloves
173- Blight 20/0 1
152+ Fireball 20/0 1
174153]] )
175154 runCallback (" OnFrame" )
176155
177- local helmetGroup = build .skillsTab .socketGroupList [1 ]
178- helmetGroup .includeInFullDPS = true
179- helmetGroup .mainActiveSkill = 2
180- local glovesGroup = build .skillsTab .socketGroupList [2 ]
181- glovesGroup .enabled = false
156+ local darkEffigyGroup = build .skillsTab .socketGroupList [1 ]
157+ darkEffigyGroup .includeInFullDPS = true
158+ darkEffigyGroup .mainActiveSkill = 2
159+ local fireballGroup = build .skillsTab .socketGroupList [2 ]
160+ fireballGroup .enabled = false
182161 runCallback (" OnFrame" )
183162
184163 build .importTab .controls .charImportItemsClearSkills .state = true
185164 build .importTab .controls .charImportItemsClearItems .state = false
186165 build .importTab :ImportItemsAndSkills (buildImportPayload ({
187- makeImportItem (" Iron Hat" , " Helm" , {
188- makeSocketedGemEntry (0 , false , " Cleave" , 1 ),
189- makeSocketedGemEntry (1 , false , " Heavy Strike" , 1 ),
190- makeSocketedGemEntry (2 , true , " Added Fire Damage Support" , 2 ),
191- }, " test-import-item-helmet" ),
192- makeImportItem (" Rawhide Gloves" , " Gloves" , {
193- makeSocketedGemEntry (0 , false , " Blight" , 20 ),
194- }, " test-import-item-gloves" ),
166+ makeImportItem (" Wrapped Cap" , " Helm" , " test-import-item-helmet" ),
167+ makeImportItem (" Linen Wraps" , " Gloves" , " test-import-item-gloves" ),
168+ }, {
169+ makeGemEntry (false , " Dark Effigy" , 1 , {
170+ makeGemEntry (true , " Controlled Destruction" , 1 ),
171+ }),
172+ makeGemEntry (false , " Fireball" , 20 ),
195173 }))
196174 runCallback (" OnFrame" )
197175
198- local groupsBySlot = {}
176+ local groupsByGem = {}
199177 for _ , socketGroup in ipairs (build .skillsTab .socketGroupList ) do
200- groupsBySlot [socketGroup .slot ] = socketGroup
178+ groupsByGem [socketGroup .gemList [ 1 ]. nameSpec ] = socketGroup
201179 end
202180
203181 assert .are .equal (2 , # build .skillsTab .socketGroupList )
204- assert .is_not_nil (groupsBySlot . Helmet )
205- assert .is_not_nil (groupsBySlot . Gloves )
206- assert .is_true (groupsBySlot . Helmet .includeInFullDPS )
207- assert .are .equal (2 , groupsBySlot . Helmet .mainActiveSkill )
208- assert .is_false (groupsBySlot . Gloves .enabled )
182+ assert .is_not_nil (groupsByGem [ " Dark Effigy " ] )
183+ assert .is_not_nil (groupsByGem . Fireball )
184+ assert .is_true (groupsByGem [ " Dark Effigy " ] .includeInFullDPS )
185+ assert .are .equal (2 , groupsByGem [ " Dark Effigy " ] .mainActiveSkill )
186+ assert .is_false (groupsByGem . Fireball .enabled )
209187 end )
210188
211189 it (" preserves skill part selection when reimporting items and skills" , function ()
212- assertReimportPreservesSkillSubstate (" Helmet " , " Iron Hat " , " Helm " , " Blight " , " skillPart" , 2 )
190+ assertReimportPreservesSkillSubstate (" Twig Focus " , " Offhand " , " Dark Effigy " , " skillPart" , 2 )
213191 end )
214192
215193 it (" preserves stage count when reimporting items and skills" , function ()
216- assertReimportPreservesSkillSubstate (" Weapon 1 " , " Driftwood Wand" , " Weapon" , " Scorching Ray " , " skillStageCount" , 8 )
194+ assertReimportPreservesSkillSubstate (" Withered Wand" , " Weapon" , " Flameblast " , " skillStageCount" , 8 )
217195 end )
218196
219- it (" preserves mine count when reimporting items and skills" , function ()
220- assertReimportPreservesSkillSubstate (" Gloves" , " Rawhide Gloves" , " Gloves" , " Pyroclast Mine" , " skillMineCount" , 12 )
221- end )
222-
223197 it (" preserves minion skill when reimporting items and skills" , function ()
224- assertReimportPreservesSkillSubstate (" Gloves " , " Rawhide Gloves " , " Gloves" , " Summon Chaos Golem " , " skillMinionSkill" , 3 )
198+ assertReimportPreservesSkillSubstate (" Linen Wraps " , " Gloves" , " Skeletal Sniper " , " skillMinionSkill" , 2 )
225199 end )
226200end )
0 commit comments