File indexing completed on 2025-01-19 04:56:43
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Kevin Ottens <ervin@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 #include <testlib/qtest_zanshin.h> 0008 #include <featurelib/zanshincontext.h> 0009 0010 using namespace Testlib; 0011 0012 // Feature: Inbox task association 0013 // As someone collecting tasks 0014 // I can associate a task to another one 0015 // In order to deal with complex tasks requiring several steps 0016 class InboxDragAndDropFeature : public QObject 0017 { 0018 Q_OBJECT 0019 private slots: 0020 void Dropping_a_task_on_another_one_makes_it_a_child() 0021 { 0022 ZanshinContext c; 0023 Given(c.I_display_the_page("Inbox")); 0024 And(c.there_is_an_item_in_the_central_list("Buy apples")); 0025 When(c.I_drop_the_item_on_the_central_list("Errands")); 0026 And(c.I_list_the_items()); 0027 Then(c.the_list_is({ 0028 { "display" }, 0029 { 0030 { "Errands" }, 0031 { "Errands / Buy apples" }, 0032 { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 0033 { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 0034 { "Buy cheese" }, 0035 { "Buy kiwis" }, 0036 { "Buy pears" }, 0037 { "Buy rutabagas" } 0038 } 0039 })); 0040 } 0041 0042 void Dropping_a_child_task_on_the_inbox_makes_it_top_level() 0043 { 0044 ZanshinContext c; 0045 Given(c.I_display_the_page("Inbox")); 0046 And(c.there_is_an_item_in_the_central_list("Buy apples")); 0047 And(c.I_drop_the_item_on_the_central_list("Errands")); 0048 And(c.there_is_an_item_in_the_central_list("Errands / Buy apples")); 0049 When(c.I_drop_the_item_on_the_page_list("Inbox")); 0050 And(c.I_list_the_items()); 0051 Then(c.the_list_is({ 0052 { "display" }, 0053 { 0054 { "Errands" }, 0055 { "Buy apples" }, 0056 { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 0057 { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 0058 { "Buy cheese" }, 0059 { "Buy kiwis" }, 0060 { "Buy pears" }, 0061 { "Buy rutabagas" } 0062 } 0063 })); 0064 } 0065 0066 void Dropping_two_tasks_on_another_one_makes_them_children() 0067 { 0068 ZanshinContext c; 0069 Given(c.I_display_the_page("Inbox")); 0070 And(c.the_central_list_contains_items_named({"Buy apples", "Buy pears"})); 0071 When(c.I_drop_items_on_the_central_list("Errands")); 0072 And(c.I_list_the_items()); 0073 Then(c.the_list_is({ 0074 { "display" }, 0075 { 0076 { "Errands" }, 0077 { "Errands / Buy apples" }, 0078 { "Errands / Buy pears" }, 0079 { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 0080 { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 0081 { "Buy cheese" }, 0082 { "Buy kiwis" }, 0083 { "Buy rutabagas" } 0084 } 0085 })); 0086 } 0087 0088 void Dropping_two_child_tasks_on_the_inbox_makes_them_top_level() 0089 { 0090 ZanshinContext c; 0091 Given(c.I_display_the_page("Inbox")); 0092 And(c.the_central_list_contains_items_named({"Buy apples", "Buy pears"})); 0093 And(c.I_drop_items_on_the_central_list("Errands")); 0094 And(c.the_central_list_contains_items_named({"Errands / Buy apples", "Errands / Buy pears"})); 0095 When(c.I_drop_items_on_the_page_list("Inbox")); 0096 And(c.I_list_the_items()); 0097 Then(c.the_list_is({ 0098 { "display" }, 0099 { 0100 { "Errands" }, 0101 { "Buy apples" }, 0102 { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 0103 { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 0104 { "Buy cheese" }, 0105 { "Buy kiwis" }, 0106 { "Buy pears" }, 0107 { "Buy rutabagas" } 0108 } 0109 })); 0110 } 0111 0112 void Dropping_a_task_on_the_inbox_removes_it_from_its_associated_project() 0113 { 0114 ZanshinContext c; 0115 Given(c.I_display_the_page("Projects / TestData ยป Calendar1 / Prepare talk about TDD")); 0116 And(c.there_is_an_item_in_the_central_list("Create Sozi SVG")); 0117 When(c.I_drop_the_item_on_the_page_list("Inbox")); 0118 And(c.I_display_the_page("Inbox")); 0119 And(c.I_look_at_the_central_list()); 0120 And(c.I_list_the_items()); 0121 Then(c.the_list_is({ 0122 { "display" }, 0123 { 0124 { "Errands" }, 0125 { "Buy apples" }, 0126 { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 0127 { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 0128 { "Buy cheese" }, 0129 { "Buy kiwis" }, 0130 { "Buy pears" }, 0131 { "Buy rutabagas" }, 0132 { "Create Sozi SVG" } 0133 } 0134 })); 0135 } 0136 0137 void Deparenting_a_task_by_dropping_on_the_central_list_blank_area() 0138 { 0139 ZanshinContext c; 0140 Given(c.I_display_the_page("Inbox")); 0141 And(c.I_look_at_the_central_list()); 0142 And(c.there_is_an_item_in_the_central_list("Buy apples")); 0143 And(c.I_drop_the_item_on_the_central_list("Errands")); 0144 And(c.I_look_at_the_central_list()); 0145 And(c.there_is_an_item_in_the_central_list("Errands / Buy apples")); 0146 When(c.I_drop_the_item_on_the_blank_area_of_the_central_list()); 0147 And(c.I_list_the_items()); 0148 Then(c.the_list_is({ 0149 { "display" }, 0150 { 0151 { "Errands" }, 0152 { "Buy apples" }, 0153 { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 0154 { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 0155 { "Buy cheese" }, 0156 { "Buy kiwis" }, 0157 { "Buy pears" }, 0158 { "Buy rutabagas" } 0159 } 0160 })); 0161 } 0162 0163 void Dropping_a_task_on_the_inbox_removes_it_from_all_its_contexts() 0164 { 0165 ZanshinContext c; 0166 Given(c.I_display_the_page("Contexts / Errands")); 0167 And(c.there_is_an_item_in_the_central_list("Buy kiwis")); 0168 When(c.I_drop_the_item_on_the_page_list("Inbox")); 0169 And(c.I_display_the_page("Contexts / Errands")); 0170 And(c.I_look_at_the_central_list()); 0171 Then(c.the_list_does_not_contain("Buy kiwis")); 0172 } 0173 }; 0174 0175 ZANSHIN_TEST_MAIN(InboxDragAndDropFeature) 0176 0177 #include "inboxdraganddropfeature.moc"