From 2e087c1bc13f669d5fa26d1785af4933d35f7fe1 Mon Sep 17 00:00:00 2001 From: Leonardo Santos Date: Thu, 2 May 2024 10:08:53 -0300 Subject: [PATCH] test(useQuery): ensure updateQuery can modify cache --- .../src/components/UpdateQuery.vue | 141 ++++++++++++++++++ .../test-e2e-composable-vue3/src/router.ts | 4 + .../tests/e2e/specs/updateQuery.cy.ts | 30 ++++ 3 files changed, 175 insertions(+) create mode 100644 packages/test-e2e-composable-vue3/src/components/UpdateQuery.vue create mode 100644 packages/test-e2e-composable-vue3/tests/e2e/specs/updateQuery.cy.ts diff --git a/packages/test-e2e-composable-vue3/src/components/UpdateQuery.vue b/packages/test-e2e-composable-vue3/src/components/UpdateQuery.vue new file mode 100644 index 00000000..3fc19dde --- /dev/null +++ b/packages/test-e2e-composable-vue3/src/components/UpdateQuery.vue @@ -0,0 +1,141 @@ + + + diff --git a/packages/test-e2e-composable-vue3/src/router.ts b/packages/test-e2e-composable-vue3/src/router.ts index 0ac28b7d..bd92a95e 100644 --- a/packages/test-e2e-composable-vue3/src/router.ts +++ b/packages/test-e2e-composable-vue3/src/router.ts @@ -93,5 +93,9 @@ export const router = createRouter({ layout: 'blank', }, }, + { + path: '/update-query', + component: () => import('./components/UpdateQuery.vue'), + }, ], }) diff --git a/packages/test-e2e-composable-vue3/tests/e2e/specs/updateQuery.cy.ts b/packages/test-e2e-composable-vue3/tests/e2e/specs/updateQuery.cy.ts new file mode 100644 index 00000000..ed7ee75d --- /dev/null +++ b/packages/test-e2e-composable-vue3/tests/e2e/specs/updateQuery.cy.ts @@ -0,0 +1,30 @@ +describe('updateQuery', () => { + beforeEach(() => { + cy.task('db:reset') + cy.visit('/update-query') + }) + + it('should add new message to cache using updateQuery', () => { + cy.get('.channel-btn').eq(0).click() + cy.get('.message-input').type('hello 1') + cy.get('.message').should('have.lengthOf', 0) + cy.get('.send-message-btn').click() + cy.get('.message').should('have.lengthOf', 1) + cy.get('.message-input').type('hello 2') + cy.get('.send-message-btn').click() + cy.get('.message').should('have.lengthOf', 2) + cy.contains('.message', 'hello 1') + cy.contains('.message', 'hello 2') + + cy.get('.channel-btn').eq(1).click() + cy.get('.message-input').type('hello 3') + cy.get('.message').should('have.lengthOf', 0) + cy.get('.send-message-btn').click() + cy.get('.message').should('have.lengthOf', 1) + cy.get('.message-input').type('hello 4') + cy.get('.send-message-btn').click() + cy.get('.message').should('have.lengthOf', 2) + cy.contains('.message', 'hello 3') + cy.contains('.message', 'hello 4') + }) +})