diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 000000000..3a882a7cc --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,6 @@ +{ + "MD013": false, // Disables the line length rule completely + // Or to customize it: + "MD013": { "line_length": 120 } // Changes max line length to 120 +} + diff --git a/README.md b/README.md index d3504028f..16cad2803 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ Framework for QA of `onlyoffice-documentbuilder` rake run_test_on_win ``` +## Conversion test coverage matrix + +| Input format | Output format | | | | | | | | | | | | | | +|--------------|---------------|-------|------|------|------|------|-----|------|-----|-----|-----|------|-----|-----| +| | docx | docxf | docm | dotm | dotx | epub | fb2 | html | odt | ott | pdf | pdfa | rtf | txt | +| docx | * | * | * | * | * | * | * | * | * | * | * | * | * | * | + ## Project Information [Official website](https://www.onlyoffice.com) diff --git a/js/conversion/docx/docx_to_docm.js b/js/conversion/docx/docx_to_docm.js new file mode 100644 index 000000000..46c383a20 --- /dev/null +++ b/js/conversion/docx/docx_to_docm.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("docm", "AddText.docm"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_docxf.js b/js/conversion/docx/docx_to_docxf.js new file mode 100644 index 000000000..47a1f27ca --- /dev/null +++ b/js/conversion/docx/docx_to_docxf.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("docxf", "AddText.docxf"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_dotm.js b/js/conversion/docx/docx_to_dotm.js new file mode 100644 index 000000000..114c33ba4 --- /dev/null +++ b/js/conversion/docx/docx_to_dotm.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("dotm", "AddText.dotm"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_dotx.js b/js/conversion/docx/docx_to_dotx.js new file mode 100644 index 000000000..8ec5229fb --- /dev/null +++ b/js/conversion/docx/docx_to_dotx.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("dotx", "AddText.dotx"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_epub.js b/js/conversion/docx/docx_to_epub.js new file mode 100644 index 000000000..9e667a2fb --- /dev/null +++ b/js/conversion/docx/docx_to_epub.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("epub", "AddText.epub"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_fb2.js b/js/conversion/docx/docx_to_fb2.js new file mode 100644 index 000000000..853abd567 --- /dev/null +++ b/js/conversion/docx/docx_to_fb2.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("fb2", "AddText.fb2"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_html.js b/js/conversion/docx/docx_to_html.js new file mode 100644 index 000000000..9980e6bb2 --- /dev/null +++ b/js/conversion/docx/docx_to_html.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("html", "AddText.html"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_ott.js b/js/conversion/docx/docx_to_ott.js new file mode 100644 index 000000000..4b29f20c0 --- /dev/null +++ b/js/conversion/docx/docx_to_ott.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("ott", "AddText.ott"); +builder.CloseFile(); diff --git a/js/conversion/docx/docx_to_pdfa.js b/js/conversion/docx/docx_to_pdfa.js new file mode 100644 index 000000000..b01ca63d0 --- /dev/null +++ b/js/conversion/docx/docx_to_pdfa.js @@ -0,0 +1,6 @@ +builder.CreateFile("docx"); +var oDocument = Api.GetDocument(); +var oParagraph = oDocument.GetElement(0); +oParagraph.AddText("This is just a sample text. Nothing special."); +builder.SaveFile("pdfa", "AddText.pdfa"); +builder.CloseFile(); diff --git a/lib/doc_builder_testing/doc_builder_helper.rb b/lib/doc_builder_testing/doc_builder_helper.rb index 38d1580fe..d06349223 100644 --- a/lib/doc_builder_testing/doc_builder_helper.rb +++ b/lib/doc_builder_testing/doc_builder_helper.rb @@ -2,6 +2,7 @@ # Helpers method for document builder module DocBuilderHelper + # Actual verison: 7.2.2 # [Hash] list of minimal file size by formats MINIMAL_FILESIZE = { '.odt' => 3656, '.rtf' => 976, @@ -9,7 +10,12 @@ module DocBuilderHelper '.txt' => 5, '.odp' => 3933, '.ods' => 3351, - '.csv' => 1 }.freeze + '.csv' => 1, + '.epub' => 1758, + '.fb2' => 498, + '.ott' => 272, + '.html' => 4234, + '.pdfa' => 4999 }.freeze # Parse file # @param path [String] file to path diff --git a/spec/docx/conversion/docx_conversion_spec.rb b/spec/docx/conversion/docx_conversion_spec.rb index 4b2bc075f..202c30965 100644 --- a/spec/docx/conversion/docx_conversion_spec.rb +++ b/spec/docx/conversion/docx_conversion_spec.rb @@ -1,29 +1,105 @@ # frozen_string_literal: true require 'spec_helper' -describe 'Conversion tests from Docx' do - it 'Conversion | Docx to Docx', :critical do - docx = builder.build_and_parse('js/conversion/docx/docx_to_docx.js') - expect(docx).to be_with_data +describe 'Conversion tests from docx' do + it 'Conversion | docx to docx' do + parsed_output_file = builder.build_and_parse('js/conversion/docx/docx_to_docx.js') + expect(parsed_output_file).to be_with_data end - it 'Conversion | Docx to Odt' do + it 'Conversion | docx to docxf' do + parsed_output_file = builder.build_and_parse('js/conversion/docx/docx_to_docxf.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_docxf.js')) + expect(File.extname(parsed_output_file.file_path).strip.downcase[1..]).to eq(ext) + expect(parsed_output_file).to be_with_data + end + + it 'Conversion | docx to docm' do + parsed_output_file = builder.build_and_parse('js/conversion/docx/docx_to_docm.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_docm.js')) + expect(File.extname(parsed_output_file.file_path).strip.downcase[1..]).to eq(ext) + expect(parsed_output_file).to be_with_data + end + + it 'Conversion | docx to dotx' do + parsed_output_file = builder.build_and_parse('js/conversion/docx/docx_to_dotx.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_dotx.js')) + expect(File.extname(parsed_output_file.file_path).strip.downcase[1..]).to eq(ext) + expect(parsed_output_file).to be_with_data + end + + it 'Conversion | docx to dotm' do + parsed_output_file = builder.build_and_parse('js/conversion/docx/docx_to_dotm.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_dotm.js')) + expect(File.extname(parsed_output_file.file_path).strip.downcase[1..]).to eq(ext) + expect(parsed_output_file).to be_with_data + end + + it 'Conversion | docx to pdf' do + parsed_output_file = builder.build_and_parse('js/conversion/docx/docx_to_pdf.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_pdf.js')) + expect(File.extname(parsed_output_file.file_path).strip.downcase[1..]).to eq(ext) + expect(parsed_output_file.pages[0][:text]).to eq('This is just a sample text. Nothing special.') + end + + it 'Conversion | docx to epub' do + output_file = builder.build_file('js/conversion/docx/docx_to_epub.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_epub.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) + expect(builder).not_to be_file_empty(output_file) + end + + it 'Conversion | docx to fb2' do + output_file = builder.build_file('js/conversion/docx/docx_to_fb2.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_fb2.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) + expect(builder).not_to be_file_empty(output_file) + end + + it 'Conversion | docx to html' do + output_file = builder.build_file('js/conversion/docx/docx_to_html.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_html.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) + expect(builder).not_to be_file_empty(output_file) + end + + it 'Conversion | docx to ott' do + output_file = builder.build_file('js/conversion/docx/docx_to_ott.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_ott.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) + expect(builder).not_to be_file_empty(output_file) + end + + it 'Conversion | docx to odt' do output_file = builder.build_file('js/conversion/docx/docx_to_odt.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_odt.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) expect(builder).not_to be_file_empty(output_file) end - it 'Conversion | Docx to Pdf', :critical do + it 'Conversion | Docx to Pdf' do output_file = builder.build_file('js/conversion/docx/docx_to_pdf.js') expect(builder).not_to be_file_empty(output_file) end - it 'Conversion | Docx to Rtf', :critical do + it 'Conversion | docx to pdfa' do + output_file = builder.build_file('js/conversion/docx/docx_to_pdfa.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_pdfa.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) + expect(builder).not_to be_file_empty(output_file) + end + + it 'Conversion | docx to rtf' do output_file = builder.build_file('js/conversion/docx/docx_to_rtf.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_rtf.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) expect(builder).not_to be_file_empty(output_file) end - it 'Conversion | Docx to Txt', :critical do + it 'Conversion | Docx to Txt' do output_file = builder.build_file('js/conversion/docx/docx_to_txt.js') + ext = builder.recognize_output_format(File.read('js/conversion/docx/docx_to_txt.js')) + expect(File.extname(output_file).strip.downcase[1..]).to eq(ext) expect(builder).not_to be_file_empty(output_file) end end