Skip to content
Merged
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
39 changes: 38 additions & 1 deletion spec/System/TestImport_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe("TestImport", function()
build.importTab:ImportPassiveTreeAndJewels(sampleData, true)
runCallback("OnFrame")

assert.equals(build.bandit, "None")
assert.equals(build.configTab.input.bandit, "None")
assert.equals(build.configTab.input.pantheonMajorGod, "TheBrineKing")
assert.equals(build.configTab.input.pantheonMinorGod, "Yugul")
assert.equals(build.characterLevel, 99)
-- iron will and CI
assert.equals(build.spec.allocatedKeystoneCount, 2)
Expand All @@ -39,6 +41,41 @@ describe("TestImport", function()

assert.equals(build.spec.allocatedNotableCount, 29)
end)

it("preserves quest choices only for account-name imports", function()
build.configTab.varControls.bandit:SetSel(2)
build.configTab.varControls.pantheonMajorGod:SetSel(4)
build.configTab.varControls.pantheonMinorGod:SetSel(9)

local importData = copyTable(sampleData)
importData.passives.bandit_choice = nil
importData.passives.pantheon_major = nil
importData.passives.pantheon_minor = nil
build.importTab.controls.siteAccountName.buf = "Test#0000"
build.importTab.controls.siteCharSelect.list = { { char = importData } }
build.importTab.controls.siteCharSelect.selIndex = 1
build.importTab.lastLeague = importData.league

local downloadPage = launch.DownloadPage
launch.DownloadPage = function(_, _, callback)
callback({ body = dkjson.encode(importData.passives) })
end
build.importTab:DownloadPassiveTree({ hostName = "", realmCode = "pc" })
launch.DownloadPage = downloadPage
runCallback("OnFrame")

assert.equals(build.configTab.input.bandit, "Oak")
assert.equals(build.configTab.input.pantheonMajorGod, "Solaris")
assert.equals(build.configTab.input.pantheonMinorGod, "Shakari")

build.importTab:ImportPassiveTreeAndJewels(importData, true)
runCallback("OnFrame")

assert.equals(build.configTab.input.bandit, "None")
assert.equals(build.configTab.input.pantheonMajorGod, "None")
assert.equals(build.configTab.input.pantheonMinorGod, "None")
end)

it("imports with correct jewels", function()
build.importTab:ImportPassiveTreeAndJewels(sampleData, true)
runCallback("OnFrame")
Expand Down
4 changes: 4 additions & 0 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ function ImportTabClass:DownloadPassiveTree(realm)
self.lastLeague = self.controls.siteCharSelectLeague:GetSelValueByKey("league")
end
local responseLua = dkjson.decode(response.body)
-- Account-name imports omit quest choices, so keep the build's current values.
responseLua.bandit_choice = responseLua.bandit_choice or self.build.configTab.input.bandit
responseLua.pantheon_major = responseLua.pantheon_major or self.build.configTab.input.pantheonMajorGod
responseLua.pantheon_minor = responseLua.pantheon_minor or self.build.configTab.input.pantheonMinorGod
-- modify response to be like the oauth API response
local charData = copyTable(charListData)
charData.passives = responseLua
Expand Down
Loading