Skip to content
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

API mount can't render the Element-ui component Pagination #1163

Closed
colinzxz opened this issue Mar 1, 2019 · 7 comments
Closed

API mount can't render the Element-ui component Pagination #1163

colinzxz opened this issue Mar 1, 2019 · 7 comments
Labels

Comments

@colinzxz
Copy link

colinzxz commented Mar 1, 2019

Version

1.0.0-beta.20

Reproduction link

https://codesandbox.io/s/nn28lx9r80

Steps to reproduce

  1. yarn test:unit test/unit/Pagination.spec.js
  2. it throw the error
    [Vue warn]: Error in mounted hook: "TypeError: Cannot read property '$el' of undefined"

What is expected?

mount the component Pagination success

What is actually happening?

it can't render success

@eddyerburgh
Copy link
Member

This issue is caused by the transition stub added by Vue Test Utils. You can solve it by unstubbing the transition component:

const wrapper = mount(Pagination, { 
  stubs: { transition: false } 
})

transition is stubbed to allow synchronous updating, but it is removed in the latest version, which removes sync mode (see #1137).

@colinzxz
Copy link
Author

colinzxz commented Mar 4, 2019

when I re-render the component, it throw another error.

[Vue warn]: Error in callback for immediate watcher "pageSize": "TypeError: Cannot read property '$scopedSlots' of undefined"

the test code https://codesandbox.io/s/mw661m198:

describe("Pagination.vue", () => {
  it("render", () => {
    const wrapper = mount(Pagination, {
      stubs: {
        transition: false
      }
    });

    expect(wrapper.isVueInstance()).toBe(true);
  });

  it("rerender", () => {
    const wrapper = mount(Pagination, {
      stubs: {
        transition: false
      }
    });
  });
});

@colinzxz
Copy link
Author

colinzxz commented Mar 4, 2019

I got a solution:

const wrapper = mount(Pagination, {
   sync: false,
   stubs: { transition: false }
 });

@garyo
Copy link
Contributor

garyo commented May 10, 2019

@eddyerburgh writes:

This issue is caused by the transition stub added by Vue Test Utils. You can solve it by unstubbing the transition component:

const wrapper = mount(Pagination, { 
  stubs: { transition: false } 
})

transition is stubbed to allow synchronous updating, but it is removed in the latest version, which removes sync mode (see #1137).

However, in typescript, you can't pass stubs: { transition: false } as an option to mount. The type declaration is:

type Stubs = {
  [key: string]: Component | string | true
} | string[]

So you have to pass a component, or a string, or true. That means I can't use this workaround as written. Any other ideas or ways to accomplish this?

@garyo
Copy link
Contributor

garyo commented May 10, 2019

I changed @vue/test-utils/types/index.d.ts to accept false as a stub value, and tried the above workaround. But I still get the same error:

LoadProjectDialog.vue › emits input event on cancel

    TypeError: Cannot read property '$scopedSlots' of undefined

      91 |
      92 |   /** the project to load */
    > 93 |   projectToLoad: string = ''
         |                                                           ^
      94 |   /** name of new project to create */
      95 |   newProjectName: string = ''
      96 |

      at updateChildComponent (node_modules/vue/dist/vue.runtime.common.dev.js:4091:27)
      at prepatch (node_modules/vue/dist/vue.runtime.common.dev.js:3119:5)
      at patchVnode (node_modules/vue/dist/vue.runtime.common.dev.js:6282:7)
      at updateChildren (node_modules/vue/dist/vue.runtime.common.dev.js:6167:9)
      at patchVnode (node_modules/vue/dist/vue.runtime.common.dev.js:6293:29)
      at updateChildren (node_modules/vue/dist/vue.runtime.common.dev.js:6167:9)
      at patchVnode (node_modules/vue/dist/vue.runtime.common.dev.js:6293:29)
      at updateChildren (node_modules/vue/dist/vue.runtime.common.dev.js:6167:9)
      ...

I may not be doing it right though.

describe('LoadProjectDialog.vue', function() {
  let localVue
  let wrapper: Wrapper<LoadProjectDialog>
  beforeEach( () => {
    localVue = createLocalVue()
    let options: ThisTypedMountOptions<LoadProjectDialog> = {
      localVue,
      propsData: { project, value: false, projects: [project] },
      stubs: { transition: false }, // XXX: had to modify test-utils/types/index.d.ts to allow this
    }
    wrapper = mount(LoadProjectDialog, options)
  })

  it('emits input event on cancel', function() {
    wrapper.setProps({value: true})
    wrapper.find('#cancel').trigger('click');
    expect(wrapper.emitted().input.length).toEqual(1)
  })
})

@eddyerburgh
Copy link
Member

@garyo we need to update the types file, do you want to make a PR adding the fix to the types file?

@garyo
Copy link
Contributor

garyo commented May 10, 2019

Done -- #1231.

nicksellen added a commit to karrot-dev/karrot-frontend that referenced this issue Nov 13, 2019
"sync: false" seems to be the new way it goes and will be the default
in the future, see vuejs/vue-test-utils#1137

The transition group stubs seem to be there by default now too, I think..
Anyway it works where it did no tbefore :)

Also see vuejs/vue-test-utils#1163
tiltec pushed a commit to karrot-dev/karrot-frontend that referenced this issue Nov 17, 2019
* Use address autocomplete

As it used to be.
Also defaults place edit map to be group centre if available.

* Remove uneeded extra wrapped div

* Update setup for storyshots testing

"sync: false" seems to be the new way it goes and will be the default
in the future, see vuejs/vue-test-utils#1137

The transition group stubs seem to be there by default now too, I think..
Anyway it works where it did no tbefore :)

