improve cypress integration test for filter musicians
This commit is contained in:
parent
e943a3235e
commit
2de5f3a3c2
|
|
@ -101,7 +101,8 @@ describe('Friends page with data', () => {
|
|||
beforeEach(() => {
|
||||
cy.stubAuthenticate({ id: '2' }); //currentUser id is 2 - people.yaml fixture
|
||||
cy.intercept('POST', /\S+\/filter\?offset=0/, { fixture: 'people_page1' }).as('getPeople_page1');
|
||||
cy.intercept('POST', /\S+\/filter\?offset=11/, { fixture: 'people_page2' }).as('getPeople_page2');
|
||||
cy.intercept('POST', /\S+\/filter\?offset=10/, { fixture: 'people_page2' }).as('getPeople_page2');
|
||||
cy.intercept('POST', /\S+\/filter\?offset=20/, { fixture: 'people_page3' }).as('getPeople_page3');
|
||||
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'person' });
|
||||
});
|
||||
|
||||
|
|
@ -115,11 +116,14 @@ describe('Friends page with data', () => {
|
|||
cy.viewport('macbook-13');
|
||||
});
|
||||
|
||||
it('paginate', () => {
|
||||
it.only('paginate', () => {
|
||||
cy.get('[data-testid=peopleListTable] > tbody tr').should('have.length', 10);
|
||||
cy.wait('@getPeople_page2')
|
||||
cy.get('[data-testid=paginate-next-page]').click();
|
||||
cy.get('[data-testid=peopleListTable] > tbody tr').should('have.length', 20);
|
||||
//cy.get('[data-testid=paginate-next-page]').should('not.exist');
|
||||
cy.get('[data-testid=paginate-next-page]').click();
|
||||
cy.get('[data-testid=peopleListTable] > tbody tr').should('have.length', 30);
|
||||
cy.get('[data-testid=paginate-next-page]').should('not.exist');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@
|
|||
"genres": []
|
||||
}
|
||||
],
|
||||
"offset": 11,
|
||||
"offset": 10,
|
||||
"my_audio_latency": 5,
|
||||
"filter_json": "{\"id\":\"68dcc055-cb5d-40d6-8ed4-66772d1a1a31\",\"user_id\":\"27bd4a30-d1b8-4eea-8454-01a104d59381\",\"foreign_key1_id\":null,\"data_blob\":{\"sort_order\":\"latency\",\"instruments\":[],\"genres\":[],\"concert_gigs\":\"-1\",\"interests\":\"any\",\"studio_sessions\":\"-1\",\"ages\":[],\"skill_level\":\"-1\"}}",
|
||||
"description": "Current Search: Sort = Latency to Me",
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@
|
|||
"genres": []
|
||||
}
|
||||
],
|
||||
"offset": null,
|
||||
"offset": 20,
|
||||
"my_audio_latency": 5,
|
||||
"filter_json": "{\"id\":\"68dcc055-cb5d-40d6-8ed4-66772d1a1a31\",\"user_id\":\"27bd4a30-d1b8-4eea-8454-01a104d59381\",\"foreign_key1_id\":null,\"data_blob\":{\"sort_order\":\"latency\",\"instruments\":[],\"genres\":[],\"concert_gigs\":\"-1\",\"interests\":\"any\",\"studio_sessions\":\"-1\",\"ages\":[],\"skill_level\":\"-1\"}}",
|
||||
"description": "Current Search: Sort = Latency to Me",
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function JKPeopleFilter() {
|
|||
|
||||
const params = useRef({});
|
||||
|
||||
const perPageLimit = 20
|
||||
const perPageLimit = 20;
|
||||
|
||||
const { greaterThan } = useResponsive();
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ function JKPeopleFilter() {
|
|||
|
||||
const { isDirty } = useFormState({ control });
|
||||
|
||||
const hasOffset = () => offset !== null && offset > 0
|
||||
const hasNextPage = () => offset !== null && offset > 0
|
||||
|
||||
const toggle = () => setShow(!show);
|
||||
|
||||
|
|
@ -170,14 +170,13 @@ function JKPeopleFilter() {
|
|||
try {
|
||||
|
||||
if(page.current === 0){
|
||||
console.log("===fetchPeople offset", offset, page.current);
|
||||
dispatch(fetchPeople({ data: params.current, offset: offset || 0, limit: perPageLimit }));
|
||||
page.current += 1
|
||||
}else{
|
||||
if(prefetched.length > 0){
|
||||
dispatch(loadPrefetched());
|
||||
}
|
||||
if(hasOffset()){
|
||||
if(hasNextPage()){
|
||||
dispatch(preFetchPeople({ data: params.current, offset, limit: perPageLimit }));
|
||||
page.current += 1;
|
||||
}
|
||||
|
|
@ -196,7 +195,7 @@ function JKPeopleFilter() {
|
|||
page.current = 0
|
||||
submitPageQuery()
|
||||
}else{
|
||||
if (page.current === 1 && hasOffset()) {
|
||||
if (page.current === 1 && hasNextPage()) {
|
||||
dispatch(preFetchPeople({ data: params.current, offset, limit: perPageLimit }));
|
||||
page.current += 1;
|
||||
}
|
||||
|
|
@ -210,12 +209,6 @@ function JKPeopleFilter() {
|
|||
fetchInstruments();
|
||||
submitPageQuery()
|
||||
}, []);
|
||||
|
||||
// useEffect(() => {
|
||||
// if(offset && offset === 0){
|
||||
// submitPageQuery()
|
||||
// }
|
||||
// }, [offset])
|
||||
|
||||
useEffect(() => {
|
||||
if (resetFilter) {
|
||||
|
|
@ -227,11 +220,9 @@ function JKPeopleFilter() {
|
|||
}
|
||||
}, [resetFilter]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setShowLoadMore(prefetched.length > 0 || hasOffset())
|
||||
}, [prefetched, hasOffset()])
|
||||
setShowLoadMore(prefetched.length > 0 || hasNextPage())
|
||||
}, [prefetched, hasNextPage()])
|
||||
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue