StrictDoc Documentation
tests/end2end/screens/document/_cross_cutting/RELATIONS/update_node/_validations/update_requirement_parent_uid_must_not_be_empty/test_case.py
Source file coverage
Path:
tests/end2end/screens/document/_cross_cutting/RELATIONS/update_node/_validations/update_requirement_parent_uid_must_not_be_empty/test_case.py
Lines:
62
Non-empty lines:
50
Non-empty lines covered with requirements:
50 / 50 (100.0%)
Functions:
2
Functions covered by requirements:
2 / 2 (100.0%)
1
"""
2
@relation(SDOC-SRS-158, scope=file)
3
"""
4
 
5
from tests.end2end.e2e_case import E2ECase
6
from tests.end2end.end2end_test_setup import End2EndTestSetup
7
from tests.end2end.helpers.screens.document.form_edit_requirement import (
8
    Form_EditRequirement,
9
)
10
from tests.end2end.helpers.screens.project_index.screen_project_index import (
11
    Screen_ProjectIndex,
12
)
13
from tests.end2end.server import SDocTestServer
14
 
15
 
16
class Test(E2ECase):
17
    def test(self):
18
        test_setup = End2EndTestSetup(path_to_test_file=__file__)
19
 
20
        with SDocTestServer(
21
            input_path=test_setup.path_to_sandbox
22
        ) as test_server:
23
            self.open(test_server.get_host_and_port())
24
 
25
            screen_project_index = Screen_ProjectIndex(self)
26
 
27
            screen_project_index.assert_on_screen()
28
            screen_project_index.assert_contains_document("Document 1")
29
 
30
            screen_document = screen_project_index.do_click_on_first_document()
31
 
32
            screen_document.assert_on_screen_document()
33
            screen_document.assert_header_document_title("Document 1")
34
 
35
            requirement = screen_document.get_node()
36
 
37
            #
38
            # Case 1: Adding a new empty relation field — form saves successfully,
39
            # the empty relation is silently skipped (not saved).
40
            # The existing PARENT: REQ-002 relation is preserved.
41
            #
42
            form_edit_requirement: Form_EditRequirement = (
43
                requirement.do_open_form_edit_requirement()
44
            )
45
            form_edit_requirement.do_open_tab("Relations")
46
            form_edit_requirement.do_form_add_field_relation()
47
            form_edit_requirement.do_form_submit()
48
 
49
            #
50
            # Case 2: Clearing the UID of an existing saved relation (without
51
            # deleting the row) must raise a validation error.
52
            # This is distinct from Case 1: the row already exists in the document,
53
            # so a blank UID is treated as a mistake, not an intent to remove.
54
            #
55
            form_edit_requirement = requirement.do_open_form_edit_requirement()
56
            form_edit_requirement.do_open_tab("Relations")
57
            form_edit_requirement.do_clear_relation_uid(1)
58
            form_edit_requirement.do_form_submit_and_catch_error(
59
                "Requirement relation UID must not be empty."
60
            )
61
 
62
        assert test_setup.compare_sandbox_and_expected_output()