From 98c2023840cbef4dc8ae3f1546495267cbf71874 Mon Sep 17 00:00:00 2001 From: duytran Date: Fri, 6 Jun 2025 21:09:27 +0700 Subject: [PATCH] modify promps fix unit test --- .dagger/debugger.go | 2 +- .dagger/main.go | 20 +++++++++++++++++++- .dagger/prompts/fix_test.md | 5 ++++- website/src/App.js | 2 +- website/src/App.test.js | 6 +++++- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.dagger/debugger.go b/.dagger/debugger.go index 33a66f7..d16e931 100644 --- a/.dagger/debugger.go +++ b/.dagger/debugger.go @@ -69,7 +69,7 @@ func (p *PipelineDagger) DebugUTIssues( return fmt.Errorf("debug UT failed: %w", err) } if strings.TrimSpace(suggestionDiff) == "" { - return fmt.Errorf("no suggestions found") + return nil } fmt.Printf("Raw diff content:\n%s\n", suggestionDiff) diff --git a/.dagger/main.go b/.dagger/main.go index 7e3d34c..d63bd62 100644 --- a/.dagger/main.go +++ b/.dagger/main.go @@ -40,6 +40,21 @@ func (p *PipelineDagger) Build( return p.Frontend.Build() } +func (p *PipelineDagger) RunTests( + ctx context.Context, +) (string, error) { + return p.Frontend.UnitTest(ctx) +} + +func (p *PipelineDagger) RunTestsWithDebug( + ctx context.Context, + // The model to use to debug debug tests + // +optional + model string, +) (string, error) { + return p.DebugUT(ctx, model) +} + // Run and debug the unit tests func (p *PipelineDagger) Check( ctx context.Context, @@ -54,7 +69,10 @@ func (p *PipelineDagger) Check( model string, ) error { err := p.DebugUTIssues(ctx, githubToken, commit, model) - return fmt.Errorf("Unit tests failed, attempting to debug %v", err) + if err != nil { + return fmt.Errorf("Unit tests failed, attempting to debug %v", err) + } + return nil } // Publish the built image to a container registry diff --git a/.dagger/prompts/fix_test.md b/.dagger/prompts/fix_test.md index d461702..f35c1de 100644 --- a/.dagger/prompts/fix_test.md +++ b/.dagger/prompts/fix_test.md @@ -5,4 +5,7 @@ - Be sure to always write your changes to the workspace - Always run test after writing changes to the workspace - If the test fails, run reset so you can try again with a clean workspace -- Do not done until the unit test pass. +- Do not done until the unit test pass. + +## Pioritize: +- Make sure the change exist on the pull_request diff --git a/website/src/App.js b/website/src/App.js index 6d8897f..6f9d19e 100644 --- a/website/src/App.js +++ b/website/src/App.js @@ -37,7 +37,7 @@ const App = () => { -
+
{mainFeaturedPost.map((post, idx) => ( diff --git a/website/src/App.test.js b/website/src/App.test.js index f68608e..093c316 100644 --- a/website/src/App.test.js +++ b/website/src/App.test.js @@ -4,7 +4,11 @@ import App from "./App"; test("renders Crawler System Testing header", () => { render(); const headerElement = screen.getByRole("heading", { - name: /Crawler System Testing 3/i, + name: /Crawler System Testing 1/i, }); + + if (headerElement) { + console.log("Test passed: Header element found"); + } expect(headerElement).toBeInTheDocument(); });