Chore/refactor req builder test#41
Conversation
the project often requires the script to be saved to the collection.
made all locator search in request build section as parent added test script locators added test script writing feature seperate getrequestResult from apiwrap combined getreResult with send button added fill header for request
includes: set auth variables to request login token request set token to env var user login
dependent models needed restructuring
Dancode-188#32 (Dancode-188#36) Added comprehensive URL validation to prevent TypeError when users type partial or invalid URLs in the request input field. ## Changes ### Core Fix - Added URL validation helper functions in src/lib/url-validator.ts - Updated RequestBuilder to safely handle invalid URLs in tab name generation - Prevents crash when typing partial URLs like "h", "ht", "https:", etc. ### User Experience Improvements - Added visual feedback: red border when URL is invalid - Added inline error message: "Please enter a valid HTTP(S) URL" - Smart validation: allows template variables like {{baseUrl}} for environment variables - Non-blocking: users can still attempt to send requests with variables ### Testing - Added comprehensive test suite with 30+ test cases - Tests cover: valid/invalid URLs, template variables, edge cases, partial URLs - All tests verify the fix handles the crash scenario ## Technical Details The crash occurred in a useEffect hook that tried to construct a URL object without validation. The URL constructor throws TypeError for invalid input, causing the app to crash on every keystroke as users typed. The fix uses a three-pronged approach: 1. Validate URLs before constructing URL objects 2. Allow template variables for environment variable substitution 3. Gracefully fallback to displaying raw URL string for invalid URLs Fixes Dancode-188#32
fix: prevent crash when entering invalid URLs in request builder, fix…
WHY: - test sometime fail in CI - so throttling cpu will help - configured throttling only for local
to avoid flaky test and occurance of multiple instance need to wait till one of the button instance is closed.
with selecting locators with same name in different section using these could come handy
optional parameter collection and request name helpfull to select already present request mimics user behaviour better
to select the environemnt the button is in the top header section created a locator to be used as parent
inlcuded auth helper, variables, script
added 28 new test taergeting request builder section rearranged tests into targeting function, components and user workflows added new functionality of adding headers and variables for testing identified Dancode-188#38 Dancode-188#39 bug
page.goto('/') repeated manytimes
as each test began with page.goto
now the page from index itself will premove to baseurl
this avoided the need to include pagegoto
all fixtures are merged in index.ts now all fixture will be available if imported from index.ts
now the page is imported from base instead of playwright/test advantage being page already in baseurl
more efficient as it is run only once per test
Dancode-188
left a comment
There was a problem hiding this comment.
Hey @biocodeit,
This is really solid work. I'm going to merge this one.
I can see the progression from #40 to here - you took the comprehensive test suite and made it more maintainable. The base fixture that handles page.goto('/') automatically is a smart move. I was looking at the test files and noticed you removed that repetition everywhere, which is exactly what we want.
The fixture index is a nice touch too. Makes imports cleaner and gives us a single place to manage fixture dependencies going forward.
One thing I really appreciate: your commit messages actually explain why you made changes, not just what changed. "More efficient as it is run only once per test" - that's the kind of context that helps when someone (including future you) needs to understand these decisions later.
This supersedes #35, #37, and #40, so I'll close those with notes. The test coverage you've built here is comprehensive - 28 tests for the request builder component alone, plus the user workflow tests. And you found two bugs in the process (#38, #39), which shows the tests are actually exercising the app properly.
Merging now. Great work on this entire series of PRs - the evolution from #35 to here shows good iterative thinking
reduced redundant code in req builder logic.
added base fixture with page.goto('/')