Action test fixes (#130)

* Fixes for tests
* remove marketplace tests
* fix some other tests
* Simplify update datasource
* Add cypress env variables
This commit is contained in:
Hetu Nandu 2020-07-21 19:31:51 +05:30 committed by GitHub
parent 74231120fe
commit fe43680abc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 69 additions and 79 deletions

View File

@ -153,6 +153,10 @@ jobs:
CYPRESS_URL: ${{ secrets.CYPRESS_URL }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
run: |
./cypress/setup-test.sh
@ -164,6 +168,10 @@ jobs:
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
with:
browser: chrome
headless: true

View File

@ -3,7 +3,7 @@
"methods": "users",
"headerKey": "Content-Type",
"headerValue": "application/json",
"headerValueBlank": " ",
"headerValueBlank": "",
"queryKey": "page",
"queryValue": "2",
"queryAndValue": "users?page=2",

View File

@ -112,8 +112,8 @@ describe("API Panel Test Functionality", function() {
cy.EnterSourceDetailsWithHeader(
testdata.baseUrl,
testdata.methods,
testdata.headerKey,
testdata.headerValue,
testdata.headerValueBlank,
testdata.headerValueBlank,
);
cy.RunAPI();
cy.ResponseStatusCheck(testdata.successStatusCode);
@ -142,8 +142,8 @@ describe("API Panel Test Functionality", function() {
cy.EnterSourceDetailsWithQueryParam(
testdata.baseUrl,
testdata.methods,
testdata.headerKey,
testdata.headerValue,
testdata.headerValueBlank,
testdata.headerValueBlank,
testdata.queryKey,
testdata.queryValue,
);

View File

@ -1,35 +1,39 @@
/// <reference types="Cypress" />
const testdata = require("../../../fixtures/testdata.json");
const apiwidget = require("../../../locators/apiWidgetslocator.json");
describe("API Panel Test Functionality ", function() {
it("Test Market place API by adding to a page", function() {
cy.log("Login Successful");
cy.NavigateToAPI_Panel();
cy.wait("@getCategories");
cy.wait("@getTemplateCollections");
cy.wait("@get3PProviders");
cy.log("Navigation to API Panel screen successful");
cy.get(apiwidget.marketPlaceapi)
.first()
.click();
cy.wait("@get3PProviderTemplates");
cy.get(".apiName")
.first()
.invoke("text")
.then(ApiName => {
cy.get(apiwidget.addPageButton)
.first()
.click();
const searchApiName = ApiName.replace(/\s/g, "");
cy.log(searchApiName);
cy.wait("@getActions");
cy.SearchAPIandClick(searchApiName);
cy.get(apiwidget.apidocumentaionLink)
.invoke("text")
.then(apidocumentation => {
cy.log(apidocumentation);
expect(apidocumentation).to.eq("API documentation");
});
});
});
});
/*
* Commenting because CE does not have marketplace anymore
*
* */
// /// <reference types="Cypress" />
// const testdata = require("../../../fixtures/testdata.json");
// const apiwidget = require("../../../locators/apiWidgetslocator.json");
// describe("API Panel Test Functionality ", function() {
// it("Test Market place API by adding to a page", function() {
// cy.log("Login Successful");
// cy.NavigateToAPI_Panel();
// cy.wait("@getCategories");
// cy.wait("@getTemplateCollections");
// cy.wait("@get3PProviders");
// cy.log("Navigation to API Panel screen successful");
// cy.get(apiwidget.marketPlaceapi)
// .first()
// .click();
// cy.wait("@get3PProviderTemplates");
// cy.get(".apiName")
// .first()
// .invoke("text")
// .then(ApiName => {
// cy.get(apiwidget.addPageButton)
// .first()
// .click();
// const searchApiName = ApiName.replace(/\s/g, "");
// cy.log(searchApiName);
// cy.wait("@getActions");
// cy.SearchAPIandClick(searchApiName);
// cy.get(apiwidget.apidocumentaionLink)
// .invoke("text")
// .then(apidocumentation => {
// cy.log(apidocumentation);
// expect(apidocumentation).to.eq("API documentation");
// });
// });
// });
// });

View File

@ -20,4 +20,4 @@
"apiPaginationNextTest": ".t--apiFormPaginationNextTest",
"apiPaginationTab": ".t--apiFormPaginationType",
"apiTab": ".react-tabs__tab-list li"
}
}

View File

@ -1307,10 +1307,8 @@ Cypress.Commands.add("startServerAndRoutes", () => {
cy.route("POST", "/api/v1/applications/publish/*").as("publishApp");
cy.route("PUT", "/api/v1/layouts/*/pages/*").as("updateLayout");
cy.route("PUT", "/api/v1/actions/*").as("putActions");
cy.route("POST", "/track/*").as("postTrack");
cy.route("POST", "/api/v1/actions/execute").as("postExecute");
cy.route("POST", "/api/v1/actions").as("postaction");
cy.route("POST", "/api/v1/actions").as("createNewApi");
cy.route("POST", "/api/v1/import?type=CURL&pageId=*&name=*").as("curlImport");

View File

@ -4,7 +4,7 @@ import {
ReduxAction,
ReduxActionErrorTypes,
} from "constants/ReduxActionConstants";
import { Action, RestAction } from "entities/Action";
import { Action } from "entities/Action";
import { batchAction } from "actions/batchActions";
export const createActionRequest = (payload: Partial<Action>) => {
@ -50,7 +50,7 @@ export const fetchActionsForPage = (pageId: string) => {
};
};
export const fetchActionsForPageSuccess = (actions: RestAction[]) => {
export const fetchActionsForPageSuccess = (actions: Action[]) => {
return {
type: ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS,
payload: actions,
@ -74,7 +74,7 @@ export const updateAction = (payload: { id: string }) => {
};
};
export const updateActionSuccess = (payload: { data: RestAction }) => {
export const updateActionSuccess = (payload: { data: Action }) => {
return {
type: ReduxActionTypes.UPDATE_ACTION_SUCCESS,
payload,
@ -107,7 +107,7 @@ export const moveActionRequest = (payload: {
};
};
export const moveActionSuccess = (payload: RestAction) => {
export const moveActionSuccess = (payload: Action) => {
return {
type: ReduxActionTypes.MOVE_ACTION_SUCCESS,
payload,
@ -135,10 +135,7 @@ export const copyActionRequest = (payload: {
};
};
export const copyActionSuccess = (payload: {
id: string;
destinationPageId: string;
}) => {
export const copyActionSuccess = (payload: Action) => {
return {
type: ReduxActionTypes.COPY_ACTION_SUCCESS,
payload,

View File

@ -46,35 +46,17 @@ type Props = EditorProps &
class EmbeddedDatasourcePathComponent extends React.Component<Props> {
handleDatasourceUrlUpdate = (datasourceUrl: string) => {
const { datasource, pluginId, orgId, datasourceList } = this.props;
const { datasource, pluginId, orgId } = this.props;
const urlHasUpdated =
datasourceUrl !== datasource.datasourceConfiguration?.url;
if (urlHasUpdated) {
if ("id" in datasource && datasource.id) {
this.props.updateDatasource({
...DEFAULT_DATASOURCE(pluginId, orgId),
datasourceConfiguration: {
...datasource.datasourceConfiguration,
url: datasourceUrl,
},
});
} else {
const matchesExistingDatasource = _.find(
datasourceList,
d => d.datasourceConfiguration?.url === datasourceUrl,
);
if (matchesExistingDatasource) {
this.props.updateDatasource(matchesExistingDatasource);
} else {
this.props.updateDatasource({
...DEFAULT_DATASOURCE(pluginId, orgId),
datasourceConfiguration: {
...datasource.datasourceConfiguration,
url: datasourceUrl,
},
});
}
}
this.props.updateDatasource({
...DEFAULT_DATASOURCE(pluginId, orgId),
datasourceConfiguration: {
...datasource.datasourceConfiguration,
url: datasourceUrl,
},
});
}
};
@ -113,7 +95,7 @@ class EmbeddedDatasourcePathComponent extends React.Component<Props> {
const matches = value.match(urlGroupsRegexExp);
if (matches && matches.length) {
datasourceUrl = matches[1];
path = `${matches[2]}${matches[3]}`;
path = `${matches[2] || ""}${matches[3] || ""}`;
}
} else {
datasourceUrl = value;

View File

@ -249,6 +249,7 @@ const actionsReducer = createReducer(initialState, {
...a,
config: {
...a.config,
id: "TEMP_COPY_ID",
name: action.payload.name,
pageId: action.payload.destinationPageId,
},

View File

@ -384,7 +384,7 @@ export function* refactorActionName(
}
function* saveApiNameSaga(action: ReduxAction<{ id: string; name: string }>) {
// Takes from drafts, checks if the name isValid, saves
// Takes from state, checks if the name isValid, saves
const apiId = action.payload.id;
const api = yield select(state =>
state.entities.actions.find(