Skip to content

Commit f0c87ce

Browse files
committed
feat: add tests for assetpack as separate workflow
1 parent 4593cd0 commit f0c87ce

File tree

4 files changed

+79
-34
lines changed

4 files changed

+79
-34
lines changed

.github/workflows/FissionUnitTest.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runUnitTests:
1212
name: Playwright Unit Tests
1313
container:
14-
image: mcr.microsoft.com/playwright:v1.54.0-noble
14+
image: mcr.microsoft.com/playwright:v1.55.0-noble
1515
runs-on: ubuntu-latest
1616
defaults:
1717
run:
@@ -57,3 +57,41 @@ jobs:
5757

5858
- name: Run Tests
5959
run: HOME=/root npm run test
60+
61+
runAssetpackTests:
62+
name: Assetpack Tests
63+
needs: runUnitTests
64+
container:
65+
image: mcr.microsoft.com/playwright:v1.55.0-noble
66+
runs-on: ubuntu-latest
67+
defaults:
68+
run:
69+
working-directory: "fission"
70+
steps:
71+
- name: Checkout Code
72+
uses: actions/checkout@v4
73+
- name: JavaScript Setup
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: 20
77+
78+
- name: Cache Unzipped Synthesis Assets
79+
id: cache-assets
80+
uses: actions/cache@v3
81+
with:
82+
path: fission/public/Downloadables
83+
key: ${{ runner.os }}-assets-${{hashFiles('fission/public/assetpack.zip')}}
84+
85+
- name: Cache Node Dependencies
86+
uses: actions/cache@v3
87+
with:
88+
key: "${{runner.os}}-npm-fission-${{hashFiles('fission/package.json')}}"
89+
path: "fission/node_modules"
90+
restore-keys: |
91+
${{runner.os}}-npm-fission-
92+
${{runner.os}}-npm
93+
94+
- name: Run Assetpack Tests
95+
run: HOME=/root npm run test src/test/mirabuf/DefaultAssets.test.ts
96+
env:
97+
RUN_ASSETPACK_TESTS: true

fission/src/test/mirabuf/DefaultAssets.test.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@ describe("Default Asset Tests", async () => {
1111
expect(DefaultAssetLoader.robots.length).toBeGreaterThan(1)
1212
})
1313

14-
test.skip.each(DefaultAssetLoader.fields)("Manifest hashes match assets ($name)", async asset => {
15-
const info = await MirabufCachingService.cacheRemote(asset.remotePath, asset.miraType)
16-
assert.exists(info)
17-
expect(asset.hash, `Hashes for "${info.name}" do not match`).toBe(info.hash)
18-
expect(asset.miraType).toBe(MiraType.FIELD)
19-
await MirabufCachingService.remove(info.hash)
20-
})
21-
test.skip.each(DefaultAssetLoader.robots)("Manifest hashes match assets ($name)", async asset => {
22-
const info = await MirabufCachingService.cacheRemote(asset.remotePath, asset.miraType)
23-
assert.exists(info)
24-
expect(asset.hash, `Hashes for "${info.name}" do not match`).toBe(info.hash)
25-
expect(asset.miraType).toBe(MiraType.ROBOT)
26-
await MirabufCachingService.remove(info.hash)
27-
})
14+
test.runIf(import.meta.env.RUN_ASSETPACK_TESTS).each(DefaultAssetLoader.fields)(
15+
"Manifest hashes match assets ($name)",
16+
async asset => {
17+
const info = await MirabufCachingService.cacheRemote(asset.remotePath, asset.miraType)
18+
assert.exists(info)
19+
expect(asset.hash, `Hashes for "${info.name}" do not match`).toBe(info.hash)
20+
expect(asset.miraType).toBe(MiraType.FIELD)
21+
await MirabufCachingService.remove(info.hash)
22+
}
23+
)
24+
test.runIf(import.meta.env.RUN_ASSETPACK_TESTS).each(DefaultAssetLoader.robots)(
25+
"Manifest hashes match assets ($name)",
26+
async asset => {
27+
const info = await MirabufCachingService.cacheRemote(asset.remotePath, asset.miraType)
28+
assert.exists(info)
29+
expect(asset.hash, `Hashes for "${info.name}" do not match`).toBe(info.hash)
30+
expect(asset.miraType).toBe(MiraType.ROBOT)
31+
await MirabufCachingService.remove(info.hash)
32+
}
33+
)
2834
})

