Skip to content

test: reload config when imported file changes#34

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/test-config-import-reload
Jul 12, 2026
Merged

test: reload config when imported file changes#34
chenjiahan merged 1 commit into
mainfrom
chenjiahan/test-config-import-reload

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

This PR adds a minimal integration test for config dependency watching. It changes a file imported by the Rstack config and verifies that the development server reloads.

Related Links

@chenjiahan chenjiahan merged commit ad63bb0 into main Jul 12, 2026
4 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/test-config-import-reload branch July 12, 2026 03:44
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an integration test that starts the dev server with a temporary configuration importing another file, waits for the initial build, modifies the imported file, and verifies the expected server restart log within a 30-second timeout.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the new integration test for config reloads on imported file changes.
Description check ✅ Passed The description matches the changeset by describing the config dependency watching test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chenjiahan/test-config-import-reload

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/rstack/test/config/reload-app-config/index.test.ts`:
- Around line 52-75: Update the test case around “should reload config when an
imported file changes” to remove test-temp-import.config.ts and
test-temp-imported.ts before setup, then wrap execution in a finally block that
deletes both files after completion or failure. Follow the existing cleanup
pattern from the first test and preserve the current watcher assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: da86d4a5-6097-4a87-8c69-72f896e1ed09

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0a321 and c7195f5.

📒 Files selected for processing (1)
  • packages/rstack/test/config/reload-app-config/index.test.ts

Comment on lines +52 to +75
test('should reload config when an imported file changes', async ({ execCliAsync, logHelper }) => {
const configFile = path.join(import.meta.dirname, 'test-temp-import.config.ts');
const importedFile = path.join(import.meta.dirname, 'test-temp-imported.ts');

await writeFile(importedFile, '');
await writeFile(
configFile,
`import { define } from 'rstack';
import './test-temp-imported.ts';

define.app({
server: { port: ${await getRandomPort()} },
});
`,
);

execCliAsync('dev --config test-temp-import.config.ts');
await logHelper.expectBuildEnd();
logHelper.clearLogs();

await writeFile(importedFile, '// changed\n');

await logHelper.expectLog('restarting server as test-temp-imported.ts changed');
}, 30_000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add cleanup of temp files before and after the test.

The new test creates test-temp-import.config.ts and test-temp-imported.ts but never removes them. The first test in this file cleans up its temp files at the start (lines 12–14); this test should follow the same pattern and also clean up after the test to avoid leaving artifacts on success or failure. Stale files from a failed previous run could interfere with file watchers or import resolution.

🧹 Proposed fix: add cleanup at start and in finally block
 test('should reload config when an imported file changes', async ({ execCliAsync, logHelper }) => {
   const configFile = path.join(import.meta.dirname, 'test-temp-import.config.ts');
   const importedFile = path.join(import.meta.dirname, 'test-temp-imported.ts');
 
+  await rm(configFile, { force: true });
+  await rm(importedFile, { force: true });
+
+  try {
     await writeFile(importedFile, '');
     await writeFile(
       configFile,
       `import { define } from 'rstack';
 import './test-temp-imported.ts';
 
 define.app({
   server: { port: ${await getRandomPort()} },
 });
 `,
     );
 
     execCliAsync('dev --config test-temp-import.config.ts');
     await logHelper.expectBuildEnd();
     logHelper.clearLogs();
 
     await writeFile(importedFile, '// changed\n');
 
     await logHelper.expectLog('restarting server as test-temp-imported.ts changed');
+  } finally {
+    await rm(configFile, { force: true });
+    await rm(importedFile, { force: true });
   }
 }, 30_000);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should reload config when an imported file changes', async ({ execCliAsync, logHelper }) => {
const configFile = path.join(import.meta.dirname, 'test-temp-import.config.ts');
const importedFile = path.join(import.meta.dirname, 'test-temp-imported.ts');
await writeFile(importedFile, '');
await writeFile(
configFile,
`import { define } from 'rstack';
import './test-temp-imported.ts';
define.app({
server: { port: ${await getRandomPort()} },
});
`,
);
execCliAsync('dev --config test-temp-import.config.ts');
await logHelper.expectBuildEnd();
logHelper.clearLogs();
await writeFile(importedFile, '// changed\n');
await logHelper.expectLog('restarting server as test-temp-imported.ts changed');
}, 30_000);
test('should reload config when an imported file changes', async ({ execCliAsync, logHelper }) => {
const configFile = path.join(import.meta.dirname, 'test-temp-import.config.ts');
const importedFile = path.join(import.meta.dirname, 'test-temp-imported.ts');
await rm(configFile, { force: true });
await rm(importedFile, { force: true });
try {
await writeFile(importedFile, '');
await writeFile(
configFile,
`import { define } from 'rstack';
import './test-temp-imported.ts';
define.app({
server: { port: ${await getRandomPort()} },
});
`,
);
execCliAsync('dev --config test-temp-import.config.ts');
await logHelper.expectBuildEnd();
logHelper.clearLogs();
await writeFile(importedFile, '// changed\n');
await logHelper.expectLog('restarting server as test-temp-imported.ts changed');
} finally {
await rm(configFile, { force: true });
await rm(importedFile, { force: true });
}
}, 30_000);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/rstack/test/config/reload-app-config/index.test.ts` around lines 52
- 75, Update the test case around “should reload config when an imported file
changes” to remove test-temp-import.config.ts and test-temp-imported.ts before
setup, then wrap execution in a finally block that deletes both files after
completion or failure. Follow the existing cleanup pattern from the first test
and preserve the current watcher assertions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7195f5adc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

await writeFile(
configFile,
`import { define } from 'rstack';
import './test-temp-imported.ts';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Assert the changed import affects the config

Because the imported file is only loaded for side effects and the assertion only waits for the restart log, this test can pass even if the dev server notices the dependency but reloads the config with stale imported values. In the scenario this is meant to cover—an imported config helper changes—the regression would still slip through; make the imported module export an observable config value, change it, and assert the post-restart build/server reflects the new value.

Useful? React with 👍 / 👎.

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