|
7 | 7 | expect(page.evaluate_script('typeof Quill')).to eq 'function' |
8 | 8 | expect(page.evaluate_script('Quill.version')).to eq(ActiveAdmin::QuillEditor::QUILL_VERSION) |
9 | 9 | end |
| 10 | + |
| 11 | + describe '.getQuillEditors' do |
| 12 | + let(:author) { Author.create!(email: '[email protected]', name: 'John Doe', age: 30) } |
| 13 | + let!(:post) { Post.create!(title: 'Test', author: author, description: '') } |
| 14 | + |
| 15 | + before do |
| 16 | + path = edit_admin_post_path(post) |
| 17 | + Admin::Posts::EditPage.new(path: path).load |
| 18 | + end |
| 19 | + |
| 20 | + it "returns the available editors", :aggregate_failures do |
| 21 | + editors_count = page.evaluate_script('window.getQuillEditors().length') |
| 22 | + expect(editors_count).to eq 2 |
| 23 | + |
| 24 | + expected_element = find('#post_summary > .ql-container') |
| 25 | + first_editor = page.evaluate_script('window.getQuillEditors()[0].container') |
| 26 | + expect(first_editor).to eq expected_element |
| 27 | + |
| 28 | + expected_element = find('#post_description > .ql-container') |
| 29 | + first_editor = page.evaluate_script('window.getQuillEditors()[1].container') |
| 30 | + expect(first_editor).to eq expected_element |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + describe '.getQuillEditorByIndex' do |
| 35 | + let(:author) { Author.create!(email: '[email protected]', name: 'John Doe', age: 30) } |
| 36 | + let!(:post) { Post.create!(title: 'Test', author: author, description: '') } |
| 37 | + |
| 38 | + before do |
| 39 | + path = edit_admin_post_path(post) |
| 40 | + Admin::Posts::EditPage.new(path: path).load |
| 41 | + end |
| 42 | + |
| 43 | + it "returns the expected editor instance" do |
| 44 | + expected_element = find('#post_description > .ql-container') |
| 45 | + editor = page.evaluate_script('window.getQuillEditorByIndex(1).container') |
| 46 | + expect(editor).to eq expected_element |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + describe '.getQuillEditorByElementId' do |
| 51 | + let(:author) { Author.create!(email: '[email protected]', name: 'John Doe', age: 30) } |
| 52 | + let!(:post) { Post.create!(title: 'Test', author: author, description: '') } |
| 53 | + |
| 54 | + before do |
| 55 | + path = edit_admin_post_path(post) |
| 56 | + Admin::Posts::EditPage.new(path: path).load |
| 57 | + end |
| 58 | + |
| 59 | + it "returns the expected editor instance" do |
| 60 | + expected_element = find('#post_description > .ql-container') |
| 61 | + editor = page.evaluate_script('window.getQuillEditorByElementId("post_description").container') |
| 62 | + expect(editor).to eq expected_element |
| 63 | + end |
| 64 | + end |
10 | 65 | end |
0 commit comments