Skip to content

Bootstrap Unit Testing - #1179

Closed
azaleacolburn wants to merge 12 commits into
devfrom
aries/1942/bootstrap-testing
Closed

Bootstrap Unit Testing#1179
azaleacolburn wants to merge 12 commits into
devfrom
aries/1942/bootstrap-testing

Conversation

@azaleacolburn

@azaleacolburn azaleacolburn commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

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

@azaleacolburn
azaleacolburn requested review from a team as code owners June 27, 2025 19:53
@azaleacolburn
azaleacolburn force-pushed the aries/1942/bootstrap-testing branch 2 times, most recently from 68c3709 to 06b2bc7 Compare June 27, 2025 19:55
@Dhruv-0-Arora Dhruv-0-Arora added the testing Relates to testing; anywhere from unit testing to E2E label Jun 27, 2025
Comment on lines +77 to +97
// 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()
// })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

@AlexD717

Copy link
Copy Markdown
Member

It appears that you have multiple unit tests that test practically the same thing, particularly in main.test.tsx.
SameTest

Comment thread fission/src/test/bootstrap/main.test.tsx Outdated

@BrandonPacewic BrandonPacewic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AlexD717 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel that there are some tests in Synthesis.test.tsx that could be merged into one test
Screenshot 2025-07-07 081955
Screenshot 2025-07-07 081939

@AlexD717 AlexD717 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

@itspvty

itspvty commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

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?

@AlexD717

AlexD717 commented Jul 9, 2025

Copy link
Copy Markdown
Member

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.

@itspvty
itspvty requested a review from AlexD717 July 9, 2025 20:08

@rutmanz rutmanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread fission/src/global.d.ts
Comment on lines +5 to +7
gtag: Mock
URL: Mock & typeof URL
testProperty: string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +33 to +34
expect(typeof window.convertAuthToken).toBe("function")
expect(typeof globalThis.gtag).toBe("function")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +206 to +208
// 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()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

So why does this test exist?

Comment on lines +222 to +228
expect(() => {
render(
<ThemeProvider initialThemeName="Default" themes={mockThemes} defaultTheme={mockTheme}>
<TestComponent />
</ThemeProvider>
)
}).not.toThrow()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

)
}).not.toThrow()

// Test with empty theme object

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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", () => ({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BrandonPacewic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Dhruv-0-Arora
Dhruv-0-Arora self-requested a review July 14, 2025 20:23
@azaleacolburn
azaleacolburn force-pushed the aries/1942/bootstrap-testing branch from fb97509 to 2e28c98 Compare July 15, 2025 20:26
@azaleacolburn

Copy link
Copy Markdown
Contributor Author

I'm going to take over and clean up this PR (@ariesninjadev learned his lesson apparently)

@azaleacolburn

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Relates to testing; anywhere from unit testing to E2E

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants