-
Notifications
You must be signed in to change notification settings - Fork 196
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
test(e2e): test sync percentage #2264
Changes from 2 commits
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,5 +1,5 @@ | ||
{ | ||
"31337": { | ||
"address": "0x7de562d80d6c8672aa32654af67884f411976593" | ||
"address": "0xad97505a508daf984fe60302109e0115e544b267" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { rpcHttpUrl } from "./setup/constants"; | ||
import { deployContracts } from "./setup"; | ||
import { createAsyncErrorHandler } from "./asyncErrors"; | ||
import { createWorld, getComponentValueStrict } from "@latticexyz/recs"; | ||
import { singletonEntity, syncToRecs } from "@latticexyz/store-sync/recs"; | ||
import mudConfig from "../contracts/mud.config"; | ||
import { transportObserver } from "@latticexyz/common"; | ||
import { ClientConfig, createPublicClient, http } from "viem"; | ||
import { getNetworkConfig } from "../client-vanilla/src/mud/getNetworkConfig"; | ||
|
||
const address = "0xad97505a508daf984fe60302109e0115e544b267"; | ||
|
||
describe("createStoreSync", () => { | ||
const asyncErrorHandler = createAsyncErrorHandler(); | ||
|
||
it("creates the sync", async () => { | ||
asyncErrorHandler.resetErrors(); | ||
|
||
await deployContracts(rpcHttpUrl); | ||
|
||
const networkConfig = await getNetworkConfig(); | ||
const clientOptions = { | ||
chain: networkConfig.chain, | ||
transport: transportObserver(http(rpcHttpUrl ?? undefined)), | ||
pollingInterval: 1000, | ||
} as const satisfies ClientConfig; | ||
|
||
const publicClient = createPublicClient(clientOptions); | ||
|
||
const world = createWorld(); | ||
const { components } = await syncToRecs({ | ||
world, | ||
config: mudConfig, | ||
address, | ||
publicClient, | ||
}); | ||
|
||
expect(getComponentValueStrict(components.SyncProgress, singletonEntity).percentage).toMatchInlineSnapshot(` | ||
100 | ||
`); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ import { Page, expect } from "@playwright/test"; | |
export async function waitForInitialSync(page: Page) { | ||
const syncStep = page.locator("#sync-step"); | ||
await expect(syncStep).toHaveText("live"); | ||
const syncProgress = page.locator("#sync-percentage"); | ||
await expect(syncProgress).toHaveText("100"); | ||
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. do we need to test for this? I kinda wonder about keeping the "live" indicator (caught up) separate from the percentage synced, so you can e.g. hide your load screen (because "live") but potentially show how "up to date" you are (percentage) 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. That makes sense - in that case I think we can remove this test. |
||
} |
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.
I assume this is here because we haven't created all the scaffolding (anvil, database, etc.) in store-sync tests yet?
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.
Yes -
store-sync
doesn't have a contracts folder,execa
, etc. I kind of like that it is more pure but we do riske2e
getting bloated with tests that are not fully "end to end"