-
Notifications
You must be signed in to change notification settings - Fork 542
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: add page reload judgment #2370
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2370 +/- ##
==========================================
+ Coverage 68.52% 68.79% +0.26%
==========================================
Files 131 131
Lines 3419 3432 +13
Branches 826 833 +7
==========================================
+ Hits 2343 2361 +18
+ Misses 1076 1071 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
need test case add
web/cypress/integration/consumer/batch-create-and-delete-consumer.spec.js
Outdated
Show resolved
Hide resolved
I will modify the simulation operation to send a request to ensure the stability of the test. |
@Baoyuantop @guoqqqi I have updated the test case, and now I can pass the test successfully. Please review it for me again.🤓 |
The structure of the test needs to be more rationalized. |
it('should delete last data and jump to first page', () => { | ||
cy.visit('/'); | ||
cy.contains('Consumer').click(); | ||
cy.wait(500); |
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.
Do we really need to wait for this?
const deleteProto = () => { | ||
cy.wait(500); | ||
cy.contains('Delete').click(); | ||
cy.contains('button', 'Confirm').click(); | ||
cy.get(selector.notification).should('contain', data.deleteProtoSuccess); | ||
cy.get(selector.notificationCloseIcon).click(); | ||
}; |
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.
We can use the custom command from the official documentation, By the way, we do not recommend using wait
https://docs.cypress.io/api/cypress-api/custom-commands
https://docs.cypress.io/api/commands/wait#Wait-for-an-arbitrary-period-of-milliseconds
cy.wait(500); | ||
cy.get(selector.page_item).click(); | ||
cy.wait(500); | ||
deleteProto(); |
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.
deleteProto(); | |
deleteProto(); |
IMO, I think it looks strange the way it's written.
} | ||
}; | ||
|
||
return { paginationConfig, savePageList, checkPageList }; |
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.
Since we have abstracted the pager into a hook, is it enough for us to write a test for the pagination
deleteConsumerSuccess: 'Delete Consumer Successfully', | ||
}; | ||
|
||
beforeEach(() => { |
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.
beforeEach or before?
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
cc @guoqqqi |
cy.visit('/'); | ||
cy.contains('Consumer').click(); | ||
cy.get(selector.page_item).click(); | ||
cy.wait(1000); |
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.
Why wait for 1 s?
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.
@oil-oil ping
cy.contains('Consumer').click(); | ||
cy.get(selector.page_item).click(); | ||
cy.wait(1000); | ||
cy.contains('Delete').click({ force: true }); |
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.
the force: true
will not ensure that the click on delete will be successful, so why use force here?
beforeEach(() => { | ||
cy.login(); | ||
Array.from({ length: 11 }).forEach(async (value, key) => { | ||
const payload = { | ||
content: 'test', | ||
desc: '', | ||
id: `protoId${key}`, | ||
}; | ||
cy.requestWithToken({ method: 'POST', payload, url: '/apisix/admin/proto' }); | ||
}); | ||
}); |
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.
Note that using an array loop in beforeEach
will cause the loop to be run once for each test case run
cy.visit('/'); | ||
cy.contains('Protocol Buffers').click(); | ||
cy.get(selector.page_item).click(); | ||
cy.wait(1000); |
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.
ditto
web/cypress/integration/upstream/table-auto-jump-when-no-data.spec.js
Outdated
Show resolved
Hide resolved
web/src/hooks/usePagination.ts
Outdated
@@ -30,5 +33,14 @@ export default function usePagination() { | |||
history.replace(`${location.pathname}?page=${page}&pageSize=${pageSize}`); | |||
}; | |||
|
|||
return { paginationConfig, savePageList }; | |||
const checkPageList = (ref: MutableRefObject<ActionType | undefined>) => { | |||
const { current, pageSize, total } = ref.current!.pageInfo as PageInfo; |
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.
const { current, pageSize, total } = ref.current!.pageInfo as PageInfo; | |
const { current, pageSize, total } = ref.current?.pageInfo as PageInfo; |
!.
will just remove undefined
and null
from the current
's type. Maybe ?.
is better?
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.
There is no preview here, the code looks ok. |
}; | ||
|
||
before(() => { | ||
cy.login(); |
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.
cy.login(); | |
cy.login().then( () => { cy.requestWithToken({ method: 'PUT', payload, url: '/apisix/admin/consumers' }); | |
}); |
}; | ||
|
||
before(() => { | ||
cy.login(); |
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.
ditto
@LiteSun OK, I'll update it |
cc @LiteSun |
* upstream: (28 commits) docs: update some tips in develop.md (apache#2451) fix: create upstream error when pass host is node and nodes without port (apache#2421) fix: correct data type of filed Active.checks.active.https_verify_certificate (apache#2422) feat: basic support Apache APISIX 2.13.0 (apache#2428) feat: add page reload judgment (apache#2370) docs: Update RPM install package link (apache#2439) docs: Remove hyperlinks from documents (apache#2431) chore(deps): bump actions/upload-artifact from 2 to 3 (apache#2423) fix: consumer without plugins causes page crashes (apache#2437) chore(deps): bump axios from 0.21.1 to 0.21.4 in /web (apache#2420) feat: Modify plugin preview page (apache#2359) chore(deps): bump moment from 2.29.1 to 2.29.2 in /web (apache#2418) chore: use json schema instead hard code (apache#2399) refactor: migrate route tests to e2enew (apache#2411) chore(deps): bump actions/setup-python from 2.3.2 to 3.1.1 (apache#2414) chore: update the year of copyright and fix typo (apache#2417) docs: update online playground url (apache#2416) chore: update README for online demo (apache#2404) refactor: migrate id compatible tests to e2enew (apache#2400) docs: fix invalid link (apache#2366) ... # Conflicts: # api/internal/route.go # web/src/components/Footer/index.tsx
Please answer these questions before submitting a pull request, or your PR will get closed.
What changes will this PR take into?
When the table needs to be reloaded after operation, judge whether there is no data on the current page. If there is no data, move the page number to the previous page.
Related issues
resolve: #2129
Checklist: