Skip to content

Commit c310d6a

Browse files
committed
[[NODE]] migration: adjust Diff/Changelog, add end-to-end test
1 parent d887fa2 commit c310d6a

File tree

49 files changed

+500
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+500
-154
lines changed

strictdoc/core/document_finder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
PathFinder,
2828
)
2929
from strictdoc.core.project_config import ProjectConfig
30+
from strictdoc.helpers.exception import StrictDocException
3031
from strictdoc.helpers.parallelizer import Parallelizer
3132
from strictdoc.helpers.paths import SDocRelativePath
3233
from strictdoc.helpers.textx import drop_textx_meta
@@ -43,13 +44,11 @@ def find_sdoc_content(
4344
for paths_to_files_or_doc in project_config.input_paths:
4445
if not os.path.exists(paths_to_files_or_doc):
4546
sys.stdout.flush()
46-
err = (
47+
raise StrictDocException(
4748
"error: "
4849
"Provided path is neither a single file or a folder: "
4950
f"'{paths_to_files_or_doc}'"
5051
)
51-
print(err) # noqa: T201
52-
sys.exit(1)
5352

5453
with measure_performance("Completed finding SDoc and assets"):
5554
file_tree, asset_manager = DocumentFinder._build_file_tree(

strictdoc/export/html/templates/components/table_key_value/index.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
{% else %}
1313
<div class="sdoc-table_key_value-key">{{ key_value_pair["Key"] }}</div>
1414
{% endif %}
15-
<div class="sdoc-table_key_value-value">{{ key_value_pair["Value"] }}</div>
15+
<div class="sdoc-table_key_value-value" data-testid="table-row-value-{{ key_value_pair["Key"].lower().replace(" ", "-") }}">{{ key_value_pair["Value"] }}</div>
1616
{% endif %}

strictdoc/export/html/templates/screens/git/diff_content.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
{%- set document_iterator = traceability_index.get_document_iterator(document) -%}
3636
{%- for section_or_requirement in document_iterator.all_content(print_fragments=True, print_fragments_from_files=False) %}
37-
{%- if section_or_requirement.is_requirement() %}
37+
{%- if section_or_requirement.is_requirement() and section_or_requirement.node_type != "SECTION" %}
3838
{%- set requirement = section_or_requirement %}
3939
{% include "screens/git/node/requirement.jinja" %}
4040

41-
{%- elif section_or_requirement.is_section() %}
41+
{%- elif section_or_requirement.is_section() or section_or_requirement.node_type == "SECTION" %}
4242
{%- set section = section_or_requirement %}
4343
{% include "screens/git/node/section.jinja" %}
4444
{%- endif %}

strictdoc/export/html/templates/screens/git/fields/section_fields.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
{%- if section_change.is_paired_change() -%}
4343
<div class="sdoc_pre_content">{{ section_change.get_colored_title_diff(side) }}</div>
4444
{%- else -%}
45-
<div class="sdoc_pre_content">{{ section.title }}</div>
45+
<div class="sdoc_pre_content">{{ section.reserved_title }}</div>
4646
{%- endif -%}
4747
{% else %}
48-
<div class="sdoc_pre_content">{{ section.title }}</div>
48+
<div class="sdoc_pre_content">{{ section.reserved_title }}</div>
4949
{% endif %}
5050
</div>
5151

strictdoc/export/html/templates/screens/git/form.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
placeholder="Enter the LHS revision here"
1515
id="left_revision"
1616
name="left_revision"
17+
data-testid="diff-screen-field-lhs"
1718
/>
1819
{% include "components/button/diff.jinja" %}
1920
<input
@@ -26,6 +27,7 @@
2627
placeholder="Enter the RHS revision here"
2728
id="right_revision"
2829
name="right_revision"
30+
data-testid="diff-screen-field-rhs"
2931
/>
3032
<input
3133
type="hidden"

strictdoc/export/html/templates/screens/git/nav_tabs.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{% else %}
1616
href="changelog.html"
1717
{% endif %}
18+
data-testid="diff-screen-tab-changelog"
1819
>Changelog</a>
1920
</div>
2021
</nav>

strictdoc/export/html/templates/screens/git/node/section.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<span>
1414
{{ section.context.title_number_string if section.context.title_number_string else "&nbsp;"|safe * (section.ng_level * 2 - 1) }}
1515
</span>
16-
<span>{{ section.title }}</span>
16+
<span>{{ section.reserved_title }}</span>
1717
{%- if tab == "diff" -%}
1818
{%- if section_change is not none -%}
1919
{%- if section_change.section_token is not none -%}

strictdoc/git/change.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ def __init__(
9595

9696
if matched_mid is not None or matched_uid is not None:
9797
change_type = ChangeType.SECTION_MODIFIED
98-
assert isinstance(lhs_section, SDocSection), lhs_section
99-
assert isinstance(rhs_section, SDocSection), rhs_section
98+
assert isinstance(lhs_section, SDocSection) or (
99+
isinstance(lhs_section, SDocNode)
100+
and lhs_section.node_type == "SECTION"
101+
), lhs_section
102+
assert isinstance(rhs_section, SDocSection) or (
103+
isinstance(rhs_section, SDocNode)
104+
and rhs_section.node_type == "SECTION"
105+
), rhs_section
100106
elif lhs_section is not None:
101107
assert rhs_section is None, rhs_section
102108
change_type = ChangeType.SECTION_REMOVED

strictdoc/git/project_diff_analyzer.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ def _iterate_one_index(
422422
for node in document_iterator.all_content(
423423
print_fragments=True, print_fragments_from_files=False
424424
):
425-
if isinstance(node, (SDocSection, SDocDocument)):
425+
if isinstance(node, (SDocSection, SDocDocument)) or (
426+
isinstance(node, SDocNode) and node.node_type == "SECTION"
427+
):
426428
if node in change_stats.map_nodes_to_changes:
427429
continue
428430

@@ -455,8 +457,12 @@ def _iterate_one_index(
455457
)
456458
# FIXME: This is when a Requirement becomes
457459
# a Section with the same UID preserved.
458-
if other_section_or_none is not None and not isinstance(
459-
other_section_or_none, SDocSection
460+
if other_section_or_none is not None and not (
461+
isinstance(other_section_or_none, SDocSection)
462+
or (
463+
isinstance(other_section_or_none, SDocNode)
464+
and other_section_or_none.node_type == "SECTION"
465+
)
460466
):
461467
other_section_or_none = None
462468
matched_uid = None
@@ -481,19 +487,22 @@ def _iterate_one_index(
481487
uid_modified = True
482488

483489
if other_section_or_none is not None:
484-
if node.title != other_section_or_none.title:
490+
if (
491+
node.reserved_title
492+
!= other_section_or_none.reserved_title
493+
):
485494
title_modified = True
486495
lhs_colored_title_diff = (
487496
get_colored_html_diff_string(
488-
node.title,
489-
other_section_or_none.title,
497+
node.reserved_title,
498+
other_section_or_none.reserved_title,
490499
"left",
491500
)
492501
)
493502
rhs_colored_title_diff = (
494503
get_colored_html_diff_string(
495-
node.title,
496-
other_section_or_none.title,
504+
node.reserved_title,
505+
other_section_or_none.reserved_title,
497506
"right",
498507
)
499508
)
@@ -508,8 +517,12 @@ def _iterate_one_index(
508517
if other_section_or_none is not None:
509518
section_token = MID.create()
510519

511-
lhs_section: Optional[Union[SDocSection, SDocDocument]]
512-
rhs_section: Optional[Union[SDocSection, SDocDocument]]
520+
lhs_section: Optional[
521+
Union[SDocSection, SDocDocument, SDocNode]
522+
]
523+
rhs_section: Optional[
524+
Union[SDocSection, SDocDocument, SDocNode]
525+
]
513526
if side == "left":
514527
lhs_section = node
515528
rhs_section = other_section_or_none
@@ -536,7 +549,7 @@ def _iterate_one_index(
536549
] = section_change
537550
change_stats.add_change(section_change)
538551

539-
if isinstance(node, SDocNode):
552+
if isinstance(node, SDocNode) and node.node_type != "SECTION":
540553
#
541554
# Step: We check if a requirement was modified at all, or if
542555
# it has already been checked before. Skipping the requirement
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from tests.end2end.helpers.screens.screen import Screen
2+
3+
4+
class Screen_Diff(Screen): # pylint: disable=invalid-name
5+
def do_enter_field_lhs(self, field_value: str):
6+
xpath_to_lhs_field = "(//*[@data-testid='diff-screen-field-lhs'])"
7+
8+
self.do_fill_in_field_value(xpath_to_lhs_field, field_value=field_value)
9+
10+
def do_enter_field_rhs(self, field_value: str):
11+
xpath_to_lhs_field = "(//*[@data-testid='diff-screen-field-rhs'])"
12+
13+
self.do_fill_in_field_value(xpath_to_lhs_field, field_value=field_value)
14+
15+
def do_submit(self):
16+
self.test_case.click_xpath('//*[@data-testid="form-submit-action"]')
17+
18+
def do_switch_tab_to_changelog(self):
19+
self.test_case.click_xpath(
20+
'//*[@data-testid="diff-screen-tab-changelog"]'
21+
)
22+
23+
def assert_documents_modified(self, stats: str) -> None:
24+
xpath = '//*[@data-testid="table-row-value-documents-modified"]'
25+
self.assert_xpath_contains(xpath, stats)
26+
27+
def assert_sections_modified(self, stats: str) -> None:
28+
xpath = '//*[@data-testid="table-row-value-sections-modified"]'
29+
self.assert_xpath_contains(xpath, stats)
30+
31+
def assert_requirements_modified(self, stats: str) -> None:
32+
xpath = '//*[@data-testid="table-row-value-requirements-modified"]'
33+
self.assert_xpath_contains(xpath, stats)

0 commit comments

Comments
 (0)