2
0

⚗️ Add infinite scroll in results table

This commit is contained in:
Baptiste Arnaud
2022-01-04 12:25:48 +01:00
parent 8ddf608c9e
commit 72454c0f68
9 changed files with 200 additions and 98 deletions

View File

@ -85,24 +85,16 @@ const createTypebots = async () => {
const createResults = () => {
return prisma.result.createMany({
data: [
{
typebotId: 'typebot1',
},
{
typebotId: 'typebot1',
},
{
id: 'result1',
typebotId: 'typebot2',
},
{
id: 'result2',
typebotId: 'typebot2',
},
{
id: 'result3',
typebotId: 'typebot2',
},
...Array.from(Array(200)).map((_, idx) => {
const today = new Date()
return {
id: `result${idx}`,
typebotId: 'typebot2',
createdAt: new Date(
today.setTime(today.getTime() + 1000 * 60 * 60 * 24 * idx)
),
}
}),
],
})
}
@ -110,24 +102,12 @@ const createResults = () => {
const createAnswers = () => {
return prisma.answer.createMany({
data: [
{
resultId: 'result1',
content: 'content 1',
...Array.from(Array(200)).map((_, idx) => ({
resultId: `result${idx}`,
content: `content${idx}`,
stepId: 'step1',
blockId: 'block1',
},
{
resultId: 'result2',
content: 'content 2',
stepId: 'step1',
blockId: 'block1',
},
{
resultId: 'result3',
content: 'content 3',
stepId: 'step1',
blockId: 'block1',
},
})),
],
})
}

View File

@ -1,6 +1,9 @@
describe('ResultsPage', () => {
before(() => {
cy.intercept({ url: '/api/typebots/typebot2/results?', method: 'GET' }).as(
cy.intercept({ url: '/api/typebots/typebot2/results*', method: 'GET' }).as(
'getResults'
)
cy.intercept({ url: '/api/typebots/typebot2/results*', method: 'GET' }).as(
'getResults'
)
})
@ -13,19 +16,32 @@ describe('ResultsPage', () => {
cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot2/results')
cy.wait('@getResults')
cy.findByText('content 2').should('exist')
cy.findByText('content 3').should('exist')
cy.findByText('content198').should('exist')
cy.findByText('content197').should('exist')
cy.findAllByRole('checkbox').eq(2).check({ force: true })
cy.findAllByRole('checkbox').eq(3).check({ force: true })
cy.findByRole('button', { name: 'Delete 2' }).click()
cy.findByRole('button', { name: 'Delete 2' }).click({ force: true })
cy.findByRole('button', { name: 'Delete' }).click()
cy.findByText('content 2').should('not.exist')
cy.findByText('content 3').should('not.exist')
cy.findByText('content198').should('not.exist')
cy.findByText('content197').should('not.exist')
cy.wait(200)
cy.findAllByRole('checkbox').first().check({ force: true })
cy.findByRole('button', { name: 'Delete 198' }).click({ force: true })
cy.findByRole('button', { name: 'Delete' }).click()
cy.findAllByRole('row').should('have.length', 1)
})
it.only('submissions table should have infinite scroll', () => {
it('submissions table should have infinite scroll', () => {
cy.signIn('test2@gmail.com')
cy.visit('/typebots/typebot2/results')
cy.wait('@getResults')
cy.findByText('content50').should('not.exist')
cy.findByText('content199').should('exist')
cy.findByTestId('table-wrapper').scrollTo('bottom')
cy.findByText('content149').should('exist')
cy.findByTestId('table-wrapper').scrollTo('bottom')
cy.findByText('content99').should('exist')
cy.findByTestId('table-wrapper').scrollTo('bottom')
cy.findByText('content50').should('exist')
cy.findByText('content0').should('exist')
})
})