-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Support duplicate one existing Route #1558
Conversation
38cc523
to
fb85518
Compare
api/internal/handler/route/route.go
Outdated
@@ -307,6 +307,12 @@ func generateLuaCode(script map[string]interface{}) (string, error) { | |||
|
|||
func (h *Handler) Create(c droplet.Context) (interface{}, error) { | |||
input := c.Input().(*entity.Route) | |||
// check duplicate name | |||
if err := h.checkDuplicateName(c, input.Name, ""); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add this check for Update
too. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
need some test cases for duplicate check, thanks. @batman-ezio |
Codecov Report
@@ Coverage Diff @@
## master #1558 +/- ##
===========================================
- Coverage 72.46% 51.77% -20.70%
===========================================
Files 134 38 -96
Lines 5738 2650 -3088
Branches 666 0 -666
===========================================
- Hits 4158 1372 -2786
+ Misses 1337 1090 -247
+ Partials 243 188 -55
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@nic-chen after I check duplicate name in create/update route api. some test cases failed. I think they are use the same route name to test before. some errors throw from the route test are very strange , like this
I have change the route name but still got this. can you help? |
hi @batman-ezio , you need to mock you could refer to: apisix-dashboard/api/internal/handler/plugin_config/plugin_config_test.go Lines 694 to 709 in 2de2c72
|
hi @Jaycean I found some test case use the same route name or empty route name for e2e test, test cases begin to bump up after my fix one by one |
Yes, 400 is usually caused by wrong data format or type. In E2E test, a route ID r1 is usually created and passed, and the route with ID r1 will be deleted, so there is no problem with the same name. |
@batman-ezio would you mind if we modify your code on your branch? |
no, please the frontend e2e test will be fixed after merge this PR #1559 |
oh, no, we should not do that. |
ok, can you help to fix the rest test cases, thanks |
d4753d8
to
65f3a7c
Compare
sure, my pleasure. will update later. |
thanks. I have squashed all my test case commits into one commit, and rebased from master (which includes the latest frontend e2e fix), but the test case still failed |
I will try to fix backend CI this afternoon. |
ok |
CI failed, wait for @nic-chen check this. |
There are some logical problems in E2E test cases, need more time resolve |
backend CI had been resolved. |
ping @LiteSun |
db8b1b2
to
fda5d75
Compare
web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js
Show resolved
Hide resolved
web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js
Outdated
Show resolved
Hide resolved
please resolve conflicts |
fixed |
}); | ||
|
||
it('should delete the route', function () { | ||
cy.visit('/routes/list'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LiteSun Do we need to visit this page by clicking Sidebar Menu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
and there is a UE enhancement suggestion:
when copying the route user in the page of first step and click [Next] button directly, they will get duplicate route name
error, maybe leaving the route name blank would be a better choice.
ok, then let me merge. |
thanks! @batman-ezio |
Please answer these questions before submitting a pull request
Why submit this pull request?
Support duplicate one existing Route #1487
New feature or improvement
1: duplicate button from route list
2: check duplicate name from POST route api
Describe the details and related test reports.
1:Click duplicate button from the router list, the address will be
![image](https://user-images.githubusercontent.com/80014017/110097045-90769d80-7dd9-11eb-9c73-52989067d690.png)
routes/:rid/duplicate
2: update the name to make sure it's no duplicated
![image](https://user-images.githubusercontent.com/80014017/110097178-b56b1080-7dd9-11eb-9509-bfe92db8eb4b.png)
3: submit data, return to the list. The new route will be there