Skip to content

Commit

Permalink
add tests for POST requests with no/raw/json/form-url-encoded body
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Apr 30, 2024
1 parent 684846a commit c5e62d8
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 16 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -52,8 +53,9 @@ fun <T: DropDownable> DropDownView(
)
},
arrowPadding: PaddingValues = PaddingValues(0.dp),
testTagPart: TestTagPart? = null,
selectedItem: T? = null,
onClickItem: (T) -> Boolean
onClickItem: (T) -> Boolean,
) {
val colors = LocalColor.current
val populatedItems = populateItems(items)
Expand All @@ -67,11 +69,22 @@ fun <T: DropDownable> DropDownView(
modifier = Modifier.background(colors.backgroundContextMenu)
) {
populatedItems.forEach { item ->
Column(modifier = Modifier.clickable {
if (onClickItem(item)) {
isShowContextMenu = false
Column(modifier = Modifier
.clickable {
if (onClickItem(item)) {
isShowContextMenu = false
}
}
}.padding(horizontal = 8.dp, vertical = 4.dp).fillMaxWidth()) {
.padding(horizontal = 8.dp, vertical = 4.dp)
.fillMaxWidth()
.run {
if (testTagPart != null) {
testTag(buildTestTag(testTagPart, TestTagPart.DropdownItem, item.displayText)!!)
} else {
this
}
}
) {
Row {
contentView(item, false, item.key == selectedItem?.key, isClickable)
}
Expand All @@ -89,6 +102,12 @@ fun <T: DropDownable> DropDownView(
} else {
this
}
}.run {
if (testTagPart != null) {
testTag(buildTestTag(testTagPart, TestTagPart.DropdownButton)!!)
} else {
this
}
}
) {
if (isShowLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ fun RequestEditorView(
onRequestModified(request.copyForApplication(application = it.key.application, method = it.key.method))
true
},
testTagPart = TestTagPart.RequestMethodDropdown,
modifier = Modifier.fillMaxHeight()
)

Expand Down Expand Up @@ -970,7 +971,8 @@ private fun RequestBodyEditor(
)
)
true
}
},
testTagPart = TestTagPart.RequestBodyTypeDropdown,
)
} else {
AppText(selectedContentType.displayText)
Expand Down Expand Up @@ -1104,6 +1106,7 @@ private fun RequestBodyEditor(
},
knownVariables = environmentVariableKeys,
isSupportFileValue = false,
testTagPart = TestTagPart.RequestBodyFormUrlEncodedForm,
modifier = remainModifier,
)

Expand Down Expand Up @@ -1137,6 +1140,7 @@ private fun RequestBodyEditor(
},
knownVariables = environmentVariableKeys,
isSupportFileValue = true,
testTagPart = TestTagPart.RequestBodyMultipartForm,
modifier = remainModifier,
)

Expand Down Expand Up @@ -1280,6 +1284,7 @@ private fun RequestBodyTextEditor(
)
},
transformations = transformations,
testTag = TestTag.RequestStringBodyTextField.name,
)
} else {
CodeEditorView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ enum class TestTag {
FirstTimeCreateProjectButton,
FirstTimeCreateSubprojectButton,
CreateRequestOrFolderButton,
RequestMethodDropdownButton,
RequestUrlTextField,
RequestParameterTypeTab,
RequestStringBodyTextField,
RequestFireOrDisconnectButton,
ResponseStatus,
ResponseBody,
}

enum class TestTagPart {
RequestMethodDropdown,
RequestHeader,
RequestQueryParameter,
RequestBodyTypeDropdown,
RequestBodyFormUrlEncodedForm,
RequestBodyMultipartForm,
Inherited,
Current,
Key,
Value,
FileButton,
ValueTypeDropdown,
DropdownButton,
DropdownItem,
}

fun buildTestTag(vararg parts: Any?): String? {
Expand Down
Loading

0 comments on commit c5e62d8

Please sign in to comment.