Also see vuejs/vue-test-utils#1163

* Add @types/jest - for editor support

See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/

* Increase test wait

Not really sure why this changed, but don't want to think about
it for now...

* Add text to translation file

* Use the spelling of the enemy

* Simplify template logic
nicksellen added a commit to karrot-dev/karrot-frontend that referenced this issue Nov 17, 2019
* Use address autocomplete

As it used to be.
Also defaults place edit map to be group centre if available.

* Remove uneeded extra wrapped div

* Update setup for storyshots testing

"sync: false" seems to be the new way it goes and will be the default
in the future, see vuejs/vue-test-utils#1137

The transition group stubs seem to be there by default now too, I think..
Anyway it works where it did no tbefore :)

Also see vuejs/vue-test-utils#1163

* Add @types/jest - for editor support

See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/

* Increase test wait

Not really sure why this changed, but don't want to think about
it for now...

* Add text to translation file

* Use the spelling of the enemy

* Simplify template logic
tiltec pushed a commit to karrot-dev/karrot-frontend that referenced this issue Nov 26, 2019
* Initial work to add person-to-person sharing

* A few sharing item UI refinements

* Initial new sharing form with multiple upload

* Add a grey box...

* Remove redundant check

* Rename sharing to offers

* Add a mock chat to offer detail UI

* Create mobile version of offer detail UI

* Tidy up multiple image editing

* A bit more polish on the offer UI

Some translations, icon, breadcrumb, etc...

* Snapshot update

* Add create offer breadcrumb title

* Rename a few offer related things for consistency

* Offer image carousel, multi upload, various bits

* Refine image upload/remove/re-position

* Add websocket listeners for offer changes

* Wireup offer conversation

* Basic features to allow to accept/archive offers

* Remove uneeded demo data

* Move selected offer data/logic to own store module

* Preserve offer filter in more places

The create/save filter preservation does not work actually
as we clear the store contents on route change.

* Remove status from offer form

Status change is now done via explicit actions/buttons

* Use address autocomplete (#1878)

* Use address autocomplete

As it used to be.
Also defaults place edit map to be group centre if available.

* Remove uneeded extra wrapped div

* Update setup for storyshots testing

"sync: false" seems to be the new way it goes and will be the default
in the future, see vuejs/vue-test-utils#1137

The transition group stubs seem to be there by default now too, I think..
Anyway it works where it did no tbefore :)

Also see vuejs/vue-test-utils#1163

* Add @types/jest - for editor support

See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/

* Increase test wait

Not really sure why this changed, but don't want to think about
it for now...

* Add text to translation file

* Use the spelling of the enemy

* Simplify template logic

* Ffix multicroppa

* Further refine offer editing, esp MultiCroppa

* Use gift as offers menu item

* Remove offer upload progress logging

* Nicer create offer button

* Clear offerDetail on route leave

* Add offer list loading indicator

* Add offer body loading indicator

* Add loading spinner when fetching offer for edit

* Correctly wire up offer form reset events

* Only show offer accept/archive buttons if active

* Handle updating offers after save/websocket better

* Cleaner mobile form view

* Only show carousel if >1 image

* Fix offer header when name is very long

* Fix offer detail image display when only 1

* Fix overflowing text on group offers page

* White background offer description

* Snapshot update

* Don't try and be fancy with updating users

* Fix style style

* Hide offers if group does not have the feature

* Check route features in after route hook

* Actually filter offers by current group

* Add offers covert function to convert createdAt

* Display offer information in latest messages

I did it a slightly different way, by adding related offers
into the latestMessages state...

* Keep related offers up to date via websocket

It's a bit overkeen actually as most users won't be in the
conversations for the offers, so we don't need to update the
related item... should really check we need it first

* Import default offer status from store

* Use current route query instead of getter

* Use + for new offer button

* Allow setting new_offer notification types

* Show offer status if not active

Although it's a bit ugly

* Change notification type spinner

* Add group.features to test mocks

* Wrap settings forms in FormContainer

* Rename to KFormContainer and move to base

* Add confirm step to accept/archive offer buttons

* Use photo icon for offer image placeholder

* Add offer as a "fake" empty result

* Filter offers by status and sort by createdAt desc

... entries can get added via websockets that might not fit
the filter, and might need reordering

* Refine group offer cards

- use QImg instead of lots of CSS
- use QItem inside for nicer layout

* Correct RouterLink casing

* Update test snapshots

* Please the pedantic linter

* Remove offer description helper

* Extract mapErrors to statusMixin

* Add accept/archive text into i18n

* Remove unneeded code

* Add offer filter status text to i18n

* Correct size for new offer button

* Remove one layer of div soup

* Put the group offer cards in proper links

* Remove commented out code

* Convert offer in websocket update

* Prefix functional getter with get

For getNotificationTypeStatus

* Preserve route query when clicking on offer conv

* Use icon service for latest messages offer item

* Move withoutKeys to utils

* Use invisible class instead of custom css

* Don't put const value in data

* Save disk space by compacting template

* Remove unneeded v-model

Was only used when I tried out quasar :rules

* Document MultiCroppa value prop a bit more

* Document the data that latestMesages/related has
tiltec pushed a commit to karrot-dev/karrot-frontend that referenced this issue May 9, 2020
* Use address autocomplete

As it used to be.
Also defaults place edit map to be group centre if available.

* Remove uneeded extra wrapped div

* Update setup for storyshots testing

"sync: false" seems to be the new way it goes and will be the default
in the future, see vuejs/vue-test-utils#1137

The transition group stubs seem to be there by default now too, I think..
Anyway it works where it did no tbefore :)

Also see vuejs/vue-test-utils#1163

* Add @types/jest - for editor support

See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/

* Increase test wait

Not really sure why this changed, but don't want to think about
it for now...

* Add text to translation file

* Use the spelling of the enemy

* Simplify template logic
tiltec pushed a commit to karrot-dev/karrot-frontend that referenced this issue May 9, 2020
* Initial work to add person-to-person sharing

* A few sharing item UI refinements

* Initial new sharing form with multiple upload

* Add a grey box...

* Remove redundant check

