Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui custom capabilities testcases #2287

Merged
merged 25 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9d7de35
Add CustomCapabilities testcase
maryvictol Oct 29, 2021
d87e3a2
Merge branch 'develop' into gui_custom_capabilities_testcases
maryvictol Oct 29, 2021
d0c6ccc
Update CustomCapabilities testcase
maryvictol Oct 30, 2021
3912ec8
add customCapabilities test
maryvictol Nov 2, 2021
00c63e9
Merge remote-tracking branch 'origin/develop' into gui_custom_capabil…
maryvictol Nov 2, 2021
7f8ef8f
update customCapabilities tests
maryvictol Nov 3, 2021
1d1b3e0
update CustomCapabilities test
maryvictol Nov 8, 2021
15fe275
update CustomCapabilities test
maryvictol Nov 8, 2021
c87ba0d
update customCapabilities test
maryvictol Nov 8, 2021
793ae0e
update customCapabilities testcase
maryvictol Nov 11, 2021
07428b8
Update customCapabilities testcase
maryvictol Nov 11, 2021
a291bef
add CustomCapabilities test 2295
maryvictol Nov 12, 2021
02ec2ef
update CustomCapabilities test
maryvictol Nov 12, 2021
0577eae
update CustomCapabilities test
maryvictol Nov 12, 2021
b4639f7
update CustomCapabilities test
maryvictol Nov 12, 2021
8fb19ca
update CustomCapabilities test
maryvictol Nov 12, 2021
0e25883
update CustomCapabilities test
maryvictol Nov 12, 2021
cb62a26
update CustomCapabilities test
maryvictol Nov 12, 2021
cba79a5
update CustomCapabilities test
maryvictol Nov 12, 2021
1d0c0b6
update CustomCapabilities test
maryvictol Nov 12, 2021
4b11fd4
update CustomCapabilities test
maryvictol Nov 12, 2021
8a380e9
Update customCapabilities testcases
maryvictol Nov 15, 2021
a0bb643
update CustomCapabilities test
maryvictol Nov 15, 2021
dc12530
update CustomCapabilities tests
maryvictol Nov 15, 2021
b707d47
Issue #2287 custom capabilities small clean up
kamyshova Nov 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update CustomCapabilities tests
  • Loading branch information
maryvictol committed Nov 15, 2021
commit dc12530633d4201f4e6c6d514d5bb2e52fbfec5b
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ public class ToolsParametersTest
extends AbstractSeveralPipelineRunningTest
implements Authorization, Tools {

private static final String CUSTOM_CAPABILITIES_1_JSON = "/customCapabilities1.json";
private static final String CUSTOM_CAPABILITIES_2_JSON = "/customCapabilities2.json";
private final String tool = C.TESTING_TOOL_NAME;
private final String registry = C.DEFAULT_REGISTRY;
private final String group = C.DEFAULT_GROUP;
private final String invalidEndpoint = "8700";
private final String launchCapabilities = "launch.capabilities";
private static final String CUSTOM_CAPABILITIES_1_JSON = "/customCapabilities1.json";
private static final String CUSTOM_CAPABILITIES_2_JSON = "/customCapabilities2.json";
private String prefInitialValue = "";
private final String custCapability1 = "testCapability1";
private final String custCapability2 = "testCapability2";
private final String capabilityParam = "CP_CAP_CUSTOM_%s";
private final String logMessage = "Running '%s' commands:";

@BeforeClass
public void getPreferencesValue() {
Expand All @@ -67,7 +69,6 @@ public void getPreferencesValue() {

@BeforeMethod
void openApplication() {
open(C.ROOT_ADDRESS);
logoutIfNeeded();
loginAs(admin);
}
Expand All @@ -85,7 +86,7 @@ public void fallBackToDefaultToolSettings() {
.saveIfNeeded();
}

@Test
@Test(priority = 1)
@TestCase(value = {"EPMCMBIBPC-502"})
public void runToolThatHaveNoNginxEndpoint() {
tools()
Expand All @@ -105,7 +106,7 @@ public void runToolThatHaveNoNginxEndpoint() {
.assertPageTitleIs("502 Bad Gateway");
}

@Test
@Test(priority = 2)
@TestCase(value = {"2234"})
public void customCapabilitiesImplementation() {
navigationMenu()
Expand All @@ -127,13 +128,13 @@ public void customCapabilitiesImplementation() {
.launch(this)
.showLog(getLastRunId())
.expandTab(PARAMETERS)
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability1), "true"), exist)
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability2), "true"), exist)
.ensure(configurationParameter(format(capabilityParam, custCapability1), "true"), exist)
.ensure(configurationParameter(format(capabilityParam, custCapability2), "true"), exist)
.waitForSshLink()
.click(taskWithName("Console"))
.waitForLog("start.sh")
.ensure(log(), matchText(format("Running '%s' commands:", custCapability1)))
.ensure(log(), matchText(format("Running '%s' commands:", custCapability2)))
.ensure(log(), matchText(format(logMessage, custCapability1)))
.ensure(log(), matchText(format(logMessage, custCapability2)))
.ensure(log(), matchText( "Command: 'echo testLine1'"))
.ensure(log(), matchText( "Command: 'echo testLine2'"))
.ssh(shell -> shell
Expand All @@ -145,7 +146,7 @@ public void customCapabilitiesImplementation() {
.close());
}

