quasar icon indicating copy to clipboard operation
quasar copied to clipboard

QSelect does not render certain items in test environment

Open rmehner opened this issue 6 years ago • 11 comments
trafficstars

Describe the bug

We're seeing a problem that when we use QSelect with current Cypress (3.6.1) on both Chrome stable (78) and Canary (80), QSelect's virtual scrolling does not render all items, which leads to this:

quasar-select 2019-11-15 11-46-52

Codepen/jsFiddle/Codesandbox (required)

I don't have that, but a full repo that you can clone and check out yourself: https://github.com/rmehner/quasar-select-cypress

To Reproduce

Steps to reproduce the behavior:

  1. Init quasar app (quasar init qselect-demo) with standard options
  2. Add Cypress to app (quasar ext add @quasar/testing-e2e-cypress), say yes to everything
  3. Edit src/pages/Index.vue to look like this:
<template>
  <q-page class="flex flex-center">
    <q-select outlined label="Number" :options="options" />
  </q-page>
</template>

<script>
export default {
  name: "PageIndex",
  data() {
    return {
      options: [...Array(5000).keys()]
    };
  }
};
</script>
  1. Add cypress test test/cypress/integration/home/init.spec.js:
import * as ctx from  '../../../../quasar.conf.js'

describe('Landing', () => {
  beforeEach(() => {
    cy.visit('/')
  })

  it('.should() - select the number', () => {
    cy.get('.q-page')
      .contains('Number')
      .within(() => {
        cy.contains('arrow_drop_down').click()
      })

    cy.get('.q-menu')
      .scrollTo('bottom')
      .contains('4999')
      .click()
  })
})
  1. Remove Chrome:: Hack for shaking AUT from test/cypress/plugins/index.js, as this will break current Cypress versions.
  2. Start server quasar dev
  3. Run npm run test:e2e
  4. Click init.spec.js in the opened browser for Cypress
  5. See that some items are not rendered in the list

Expected behavior

All items should be rendered, just like it normally does in the browser.

Platform (please complete the following information): OS: macOS 10.14.6 (although we're also seeing this on other machines that run Win10 and Linux) Node: 12.13.0 NPM: 6.11.1 Yarn: - Browsers: Chrome 78 / Chrome 80 iOS: - Android: - Electron: -

rmehner avatar Nov 15 '19 11:11 rmehner

Btw. we've tried to use the command that the quasar plugin for cypress creates, but that one doesn't seem to be compatible to current Quasar versions.

rmehner avatar Nov 15 '19 11:11 rmehner

I don't know how Cypress works, but could you try adding a delay between .scrollTo('bottom') and .contains('4999')...? When scrolling there is a $nextTick between the scroll and the rendering.

pdanpdan avatar Nov 15 '19 13:11 pdanpdan

Any news on this? Does it work with the delay?

pdanpdan avatar Nov 19 '19 08:11 pdanpdan

Added a little wait of 5000ms, still no dice.

diff --git a/test/cypress/integration/home/init.spec.js b/test/cypress/integration/home/init.spec.js
index 2766544..10f1cc2 100755
--- a/test/cypress/integration/home/init.spec.js
+++ b/test/cypress/integration/home/init.spec.js
@@ -14,6 +14,10 @@ describe('Landing', () => {
 
     cy.get('.q-menu')
       .scrollTo('bottom')
+
+    cy.wait(5000)
+
+    cy.get('.q-menu')
       .contains('4999')
       .click()
   })

Window looks like this:

quasar-select 2019-11-19 11-00-20

I just realised that this issue might be better suited in https://github.com/quasarframework/quasar-testing, sorry if this is the wrong repo to report this in.

rmehner avatar Nov 19 '19 10:11 rmehner

Are you doing a render when waiting? I don't know exactly how the testing framework works, but the virtual list needs a tick to re-render the content.

pdanpdan avatar Nov 27 '19 08:11 pdanpdan

We don't explicitly render, as Cypress is like remote control for Chrome and if we wait, it just sits there and wait and Chrome does its thing, so the tick should happen.

rmehner avatar Nov 27 '19 09:11 rmehner

👋

We've tried around a little and extended the example over at https://github.com/rmehner/quasar-select-cypress

Things we've found out / extra info:

  • We've added a progress bar that updates on nextTick to see if we miss ticks, but ticks are running fine, so that's out
  • We've added a @virtual-scroll event handler on the select and when we use it in the browser, we see 4 scroll events in the log, but with Cypress we only ever see one, no matter how often we scroll in the element. Not sure if what this tells us, but just throwing it out here.
  • when we set virtual-scroll-item-size on the element to 0 it works in cypress. If we leave it out, it does not work. I have a hunch that calculating the right heights for the virtual scrolling seems to no work properly within the Cypress environment.

Does this information help you in any case?

(We've also updated to latest quasar, just to rule out that there is a bug in the older version)

rmehner avatar Dec 04 '19 15:12 rmehner

After the release of v1.8.4 tomorrow can you please try to call the new refresh method of QSelect after scrolling? - it might fix the things for you also

pdanpdan avatar Jan 30 '20 17:01 pdanpdan

I'll close it because a lot changed since the last update. If you have the same problem please comment here to reopen.

pdanpdan avatar Jul 06 '20 15:07 pdanpdan

I have the same problem with quasar 2.0.3, I don't use @ virtual-scroll, however only the last 20-30 options are rendered.

it works correctly only if virtual-scroll-item-size="0" is set

Nervus86 avatar Aug 23 '21 14:08 Nervus86

I came across this problem using a table with virtual scroll. In the end, I disabled modifyObstructiveCode in the Cypress configuration and the problem was immediately solved.

I'm guessing that something in the virtual scroll code is similar enough to a framebusting technique that Cypress is by default removing it.

kamcnally avatar Feb 14 '22 16:02 kamcnally