* Rename sharing to offers

* Add a mock chat to offer detail UI

* Create mobile version of offer detail UI

* Tidy up multiple image editing

* A bit more polish on the offer UI

Some translations, icon, breadcrumb, etc...

* Snapshot update

* Add create offer breadcrumb title

* Rename a few offer related things for consistency

* Offer image carousel, multi upload, various bits

* Refine image upload/remove/re-position

* Add websocket listeners for offer changes

* Wireup offer conversation

* Basic features to allow to accept/archive offers

* Remove uneeded demo data

* Move selected offer data/logic to own store module

* Preserve offer filter in more places

The create/save filter preservation does not work actually
as we clear the store contents on route change.

* Remove status from offer form

Status change is now done via explicit actions/buttons

* Use address autocomplete (#1878)

* Use address autocomplete

As it used to be.
Also defaults place edit map to be group centre if available.

* Remove uneeded extra wrapped div

* Update setup for storyshots testing

"sync: false" seems to be the new way it goes and will be the default
in the future, see vuejs/vue-test-utils#1137

The transition group stubs seem to be there by default now too, I think..
Anyway it works where it did no tbefore :)

Also see vuejs/vue-test-utils#1163

* Add @types/jest - for editor support

See https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/

* Increase test wait

Not really sure why this changed, but don't want to think about
it for now...

* Add text to translation file

* Use the spelling of the enemy

* Simplify template logic

* Ffix multicroppa

* Further refine offer editing, esp MultiCroppa

* Use gift as offers menu item

* Remove offer upload progress logging

* Nicer create offer button

* Clear offerDetail on route leave

* Add offer list loading indicator

* Add offer body loading indicator

* Add loading spinner when fetching offer for edit

* Correctly wire up offer form reset events

* Only show offer accept/archive buttons if active

* Handle updating offers after save/websocket better

* Cleaner mobile form view

* Only show carousel if >1 image

* Fix offer header when name is very long

* Fix offer detail image display when only 1

* Fix overflowing text on group offers page

* White background offer description

* Snapshot update

* Don't try and be fancy with updating users

* Fix style style

* Hide offers if group does not have the feature

* Check route features in after route hook

* Actually filter offers by current group

* Add offers covert function to convert createdAt

* Display offer information in latest messages

I did it a slightly different way, by adding related offers
into the latestMessages state...

* Keep related offers up to date via websocket

It's a bit overkeen actually as most users won't be in the
conversations for the offers, so we don't need to update the
related item... should really check we need it first

* Import default offer status from store

* Use current route query instead of getter

* Use + for new offer button

* Allow setting new_offer notification types

* Show offer status if not active

Although it's a bit ugly

* Change notification type spinner

* Add group.features to test mocks

* Wrap settings forms in FormContainer

* Rename to KFormContainer and move to base

* Add confirm step to accept/archive offer buttons

* Use photo icon for offer image placeholder

* Add offer as a "fake" empty result

* Filter offers by status and sort by createdAt desc

... entries can get added via websockets that might not fit
the filter, and might need reordering

* Refine group offer cards

- use QImg instead of lots of CSS
- use QItem inside for nicer layout

* Correct RouterLink casing

* Update test snapshots

* Please the pedantic linter

* Remove offer description helper

* Extract mapErrors to statusMixin

* Add accept/archive text into i18n

* Remove unneeded code

* Add offer filter status text to i18n

* Correct size for new offer button

* Remove one layer of div soup

* Put the group offer cards in proper links

* Remove commented out code

* Convert offer in websocket update

* Prefix functional getter with get

For getNotificationTypeStatus

* Preserve route query when clicking on offer conv

* Use icon service for latest messages offer item

* Move withoutKeys to utils

* Use invisible class instead of custom css

* Don't put const value in data

* Save disk space by compacting template

* Remove unneeded v-model

Was only used when I tried out quasar :rules

* Document MultiCroppa value prop a bit more

* Document the data that latestMesages/related has
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants