Repository: element-plus/element-plus
File: packages/components/date-picker/__tests__/date-picker.test.ts (TypeScript)

Code before:
      await nextTick()
      const formItem = wrapper.find('[data-test-ref="item"]')
      const formItemLabel = formItem.find('.el-form-item__label')
      const datePickerInput = wrapper.find('.el-input__inner')
      expect(formItem.attributes().role).toBeFalsy()
      expect(datePickerInput.attributes().id).toBe('foobar')
      expect(formItemLabel.attributes().for).toBe(
        datePickerInput.attributes().id
      )
    })

    it('form item role is group when multiple inputs', async () => {
      const wrapper = _mount(
        `<el-form-item label="Foobar" data-test-ref="item">
          <el-date-picker />
          <el-date-picker />
        </el-form-item>`,
        () => ({})
      )

      await nextTick()
      const formItem = wrapper.find('[data-test-ref="item"]')
      expect(formItem.attributes().role).toBe('group')
    })

    it('form is disabled, but the datePicker is not.', async () => {
      const wrapper = _mount(
        `<el-form :disabled="true">
          <el-form-item>
            <el-date-picker :disabled="false" v-model="value"/>
          </el-form-item>
        </el-form>`,
        () => ({ value: '' })
      )

      await nextTick()
      const datePickerInput = wrapper.find('.el-input__inner')
      expect(datePickerInput.attributes('disabled')).toBeUndefined()

      datePickerInput.trigger('focus')
      await nextTick()
      const panel = document.querySelector('.el-picker-panel')
      expect(panel?.classList.contains('is-disabled')).toBeFalsy()
    })
  })

  it('The year which is disabled should not be selectable', async () => {
    const pickHandler = vi.fn()
    const wrapper = _mount(
      `<el-date-picker
        v-model="yearValue"

Review comment (suggestion):
```suggestion
    it('should give its own disabled prop higher priority within a form', async () => {
```

Code after:
      await nextTick()
      const formItem = wrapper.find('[data-test-ref="item"]')
      const formItemLabel = formItem.find('.el-form-item__label')
      const datePickerInput = wrapper.find('.el-input__inner')
      expect(formItem.attributes().role).toBeFalsy()
      expect(datePickerInput.attributes().id).toBe('foobar')
      expect(formItemLabel.attributes().for).toBe(
        datePickerInput.attributes().id
      )
    })

    it('form item role is group when multiple inputs', async () => {
      const wrapper = _mount(
        `<el-form-item label="Foobar" data-test-ref="item">
          <el-date-picker />
          <el-date-picker />
        </el-form-item>`,
        () => ({})
      )

      await nextTick()
      const formItem = wrapper.find('[data-test-ref="item"]')
      expect(formItem.attributes().role).toBe('group')
    })

    it('should give its own disabled prop higher priority within a form', async () => {
      const wrapper = _mount(
        `<el-form :disabled="true">
          <el-form-item>
            <el-date-picker :disabled="false" v-model="value"/>
          </el-form-item>
        </el-form>`,
        () => ({ value: '' })
      )

      await nextTick()
      const datePickerInput = wrapper.find('.el-input__inner')
      expect(datePickerInput.attributes('disabled')).toBeUndefined()

      datePickerInput.trigger('focus')
      await nextTick()
      const panel = document.querySelector('.el-picker-panel')
      expect(panel?.classList.contains('is-disabled')).toBeFalsy()
    })
  })

  it('The year which is disabled should not be selectable', async () => {
    const pickHandler = vi.fn()
    const wrapper = _mount(
      `<el-date-picker
        v-model="yearValue"