-
-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix reource load issue in local downloaded npm package #2436
Changes from all commits
5a26f3d
5ecc318
cafc24f
dc69489
221b7b6
0d45d9c
0f14c3f
8871d9b
3b4ffd7
f649a58
598fc56
e33a66f
41ef06f
b5214fc
f36ce02
ff8b7c2
634236f
91e6fa4
3932448
671cace
92b972e
9226d38
ff6a69a
83b9ca2
f510c2a
3bcaeb0
79a7a0c
fa7131c
d4ea485
2af1c65
a828991
24cb887
ab8bf3b
fd870a0
daf6521
b3f8e57
809a3cb
1607698
7e4a771
c76cba5
ef32bc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { AssetPromise, ResourceManager, Texture2D } from "@galacean/engine-core"; | ||
import { AssetPromise, AssetType, ResourceManager, Texture2D } from "@galacean/engine-core"; | ||
import { WebGLEngine } from "@galacean/engine-rhi-webgl"; | ||
import chai, { expect } from "chai"; | ||
import spies from "chai-spies"; | ||
|
@@ -81,4 +81,17 @@ describe("ResourceManager", () => { | |
chai.spy.restore(glTFLoader, "load"); | ||
}); | ||
}); | ||
|
||
describe("gltf subAsset load", () => { | ||
it("invalid q case", async () => { | ||
const loadRes = await engine.resourceManager.load({ | ||
// contains invalid q value cdn url. | ||
url: "https://mdn.alipayobjects.com/huamei_aftkdx/afts/file/A*_Ao1QZtL9fMAAAAAAAAAAAAADteEAQ/mock-project.json", | ||
type: AssetType.Project | ||
}); | ||
expect(loadRes).to.equal(undefined); | ||
}); | ||
|
||
// TODO: case for gltf loader load invalid q url, expect to throw | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement the TODO test case before merging Given that this PR addresses resource loading issues, the TODO test case for GLTF loader error handling should be implemented now rather than deferred. This test is important for validating the error handling behavior of the resource loading fix. Would you like me to help implement the test case for GLTF loader error handling? Here's a suggested structure: it("should throw error when loading GLTF with invalid query URL", async () => {
try {
await engine.resourceManager.load({
url: "/test-assets/model.gltf?q=invalid[query]",
type: AssetType.GLTF
});
expect.fail("Should have thrown an error");
} catch (error) {
expect(error).to.be.instanceOf(Error);
expect(error.message).to.include("Invalid query parameter");
}
}); |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Test case needs improvement for reliability and clarity
Several issues with the current test implementation:
undefined
is the expected return value.Consider refactoring like this: