local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local root = Workspace:FindFirstChild("CandyAssetPreviewGrid")
assert(root, "CandyAssetPreviewGrid missing")
local readyRoot = ReplicatedStorage:FindFirstChild("RobloxReadyGameAssets")
assert(readyRoot, "RobloxReadyGameAssets missing")
local ready = readyRoot:FindFirstChild("Candy")
assert(ready, "RobloxReadyGameAssets.Candy missing")
assert(#root:GetChildren() == 25, "expected 25 workspace candy models, got " .. tostring(#root:GetChildren()))
assert(#ready:GetChildren() == 25, "expected 25 ready candy models, got " .. tostring(#ready:GetChildren()))
local attrs = {"CandyName", "CandyType", "Rarity", "IsCollectible", "PickupValue", "IsConsumable", "ItemId", "Category", "NotAvatarAccessory"}
local attrOk = 0
local partOk = 0
local accessories = 0
for _, model in ipairs(root:GetChildren()) do
    assert(model:IsA("Model"), model.Name .. " is not a Model")
    if model:FindFirstChildWhichIsA("BasePart") then partOk += 1 end
    for _, attr in ipairs(attrs) do
        assert(model:GetAttribute(attr) ~= nil, model.Name .. " missing attr " .. attr)
    end
    assert(model:GetAttribute("Category") == "game_asset_candy", model.Name .. " wrong category")
    assert(model:GetAttribute("NotAvatarAccessory") == true, model.Name .. " not marked NotAvatarAccessory")
    attrOk += 1
end
for _, inst in ipairs(root:GetDescendants()) do
    if inst:IsA("Accessory") then accessories += 1 end
end
assert(partOk == 25, "expected every model to have BasePart")
assert(accessories == 0, "expected 0 accessories")
return string.format("candy preview validation ok; workspace=%d; ready=%d; attrOk=%d; partOk=%d; accessories=%d", #root:GetChildren(), #ready:GetChildren(), attrOk, partOk, accessories)