fission/src/test/mirabuf/MirabufLoader.test.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,24 @@ describe("MirabufLoader", () => {
7979
beforeEach(async () => {
8080
await MirabufLoader.removeAll()
8181
})
82-
test("Loads Robot", async () => {
83-
const info = await MirabufLoader.cacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT)
82+
const tests: [string, MiraType][] = [
83+
["/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT],
84+
["/api/mira/fields/FRC Field 2023_v7.mira", MiraType.FIELD],
85+
]
86+
test.for(tests)("Loads Asset ($0)", async ([url, miratype]) => {
87+
const info = await MirabufLoader.cacheRemote(url, miratype)
8488
expect(info).toBeDefined()
85-
expect(info?.miraType).toBe(MiraType.ROBOT)
86-
expect(info?.name).toBe("Dozer v9")
89+
expect(info?.miraType).toBe(miratype)
90+
expect(info?.name).toMatchSnapshot()
91+
expect(info?.hash).toMatchSnapshot()
8792
const assembly = await MirabufLoader.get(info!.hash)
8893
expect(assembly).toBeDefined()
8994
expect(assembly?.info?.name).toBe(info!.name)
9095
expect(MirabufLoader.getAll()).toStrictEqual([info])
91-
expect(MirabufLoader.getAll(MiraType.ROBOT)).toStrictEqual([info])
92-
expect(MirabufLoader.getAll(MiraType.FIELD)).toStrictEqual([])
96+
expect(MirabufLoader.getAll(miratype)).toStrictEqual([info])
97+
expect(MirabufLoader.getAll(miratype == MiraType.FIELD ? MiraType.ROBOT : MiraType.FIELD)).toStrictEqual([])
9398
})
9499

95-
test("Loads Field", async () => {
96-
const info = await MirabufLoader.cacheRemote("/api/mira/fields/FRC Field 2023_v7.mira", MiraType.FIELD)
97-
expect(info).toBeDefined()
98-
expect(info?.miraType).toBe(MiraType.FIELD)
99-
expect(info?.name).toBe("FRC Field 2023 v7")
100-
expect(info?.hash).toBe("60440aa3010e1fa2f12877ae52aafbea68e81d")
101-
const assembly = await MirabufLoader.get(info!.hash)
102-
expect(assembly).toBeDefined()
103-
expect(assembly?.info?.name).toBe(info!.name)
104-
expect(MirabufLoader.getAll()).toStrictEqual([info])
105-
expect(MirabufLoader.getAll(MiraType.FIELD)).toStrictEqual([info])
106-
expect(MirabufLoader.getAll(MiraType.ROBOT)).toStrictEqual([])
107-
})
108100
test("Remove All Cleans Up", async () => {
109101
const field1 = await MirabufLoader.cacheRemote("/api/mira/fields/FRC Field 2023_v7.mira", MiraType.FIELD)
110102
const robot1 = await MirabufLoader.cacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`MirabufLoader > Real Fetch > Loads Asset ('/api/mira/fields/FRC Field 2023_v7.mi…') 1`] = `"FRC Field 2023 v7"`;
4+
5+
exports[`MirabufLoader > Real Fetch > Loads Asset ('/api/mira/fields/FRC Field 2023_v7.mi…') 2`] = `"60440aa3010e1fa2f12877ae52aafbea68e81d"`;
6+
7+
exports[`MirabufLoader > Real Fetch > Loads Asset ('/api/mira/robots/Dozer_v9.mira') 1`] = `"Dozer v9"`;
8+
9+
exports[`MirabufLoader > Real Fetch > Loads Asset ('/api/mira/robots/Dozer_v9.mira') 2`] = `"fc2094375a8373ee3782ba92ced2f7a60e697f3"`;

0 commit comments

Comments
 (0)