air_test 0.1.5.3 → 0.1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/air_test/notion_parser.rb +42 -8
- data/lib/air_test/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8814b0e5adb17e2636d7da5b58d8c2f472c78fa31325d1d415ef30de9993104
|
4
|
+
data.tar.gz: d1e48aa3bb971eaecb093b97a247197e4138b02ed5d9cb41c00d3f202c22afcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e2fee67f17bb43db86a10d981f73d033429ce2da0d55481eb56356c1fe979777cccf72e59e6a24fc79e3468cc681f12081c8ec9fa125394b2ae35ff8e00cf7b
|
7
|
+
data.tar.gz: 65138b6b62ad47c68fb0abc70ca9670687fd0d595c7de55b4e8e7a1817f54e8e17cc1159bfcdc34b3394f2bf125c670c42faaab3b360c868e496b96d51408999
|
@@ -26,9 +26,16 @@ module AirTest
|
|
26
26
|
|
27
27
|
def parse_ticket_content(page_id)
|
28
28
|
blocks = get_page_content(page_id)
|
29
|
+
puts "\n===== RAW NOTION BLOCKS ====="
|
30
|
+
puts JSON.pretty_generate(blocks)
|
29
31
|
return nil unless blocks
|
30
|
-
|
31
|
-
|
32
|
+
normalized_blocks = normalize_blocks(blocks)
|
33
|
+
puts "\n===== NORMALIZED BLOCKS ====="
|
34
|
+
puts JSON.pretty_generate(normalized_blocks)
|
35
|
+
parsed_data = parse_content(normalized_blocks)
|
36
|
+
puts "\n===== PARSED DATA ====="
|
37
|
+
puts JSON.pretty_generate(parsed_data)
|
38
|
+
parsed_data
|
32
39
|
end
|
33
40
|
|
34
41
|
def extract_ticket_title(ticket)
|
@@ -84,11 +91,10 @@ module AirTest
|
|
84
91
|
in_background_block = false
|
85
92
|
background_steps = []
|
86
93
|
|
87
|
-
blocks.
|
94
|
+
blocks.each do |block|
|
88
95
|
block_type = block["type"]
|
89
96
|
text = extract_text(block[block_type]["rich_text"]) rescue ""
|
90
97
|
|
91
|
-
# Detect headings for feature, background, and scenario
|
92
98
|
if %w[heading_1 heading_2 heading_3].include?(block_type)
|
93
99
|
heading_text = text.strip
|
94
100
|
if heading_text.downcase.include?("feature")
|
@@ -101,6 +107,7 @@ module AirTest
|
|
101
107
|
in_feature_block = false
|
102
108
|
in_scenario_block = false
|
103
109
|
elsif heading_text.downcase.include?("scenario")
|
110
|
+
# Start a new scenario
|
104
111
|
in_scenario_block = true
|
105
112
|
in_feature_block = false
|
106
113
|
in_background_block = false
|
@@ -112,7 +119,7 @@ module AirTest
|
|
112
119
|
in_background_block = false
|
113
120
|
end
|
114
121
|
elsif block_type == "paragraph" && text.strip.downcase.start_with?("scenario:")
|
115
|
-
#
|
122
|
+
# Start a new scenario from a paragraph
|
116
123
|
in_scenario_block = true
|
117
124
|
in_feature_block = false
|
118
125
|
in_background_block = false
|
@@ -125,12 +132,14 @@ module AirTest
|
|
125
132
|
elsif in_background_block
|
126
133
|
background_steps << text
|
127
134
|
elsif in_scenario_block && current_scenario
|
128
|
-
|
135
|
+
# Only add as step if not a scenario heading
|
136
|
+
unless text.strip.downcase.start_with?("scenario:")
|
137
|
+
current_scenario[:steps] << text
|
138
|
+
end
|
129
139
|
end
|
130
140
|
elsif block_type == "callout"
|
131
141
|
text = extract_text(block["callout"]["rich_text"])
|
132
142
|
next if text.empty?
|
133
|
-
|
134
143
|
if text.downcase.include?("tag")
|
135
144
|
tags = extract_tags(text)
|
136
145
|
parsed_data[:meta][:tags].concat(tags)
|
@@ -168,7 +177,7 @@ module AirTest
|
|
168
177
|
in_steps = false
|
169
178
|
end
|
170
179
|
elsif %w[paragraph bulleted_list_item numbered_list_item].include?(block_type)
|
171
|
-
steps << text if in_steps && !text.empty?
|
180
|
+
steps << text if in_steps && !text.empty? && !text.strip.downcase.start_with?("scenario:")
|
172
181
|
end
|
173
182
|
end
|
174
183
|
if steps.any?
|
@@ -218,6 +227,31 @@ module AirTest
|
|
218
227
|
""
|
219
228
|
end
|
220
229
|
end
|
230
|
+
|
231
|
+
# Normalize Notion blocks: split multi-line blocks into one-line synthetic paragraph blocks
|
232
|
+
def normalize_blocks(blocks)
|
233
|
+
normalized = []
|
234
|
+
blocks.each do |block|
|
235
|
+
block_type = block["type"]
|
236
|
+
text = if block[block_type] && block[block_type]["rich_text"]
|
237
|
+
block[block_type]["rich_text"].map { |rt| rt["plain_text"] }.join("")
|
238
|
+
else
|
239
|
+
""
|
240
|
+
end
|
241
|
+
lines = text.split("\n").map(&:strip).reject(&:empty?)
|
242
|
+
if lines.size > 1
|
243
|
+
lines.each do |line|
|
244
|
+
normalized << {
|
245
|
+
"type" => "paragraph",
|
246
|
+
"paragraph" => { "rich_text" => [{ "plain_text" => line }] }
|
247
|
+
}
|
248
|
+
end
|
249
|
+
else
|
250
|
+
normalized << block
|
251
|
+
end
|
252
|
+
end
|
253
|
+
normalized
|
254
|
+
end
|
221
255
|
end
|
222
256
|
end
|
223
257
|
|
data/lib/air_test/version.rb
CHANGED