Skip to content

test(v4): verify recompilation when theme file changes#89

Open
colinaaa wants to merge 1 commit intorstackjs:v4from
colinaaa:feat/test-recompilation
Open

test(v4): verify recompilation when theme file changes#89
colinaaa wants to merge 1 commit intorstackjs:v4from
colinaaa:feat/test-recompilation

Conversation

@colinaaa
Copy link
Collaborator

This PR adds test cases to verify that changes to external theme files trigger a recompilation and update the styles correctly.

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial test to ensure the robustness of the build system's handling of external CSS theme files. By simulating modifications to a theme file and verifying that the subsequent build correctly applies these changes, it confirms that the styling pipeline is properly re-evaluating and updating styles, preventing stale visual outputs when theme definitions are altered.

Highlights

  • New Test Case: Added a Playwright test to verify that changes to external theme files correctly trigger a recompilation and update the styles in the build output.
  • Recompilation Verification: The test simulates modifying a theme file (theme.css) between two build cycles and asserts that the CSS properties of an element reflect the updated theme variables after the second build.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • test/recompilation/index.test.ts
    • Added a new Playwright test file.
  • test/recompilation/src/index.css
    • Added a new CSS file for testing purposes.
  • test/recompilation/src/index.js
    • Added a new JavaScript entry file for the test.
  • test/recompilation/src/theme.css
    • Added a new theme CSS file used in the recompilation test.
Activity
  • No human activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds an important integration test to verify that changes to theme files trigger recompilation. The test implementation is sound, but I have a couple of suggestions to improve its robustness and clarity. Specifically, I recommend adding a cleanup mechanism to handle file system side effects and removing some leftover development comments. These changes will make the test more maintainable.

Comment on lines +11 to +59
test('should update styles when theme file changes', async ({ page }) => {
// Reset theme file
fs.writeFileSync(
themePath,
`
@theme {
--color-dynamic: rgb(1, 2, 3);
}
`,
);

const rsbuild = await createRsbuild({
cwd: __dirname,
rsbuildConfig: {
plugins: [pluginTailwindCSS()],
},
});

// First build
await rsbuild.build();
let result = await rsbuild.preview();

await page.goto(result.urls[0]);
let locator = page.locator('#dynamic');
await expect(locator).toHaveCSS('background-color', 'rgb(1, 2, 3)');
await result.server.close();

// Modify theme file
fs.writeFileSync(
themePath,
`
@theme {
--color-dynamic: rgb(4, 5, 6);
}
`,
);

// Second build (reusing instance if possible, or creating new one if that's how tests work)
// The user asked to "Same createRsbuild instance" if possible.
// rsbuild.build() runs the build.
// We can run it again.
await rsbuild.build();
result = await rsbuild.preview(); // New preview server

await page.goto(result.urls[0]);
locator = page.locator('#dynamic');
await expect(locator).toHaveCSS('background-color', 'rgb(4, 5, 6)');
await result.server.close();
});

Choose a reason for hiding this comment

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

medium

This test modifies a file on the file system (theme.css), which is a side effect. If the test fails midway, the file could be left in a modified state, potentially affecting other tests or subsequent local runs. It's a good practice to ensure cleanup, even on failure.

You can use Playwright's test.afterEach hook to restore the file to its original state after the test completes, regardless of whether it passed or failed. This makes the test more robust and self-contained.

Here's how you could implement this:

// At the top of the file
const __dirname = dirname(fileURLToPath(import.meta.url));
const themePath = join(__dirname, 'src/theme.css');
const originalTheme = fs.readFileSync(themePath, 'utf-8');

test.afterEach(() => {
  fs.writeFileSync(themePath, originalTheme);
});

// The test itself remains largely the same
test('should update styles when theme file changes', async ({ page }) => {
  // ...
});

Comment on lines +48 to +51
// Second build (reusing instance if possible, or creating new one if that's how tests work)
// The user asked to "Same createRsbuild instance" if possible.
// rsbuild.build() runs the build.
// We can run it again.

Choose a reason for hiding this comment

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

medium

These comments appear to be development notes and can be removed to improve code clarity. The code itself is self-explanatory in that it's performing a second build.

@colinaaa colinaaa changed the title test: verify recompilation when theme file changes test(v4): verify recompilation when theme file changes Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant