123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- require 'rails_helper'
- RSpec.describe 'Manage > Checklists', current_user_id: 1, type: :system do
- context 'when enabling/disabling checklists' do
- before do
- visit 'manage/checklists'
- end
- it 'can enable/disable checklists' do
- expect(Setting.get('checklist')).to be(true)
- find('.js-checklistSetting').click
- wait.until { Setting.get('checklist') == false }
- end
- end
- context 'when adding a new checklist' do
- before do
- visit 'manage/checklists'
- end
- it 'shows a help text' do
- expect(page).to have_content('With checklist templates it is possible to pre-fill new checklists with initial items.')
- expect(page).to have_no_css('.js-description')
- end
- context 'when items are empty' do
- it 'shows an error message' do
- expect(page).to have_link('New Checklist Template')
- click_on('New Checklist Template')
- in_modal do
- fill_in('Name', with: 'Test Checklist')
- click_on('Submit')
- expect(page).to have_content('Please add at least one item to the checklist.')
- end
- end
- end
- context 'when items are present' do
- it 'adds a new checklist' do
- expect(page).to have_link('New Checklist Template')
- click_on('New Checklist Template')
- in_modal do
- fill_in('Name', with: 'Test Checklist')
- find('.checklist-item-add-item-text').fill_in(with: 'Test Item')
- click_on('Add')
- click_on('Submit')
- end
- expect(page).to have_content('Test Checklist')
- end
- end
- end
- context 'when editing a checklist' do
- before do
- create(:checklist_template, name: 'Test Checklist')
- visit 'manage/checklists'
- end
- it 'shows a description button' do
- expect(page).to have_no_content('With checklist templates it is possible to pre-fill new checklists with initial items.')
- expect(page).to have_css('.js-description')
- page.find('.js-description').click
- in_modal do
- expect(page).to have_content('With checklist templates it is possible to pre-fill new checklists with initial items.')
- end
- end
- it 'successfully updates the checklist' do
- expect(page).to have_content('Test Checklist')
- find('.js-checklistTemplatesTable tr.item').click
- in_modal do
- find('.checklist-item-add-item-text').fill_in(with: 'Test Item')
- click_on('Add')
- click_on('Submit')
- end
- expect(ChecklistTemplate.last.items.count).to eq(6)
- expect(ChecklistTemplate.last.items.last.text).to eq('Test Item')
- end
- end
- context 'when cloning a checklist' do
- before do
- create(:checklist_template, name: 'Test Checklist')
- visit 'manage/checklists'
- end
- it 'successfully creates a clone' do
- expect(page).to have_content('Test Checklist')
- find('.js-checklistTemplatesTable tr.item .js-action').click
- find('.js-table-action-menu .js-clone').click
- in_modal do
- click_on('Submit')
- end
- expect(page).to have_content('Clone: Test Checklist')
- expect(ChecklistTemplate.last.items.count).to eq(5)
- end
- end
- context 'when deleting a checklist' do
- before do
- create(:checklist_template, name: 'Test Checklist')
- visit 'manage/checklists'
- end
- it 'successfully creates a clone' do
- expect(page).to have_content('Test Checklist')
- find('.js-checklistTemplatesTable tr.item .js-action').click
- find('.js-table-action-menu .js-delete').click
- in_modal do
- click_on('delete')
- end
- expect(page).to have_no_content('Test Checklist')
- expect(ChecklistTemplate.count).to eq(0)
- end
- end
- end
|