@Test
@Test(priority = 2)
@TestCase(value = {"2295"})
public void customCapabilitiesWithConfiguredJobParameters() {
navigationMenu()
Expand All @@ -165,8 +166,8 @@ public void customCapabilitiesWithConfiguredJobParameters() {
.launch(this)
.showLog(getLastRunId())
.expandTab(PARAMETERS)
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability1), "true"), exist)
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability2), "true"), exist)
.ensure(configurationParameter(format(capabilityParam, custCapability1), "true"), exist)
.ensure(configurationParameter(format(capabilityParam, custCapability2), "true"), exist)
.ensure(configurationParameter("MY_PARAM1", "MY_VALUE1"), exist)
.ensure(configurationParameter("MY_PARAM2", "MY_VALUE2"), exist)
.ensure(configurationParameter("MY_BOOLEAN_PARAM", "false"), exist)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.function.Supplier;

import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions;

import static com.codeborne.selenide.Condition.appear;
import static com.codeborne.selenide.Condition.appears;
Expand Down Expand Up @@ -540,6 +541,16 @@ default void closeTab() {
switchTo().window(tabs.get(0));
}

default ELEMENT_TYPE deleteExtraBrackets(SelenideElement selenideElement, int number) {
Actions action = actions().moveToElement(selenideElement);
sleep(500, MILLISECONDS);
for (int i = 0; i < number; i++) {
action.sendKeys(Keys.DELETE);
}
action.perform();
return (ELEMENT_TYPE) this;
}

class Entry {
private final Primitive primitive;
private final SelenideElement selenideElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,6 @@ public FileEditingPopupAO assertFileIsNotEmpty() {
return this;
}

private FileEditingPopupAO deleteExtraBrackets() {
return deleteExtraBrackets(100);
}

public FileEditingPopupAO deleteExtraBrackets(int number) {
Actions action = actions().moveToElement($(byClassName("CodeMirror-line")));
sleep(500, MILLISECONDS);
for (int i = 0; i < number; i++) {
action.sendKeys(Keys.DELETE);
}
action.perform();
return this;
}

private FileEditingPopupAO fillWith(String newText) {
Utils.clickAndSendKeysWithSlashes($(byClassName("CodeMirror-line")), newText);
return this;
Expand Down Expand Up @@ -273,11 +259,16 @@ public FileEditingPopupAO editFile(final UnaryOperator<String> action) {
if (!code.equals(edited)) {
clear();
fillWith(edited);
deleteExtraBrackets();
deleteExtraBrackets($(byClassName("CodeMirror-line")), 100);
}
return this;
}

public FileEditingPopupAO deleteExtraBrackets(int num) {
deleteExtraBrackets($(byClassName("CodeMirror-line")), num);
return this;
}

public FileEditingPopupAO shouldContainInCode(final String expectedCode) {
final Function<String, SelenideElement> lineWithText =
text -> $x(format("//pre[contains(@class, 'CodeMirror-line') and contains(., '%s')]", text));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import static com.epam.pipeline.autotests.utils.PipelineSelectors.combobox;
import static com.epam.pipeline.autotests.utils.PipelineSelectors.inputOf;
import static com.epam.pipeline.autotests.utils.PipelineSelectors.menuitem;
import static com.epam.pipeline.autotests.utils.Utils.*;
import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -1160,42 +1161,39 @@ public LaunchAO switchToLaunch() {
return new LaunchAO(parentAO);
}

public PreferencesAO setPreference(String preference, String value, boolean eyeIsChecked) {
searchPreference(preference);
final By pref = getByField(preference);
click(pref)
.clear(pref)
.setValue(pref, value);
private void setEyeOption(boolean eyeIsChecked) {
final SelenideElement eye = context().find(byClassName("preference-group__preference-row"))
.find(byClassName("anticon"));
if((eye.has(cssClass("anticon-eye-o")) && eyeIsChecked) ||
(eye.has(cssClass("anticon-eye")) && !eyeIsChecked)) {
eye.click();
}
}

public PreferencesAO setPreference(String preference, String value, boolean eyeIsChecked) {
searchPreference(preference);
final By pref = getByField(preference);
click(pref)
.clear(pref)
.setValue(pref, value);
setEyeOption(eyeIsChecked);
return this;
}

public String getPreference(String preference) {
searchPreference(preference);
String[] strings = context().$(byClassName("CodeMirror-code"))
.findAll(byClassName("CodeMirror-line")).texts().toArray(new String[0]);
return String.join("\n", strings);
List<String> list = context().$(byClassName("CodeMirror-code"))
.findAll(byClassName("CodeMirror-line")).texts();
return (list.size() <= 1 ) ? String.join("", list) : String.join("\n", list);
}

public PreferencesAO clearAndSetJsonToPreference(String preference, String value, boolean eyeIsChecked) {
SelenideElement pref = context().$(byClassName("preference-group__code-editor"));
searchPreference(preference);
Utils.clearTextField(pref);
Utils.clickAndSendKeysWithSlashes(pref, value);
for (int i = 0; i < 100; i++) {
actions().sendKeys(Keys.DELETE).perform();
}
final SelenideElement eye = context().find(byClassName("preference-group__preference-row"))
.find(byClassName("anticon"));
if((eye.has(cssClass("anticon-eye-o")) && eyeIsChecked) ||
(eye.has(cssClass("anticon-eye")) && !eyeIsChecked)) {
eye.click();
}
clearTextField(pref);
clickAndSendKeysWithSlashes(pref, value);
deleteExtraBrackets(pref, 100);
setEyeOption(eyeIsChecked);
return this;
}

Expand All @@ -1207,12 +1205,7 @@ public PreferencesAO setCheckboxPreference(String preference, boolean checkboxIs
(!checkBox.has(cssClass("ant-checkbox-checked")) && checkboxIsEnable)) {
checkBox.click();
}
final SelenideElement eye = context().find(byClassName("preference-group__preference-row"))
.find(byClassName("anticon"));
if((eye.has(cssClass("anticon-eye-o")) && eyeIsChecked) ||
(eye.has(cssClass("anticon-eye")) && !eyeIsChecked)) {
eye.click();
}
setEyeOption(eyeIsChecked);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion e2e/gui/src/test/resources/customCapabilities1.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"echo 'testLine2' >> ~/testFile1.txt"
]
}
}
}
2 changes: 1 addition & 1 deletion e2e/gui/src/test/resources/customCapabilities2.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"MY_NUMBER_PARAM": 2
}
}
}
}