Bootstrap Unit Testing - #1179
Conversation
68c3709 to
06b2bc7
Compare
| // NOTE Unnecessary test that uses URL wrong | ||
| // test("supports URL and history API", () => { | ||
| // globalThis.URL = vi.fn(() => ({ | ||
| // searchParams: { | ||
| // get: vi.fn(), | ||
| // set: vi.fn(), | ||
| // }, | ||
| // })) | ||
| // | ||
| // const mockHistory = { | ||
| // replaceState: vi.fn(), | ||
| // pushState: vi.fn(), | ||
| // } | ||
| // Object.defineProperty(window, "history", { | ||
| // value: mockHistory, | ||
| // configurable: true, | ||
| // }) | ||
| // | ||
| // expect(window.history.replaceState).toBeDefined() | ||
| // expect(window.history.pushState).toBeDefined() | ||
| // }) |
BrandonPacewic
left a comment
There was a problem hiding this comment.
This might be the first case of AI "slop" within the Synthesis codebase, or at least in a PR. Going to combine a bunch of these tests into a single file as I'm seeing a lot of overlap here, should significantly cut down on the number of lines added by this PR.
AlexD717
left a comment
There was a problem hiding this comment.
You are calling expect(screen.getByTestId("main-hud")).toBeDefined() in 5 tests. This is probably unnecessary and I would remove it from all tests but the first one. (A very similar thing is happening with screen.getByTestId("scene").
Seems like these calls are part of verifying the outcome of the previously executed steps in each test? |
In some test it is verifying that the previous steps are correct. However, your third test renders the same exact thing as the first test, with no custom parameters or changes, and then verifies what was already verified in the first test. It verifies a new thing (that container.firstChild is defined) but it doesn't need to very that scene or main hud was defined. |
rutmanz
left a comment
There was a problem hiding this comment.
This might be the first case of AI "slop" within the Synthesis codebase, or at least in a PR. Going to combine a bunch of these tests into a single file as I'm seeing a lot of overlap here, should significantly cut down on the number of lines added by this PR.
Strongly agree with this, it looks like a lot of the tests were created without intention and don't actually test the important parts
| gtag: Mock | ||
| URL: Mock & typeof URL | ||
| testProperty: string |
There was a problem hiding this comment.
Why is anything being globally typed as Mock? I think it's fine to type as Function but vitest stuff should not be put in places that make it relevant to the rest of the codebase
| expect(typeof window.convertAuthToken).toBe("function") | ||
| expect(typeof globalThis.gtag).toBe("function") |
There was a problem hiding this comment.
Aren't you defining both of these as mocks and they will therefore always be defined as functions?
| ) | ||
|
|
||
| expect(screen.getByTestId("test-component")).toBeDefined() | ||
| expect(screen.getByTestId("context-test")).toBeDefined() |
There was a problem hiding this comment.
This tests that they don't error but doesn't test that they're actually providing any context/they're doing what they're expected to do, so I'm not entirely sure what this test is helpful for
| // The theme provider should set CSS custom properties on document root | ||
| // We can't easily test this in JSDOM, but we can verify the component renders | ||
| expect(screen.getByTestId("test-component")).toBeDefined() |
There was a problem hiding this comment.
???
So why does this test exist?
| expect(() => { | ||
| render( | ||
| <ThemeProvider initialThemeName="Default" themes={mockThemes} defaultTheme={mockTheme}> | ||
| <TestComponent /> | ||
| </ThemeProvider> | ||
| ) | ||
| }).not.toThrow() |
| ) | ||
| }).not.toThrow() | ||
|
|
||
| // Test with empty theme object |
There was a problem hiding this comment.
I don't think this is actually a useful test to have if this isn't a scenario that ever occurs. It is, in my opinion, not useful to test edge cases by just checking for an error if those edge cases won't come up, and you can check if they do by just checking if the main app renders
| }, | ||
| })) | ||
|
|
||
| vi.mock("@/components/Scene.tsx", () => ({ |
There was a problem hiding this comment.
Why are all of the components and other relevant files being mocked? Shouldn't we be testing that they all load and render without error?
BrandonPacewic
left a comment
There was a problem hiding this comment.
This branch needs to be manually updated as there were naming changes that are not reflected in git conflicts that are causing the tests to fail.
fb97509 to
2e28c98
Compare
|
I'm going to take over and clean up this PR (@ariesninjadev learned his lesson apparently) |
|
After further consideration, I don't actually think there's much of value in this PR at all. I'm going to close it and start fresh on this ticket. |



Description
This is a branch off of #1175 which I can actually edit to make fixes, since @ariesninjadev was working from a personal fork.
The tests are not my work, I have just fixed the formatting and typing issues.
JIRA Issue