Skip to content

Commit

Permalink
Rgb color test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yar04ek committed Nov 24, 2023
1 parent a8f282b commit d8a5a92
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 57 deletions.
32 changes: 12 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ GEM
iniparse (1.5.0)
json (2.6.3)
jwt (2.7.1)
language_server-protocol (3.17.0.3)
mini_portile2 (2.8.5)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
nokogiri (1.15.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.5-x86_64-darwin)
racc (~> 1.4)
onlyoffice_pdf_parser (0.5.0)
image_size (>= 2, < 4)
Expand All @@ -23,7 +22,7 @@ GEM
ooxml_decrypt (1.0.0)
nokogiri (~> 1.10)
ruby-ole (~> 1.2)
ooxml_parser (0.37.1)
ooxml_parser (0.34.2)
nokogiri (~> 1)
ooxml_decrypt (~> 1)
rubyzip (~> 2)
Expand All @@ -32,7 +31,7 @@ GEM
iniparse (~> 1.4)
rexml (~> 3.2)
parallel (1.23.0)
parallel_tests (4.3.0)
parallel_tests (3.13.0)
parallel
parser (3.2.2.4)
ast (~> 2.4.1)
Expand Down Expand Up @@ -64,32 +63,25 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.57.2)
rubocop (1.50.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-performance (1.19.1)
rubocop-performance (1.17.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec (2.17.1)
rubocop (~> 1.33)
ruby-ole (1.2.12.2)
ruby-progressbar (1.13.0)
ruby-rc4 (0.1.5)
Expand All @@ -100,7 +92,7 @@ GEM
yard (0.9.34)

PLATFORMS
ruby
universal-darwin-23

DEPENDENCIES
jwt
Expand Down
46 changes: 18 additions & 28 deletions js/docx/smoke/api_rgb_color/to_json.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oRGBColor;

// Создаем элемент параграфа
oParagraph = Api.CreateParagraph();

// Создаем RGB цвет с помощью значений RGB (красный, зеленый, синий)
oRGBColor = Api.CreateRGBColor(255, 0, 0); // Например, красный цвет

// Преобразуем RGB цвет в JSON
var jsonRGB = oRGBColor.ToJSON();

// Добавляем текстовую строку с JSON представлением RGB цвета в параграф
oParagraph.AddText("JSON representation of RGB color: " + jsonRGB);

// Добавляем созданный параграф в документ
var oParagraph = Api.CreateParagraph();
var oRGBColor = Api.CreateRGBColor(255, 0, 0);
var json = oRGBColor.ToJSON();
oParagraph.AddText("JSON representation of RGB color: " + json);
oDocument.Push(oParagraph);
GlobalVariable["RGBColorJSON"] = json;
builder.CloseFile()
/////////////////////////

// Сохраняем файл
builder.SaveFile("docx", "RGBColorJSONCheck.docx");
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var json = GlobalVariable["RGBColorJSON"];
var oRGBColorFromJSON = Api.FromJSON(json);
oRGBColorFromJSON.SetDefaultStyle();
oParagraph.AddElement(oRGBColorFromJSON);
var oParagraph1 = Api.CreateParagraph();
oDocument.Push(oParagraph1);
oParagraph1.AddText(json);
builder.SaveFile("docx", "RGBColorDocument.docx");
builder.CloseFile();



/////////////////////////

builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oRGBColor = Api.CreateRGBColor(255, 164, 101);
var json = oRGBColor.ToJSON();
GlobalVariable["RGBColorJSON"] = json;
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("JSON representation of RGBColor: " + json);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "RGBColorToJSON.docx");
builder.CloseFile();

14 changes: 6 additions & 8 deletions spec/docx/smoke/api_rgb_color_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@

end


it 'ApiRGBColor | ToJSON method' do
docx = builder.build_and_parse('js/docx/smoke/api_rgb_color/to_json.js')
json = docx.to_json
parsed_json = JSON.parse(json)
# Проверка наличия ключа 'rgba' для второго цвета
expect(parsed_json['graphic']).not_to be_nil
# Проверка ожидаемых значений красного, зеленого и синего цветов для второго цвета
expect(parsed_json['graphic']['red']).to eq(255)
expect(parsed_json['graphic']['green']).to eq(0)
expect(parsed_json['graphic']['blue']).to eq(0)
p docx
# expect(docx.paragraphs[0].text).to include(GlobalVariable['RGBColorJSON'])
# json = JSON.parse(docx.elements[1].nonempty_runs.first.text)
# expected_rgba = (GlobalVariable['RGBColorJSON'])['graphic']['spPr']['fill']['fill']['gsLst'][1]['color']['color']['rgba']
# expect(json['graphic']['spPr']['fill']['fill']['gsLst'][1]['color']['color']['rgba']).to eq(expected_rgba)
end

end
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
# @return [WebDocBuilderWrapper, DocBuilderWrapper]
def builder
@builder ||= if web_builder?
WebDocBuilderWrapper.new
WebDocBuilderWrapper.new(
jwt_key: 'h6DwLNlgK0ALVDvW8V8FfNJK8NSH6AiZ',
jwt_header: 'Authorization',
documentserver_path: 'http://192.168.100.2'
)
else
DocBuilderWrapper.new
end
end


# @return [String] which platform is used to run builder tests
def builder_platform
ENV.fetch('BUILDER_PLATFORM', 'DESKTOP')
Expand Down

0 comments on commit d8a5a92

Please sign in to comment.