Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -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
}

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_docm.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_docxf.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_dotm.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_dotx.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_epub.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_fb2.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_html.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_ott.js
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions js/conversion/docx/docx_to_pdfa.js
Original file line number Diff line number Diff line change
@@ -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();
8 changes: 7 additions & 1 deletion lib/doc_builder_testing/doc_builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

# 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,
'.pdf' => 734,
'.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
Expand Down
92 changes: 84 additions & 8 deletions spec/docx/conversion/docx_conversion_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading