77 lines
5.7 KiB
Lua
77 lines
5.7 KiB
Lua
-- Original Store Lua-local hierarchy -> Source provider -> real Buy identity.
|
|
local root=arg[1] or '.'
|
|
local function read(path)local f=assert(io.open(path,'rb'));local s=f:read('*a');f:close();return s:gsub('\r\n','\n')end
|
|
local function extract(s,signature)
|
|
local first=assert(s:find(signature..'\n',1,true));local last=assert(s:find('\nend',first,true));return s:sub(first,last+3)
|
|
end
|
|
dofile(root..'/ops/data/source_shop/ShopData.lua')
|
|
local Module=dofile(root..'/ops/source_shop_store_provider.lua')
|
|
local secure=read(root..'/ops/native_source_store_secure.lua')
|
|
local inventory={[69117]=5,[69129]=20,[81088]=19,[900002]=0}
|
|
local apiCalls={}
|
|
C_Item={GetItemInventoryTypeByID=function(id)assert(type(id)=='number' and id>0);apiCalls[#apiCalls+1]=id;return inventory[id]end}
|
|
Enum={BattlepayCardType={SmallCard=1}};ALL='All';CHESTSLOT='Chest';TABARDSLOT='Tabard';OTHER='Other'
|
|
GetItemInfo=function()end;UnitRace=function()return 'Human','Human',1 end;UnitSex=function()return 3 end
|
|
local nativeOptions
|
|
SourceStoreProvider={New=function(_,options)nativeOptions=options;return {} end};SourceStoreWire=TurtleDonationShop
|
|
assert(load(secure))()
|
|
-- This file checks the Fashion slot hierarchy itself; the Forever top layout has its own test.
|
|
assert(nativeOptions.foreverLayout==true);nativeOptions.foreverLayout=false
|
|
local provider=Module.New(TurtleDonationShop,nativeOptions)
|
|
local function apply(message)assert(provider:ApplyMessage(message),message)end
|
|
apply('Categories:2=0=Skins=skin;7=0=Fashion=tabard;')
|
|
apply('Entries:7=start')
|
|
for _,row in ipairs({{69117,69117,'Robe'},{900003,69129,'Robe variant'},{81088,81088,'Tabard'},
|
|
{900001,68070,'Pending metadata'},{900002,0,'Non-equippable'}}) do
|
|
apply('Entries:7=0='..row[3]..'=10=='..row[1]..'=0='..row[2]..'=0=0=0=0=0')
|
|
end
|
|
apply('Entries:7=end');apply('Balance:100')
|
|
local groups=provider:GetProductGroups();local byName={};local virtual=0
|
|
for _,group in ipairs(groups)do
|
|
local info=assert(provider:GetProductGroupInfo(group.groupID))
|
|
if group.groupID<0 then
|
|
assert(group.parentGroupID==7 and info.sourceCategoryID==7 and info.sourceDisplayOnly)
|
|
byName[info.groupName]=group.groupID;virtual=virtual+1
|
|
end
|
|
end
|
|
assert(virtual==4 and byName.All and byName.Chest and byName.Tabard and byName.Other)
|
|
assert(#provider:GetProducts(byName.All)==5 and #provider:GetProducts(7)==5)
|
|
local chest=provider:GetProducts(byName.Chest);assert(#chest==2,'chest/robe must share native chest slot')
|
|
assert(#provider:GetProducts(byName.Tabard)==1 and #provider:GetProducts(byName.Other)==2)
|
|
assert(#provider:GetProducts(-123456)==0)
|
|
local wireGroups=provider:GetSourceProductGroups();assert(#wireGroups==2)
|
|
for _,group in ipairs(wireGroups)do assert(group.groupID>0 and group.parentGroupID==0)end
|
|
assert(not TurtleDonationShop.Parse('Categories:-7000=0=Invalid=icon;'))
|
|
-- The original consumer stores selection as a Lua local, without a native
|
|
-- uint32 category API; every negative selected key goes back to our wrapper.
|
|
local original=read(root..'/runtime/continuation-20261113/codex/PTR-feedback-disable/native70334-ui/interface/addons/blizzard_storeui/blizzard_shared_storeuisecure.lua')
|
|
assert(load('local selectedCategoryID\n'..extract(original,'function StoreFrame_GetSelectedCategoryID()')..'\n'..extract(original,'function StoreFrame_SetSelectedCategoryID(categoryID)')))()
|
|
StoreFrame_SetSelectedCategoryID(byName.Chest)
|
|
local products=provider:GetProducts(StoreFrame_GetSelectedCategoryID())
|
|
for _,id in ipairs(products)do assert(id>0 and provider:GetEntryInfo(id).sharedData.sourceCategoryID==7)end
|
|
local entry=provider:GetEntryInfo(900003)
|
|
assert(entry.entryID==900003 and entry.sharedData.sourcePreviewItemID==69129)
|
|
assert(provider:BeginPurchase(entry)=='Buy:900003','virtual group/preview ID leaked into Buy')
|
|
assert(not provider:BeginPurchase(entry),'duplicate Buy emitted')
|
|
assert(provider:ApplyMessage('BuyResult:ok'));assert(provider:ApplyMessage('Balance:90'))
|
|
for _,id in ipairs(apiCalls)do assert(id>0 and id~=900003,'inventory classifier used purchased token instead of preview selector')end
|
|
-- Metadata arrival reclassifies only the matching Source selector, preserving
|
|
-- all products and a valid Source fallback if the selected Other leaf empties.
|
|
inventory[68070]=5;assert(provider:RefreshFashionSlots(68070));assert(#provider:GetProducts(byName.Other)==1)
|
|
assert(not provider:RefreshFashionSlots(999999) and #provider:GetProducts(byName.All)==5)
|
|
inventory[900002]=5;assert(provider:RefreshFashionSlots(900002));assert(not provider:GetProductGroupInfo(byName.Other))
|
|
assert(provider:GetSourceCategoryForGroup(byName.Other)==7 and #provider:GetProducts(7)==5)
|
|
StoreFrame_SetSelectedCategoryID(byName.Other)
|
|
local selectedEntry=900002;local refreshed=false
|
|
StoreFrame={IsShown=function()return true end,CategoryTreeScrollContainer={UpdateCategories=function()end},
|
|
BrowseNotice={SetText=function()end}}
|
|
StoreFrame_SetSelectedPageNum=function()end;StoreFrame_GetSelectedPageNum=function()return 1 end
|
|
StoreFrame_GetSelectedEntryID=function()return selectedEntry end;StoreFrame_SetSelectedEntryID=function(id)selectedEntry=id end
|
|
SourceStore_CloseInternalPreview=function()end;StoreFrame_SetCategory=function()refreshed=true end
|
|
SourceStore_UpdateBuyButton=function()end;StoreFrame_UpdateCoverState=function()end;StoreFrame_HideAlert=function()end
|
|
assert(load('local sourceStore=...\n'..extract(secure,'function SourceStore_Refresh()')))(provider)
|
|
SourceStore_Refresh();assert(StoreFrame_GetSelectedCategoryID()==7 and selectedEntry==900002 and refreshed)
|
|
-- Missing native API remains Other, never a fabricated inventory definition.
|
|
C_Item={};assert(nativeOptions.inventoryType(69117)==nil)
|
|
print('PASS native Fashion hierarchy/real InventoryType selector, chest+robe merge, All+Other retention, async valid selection, positive-only Source groups and unchanged Buy identity')
|