Skip to content

Commit

Permalink
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
Browse files Browse the repository at this point in the history
…o action-redesign/databricks
  • Loading branch information
ankitakinger committed Sep 10, 2024
2 parents 06a7076 + 70a7164 commit a7ba129
Show file tree
Hide file tree
Showing 34 changed files with 497 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ describe(
it("1. Fork a template to the current app + Bug 17477", () => {
PageList.AddNewPage("Add page from template");
agHelper.AssertElementVisibility(template.templateDialogBox);
agHelper.GetNClick("//h1[text()='Applicant Tracker-test']");
agHelper.GetNClick(template.templateCard, 0, true);
agHelper.FailIfErrorToast("INTERNAL_SERVER_ERROR");
agHelper.GetNClick(template.templateViewForkButton);
agHelper.WaitUntilToastDisappear("template added successfully");
assertHelper.AssertNetworkStatus("updateLayout");
// [Bug]: Getting 'Resource not found' error on deploying template #17477
PageList.AddNewPage("Generate page with data");
deployMode.DeployApp();
agHelper.GetNClickByContains(
".t--page-switch-tab",
"1 Track Applications",
);
agHelper.GetNClick(locators._deployedPage, 0, true);
deployMode.NavigateBacktoEditor();
homePage.NavigateToHome();
agHelper.WaitUntilAllToastsDisappear();
Expand All @@ -35,14 +32,13 @@ describe(
homePage.CreateNewApplication();
PageList.AddNewPage("Add page from template");
agHelper.AssertElementVisibility(template.templateDialogBox);
agHelper.GetNClick("//h1[text()='Applicant Tracker-test']");
agHelper.GetNClick(template.templateCard, 0, true);
agHelper.FailIfErrorToast(
"Internal server error while processing request",
);
assertHelper.AssertNetworkStatus("getTemplatePages");
agHelper.CheckUncheck(template.selectAllPages, false);
agHelper.GetNClick(template.selectCheckbox, 1);
// [Bug]: On forking selected pages from a template, resource not found error is shown #17270
agHelper.GetNClick(template.templateViewForkButton);
agHelper.AssertElementAbsence(
locators._visibleTextSpan("Setting up the template"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ describe(
assertHelper.AssertNetworkStatus("@getDatasourceStructure"); //Making sure table dropdown is populated
agHelper.GetNClick(dataSources._selectTableDropdown, 0, true);
agHelper.GetNClickByContains(dataSources._dropdownOption, "pokemon");

agHelper.GetNClick(dataSources._selectTableDropdown, 1, true);
agHelper.GetNClickByContains(dataSources._dropdownOption, "img");

GenerateCRUDNValidateDeployPage(
"http://www.serebii.net/pokemongo/pokemon/150.png",
"150",
Expand Down Expand Up @@ -103,30 +107,68 @@ describe(
assertHelper.AssertNetworkStatus("@postExecute", 200);
agHelper.ClickButton("Got it");
assertHelper.AssertNetworkStatus("@updateLayout", 200);

deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.TABLE));

//Validating loaded table
agHelper.AssertElementExist(dataSources._selectedRow);
table.ReadTableRowColumnData(0, 0, "v2", 2000).then(($cellData) => {
expect($cellData).to.eq(col1Text);
});
table.ReadTableRowColumnData(0, 3, "v2", 200).then(($cellData) => {
expect($cellData).to.eq(col2Text);
});
table.ReadTableRowColumnData(0, 6, "v2", 200).then(($cellData) => {
expect($cellData).to.eq(col3Text);
});

//Validating loaded JSON form
cy.xpath(locators._buttonByText("Update")).then((selector) => {
cy.wrap(selector)
.invoke("attr", "class")
.then((classes) => {
//cy.log("classes are:" + classes);
expect(classes).not.contain("bp3-disabled");
findTheDataRow(col1Text).then((rowIndex: number) => {
cy.log(`This is the rowIndex of ${col1Text} : ${rowIndex}`);
table
.ReadTableRowColumnData(rowIndex, 0, "v2", 2000)
.then(($cellData) => {
expect($cellData).to.eq(col1Text);
});
table
.ReadTableRowColumnData(rowIndex, 3, "v2", 200)
.then(($cellData) => {
expect($cellData).to.eq(col2Text);
});
table
.ReadTableRowColumnData(rowIndex, 6, "v2", 200)
.then(($cellData) => {
expect($cellData).to.eq(col3Text);
});

//Validating loaded JSON form
cy.xpath(locators._buttonByText("Update")).then((selector) => {
cy.wrap(selector)
.invoke("attr", "class")
.then((classes) => {
//cy.log("classes are:" + classes);
expect(classes).not.contain("bp3-disabled");
});
});
dataSources.AssertJSONFormHeader(0, idIndex, "Id", "", true);
});
dataSources.AssertJSONFormHeader(0, idIndex, "Id", "", true);
}

function findTheDataRow(col1Text: string) {
if (col1Text.length === 0) {
return cy.wrap(0);
}

return agHelper
.GetElement(table._tableColumnDataWithText(0, col1Text, "v2"))
.closest(".tr")
.then(($p1) => {
return cy
.wrap($p1)
.parent()
.children()
.then(($children) => {
let index = 0;
$children.each((i, el) => {
// Iterate through the children
if (Cypress.$(el).is($p1)) {
// Check if the current child is p1
index = i; // Assign the index when found
}
});
return index;
});
});
}
},
);
9 changes: 9 additions & 0 deletions app/client/cypress/support/Pages/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export class Table {
_tableRow = (rowNum: number, colNum: number, version: "v1" | "v2") =>
this._tableWidgetVersion(version) +
` .tbody .td[data-rowindex=${rowNum}][data-colindex=${colNum}]`;
_tableColumnDataWithText = (
colNum: number,
columnText: string,
version: "v1" | "v2",
) =>
this._tableWidgetVersion(version) +
` .tbody .td[data-colindex=${colNum}]` +
this._tableRowColumnDataVersion(version) +
` div:contains("${columnText}")`;
_editCellIconDiv = ".t--editable-cell-icon";
_editCellEditor = ".t--inlined-cell-editor";
_editCellEditorInput = this._editCellEditor + " input";
Expand Down
10 changes: 4 additions & 6 deletions app/client/src/ce/pages/Editor/Explorer/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
DATA_SOURCES_EDITOR_ID_PATH,
matchBuilderPath,
matchViewerPath,
BUILDER_VIEWER_PATH_PREFIX,
VIEWER_PATH,
VIEWER_CUSTOM_PATH,
VIEWER_PATH_DEPRECATED,
} from "constants/routes";

import {
Expand Down Expand Up @@ -80,11 +82,7 @@ export const getActionIdFromURL = () => {
};

export function getAppViewerPageIdFromPath(path: string): string | null {
const regexes = [
`${BUILDER_VIEWER_PATH_PREFIX}:applicationSlug/:pageSlug(.*\\-):basePageId`, // VIEWER_PATH
`${BUILDER_VIEWER_PATH_PREFIX}:customSlug(.*\\-):basePageId`, // VIEWER_CUSTOM_PATH
`/applications/:baseApplicationId/pages/:basePageId`, // VIEWER_PATH_DEPRECATED
];
const regexes = [VIEWER_PATH, VIEWER_CUSTOM_PATH, VIEWER_PATH_DEPRECATED];
for (const regex of regexes) {
const match = matchPath<{ basePageId: string }>(path, { path: regex });
if (match?.params.basePageId) {
Expand Down
27 changes: 1 addition & 26 deletions app/client/src/pages/UserProfile/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@testing-library/jest-dom/extend-expect";
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import { render } from "@testing-library/react";
import { Provider } from "react-redux";
import configureStore from "redux-mock-store";
import { lightTheme } from "selectors/themeSelectors";
Expand Down Expand Up @@ -87,15 +87,6 @@ jest.mock("actions/gitSyncActions", () => ({
fetchGlobalGitConfigInit: jest.fn(),
}));

const mockHistoryPush = jest.fn();

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
useHistory: () => ({
push: mockHistoryPush,
}),
}));

const mockStore = configureStore([]);
describe("Git config ", () => {
// TODO: Fix this the next time the file is edited
Expand Down Expand Up @@ -137,22 +128,6 @@ describe("Git config ", () => {
expect(getAllByText("Sign in to your account")).toBeInTheDocument;
});

it("should call history push when user goes back to applications", () => {
store = mockStore(defaultStoreState);
render(
<Provider store={store}>
<ThemeProvider theme={lightTheme}>
<Router>
<UserProfile />
</Router>
</ThemeProvider>
</Provider>,
);
const backButton = screen.getByText("Back");
fireEvent.click(backButton);
expect(mockHistoryPush).toHaveBeenCalledWith("/applications");
});

afterAll(() => {
jest.clearAllMocks();
store.clearActions();
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/pages/UserProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function UserProfile() {
return (
<PageWrapper displayName={"Profile"}>
<ProfileWrapper>
<BackButton goTo="/applications" />
<BackButton />
<Tabs defaultValue={selectedTab} onValueChange={setSelectedTab}>
<TabsList>
{tabs.map((tab) => {
Expand Down
30 changes: 0 additions & 30 deletions app/client/src/pages/workspace/__tests__/settings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import React from "react";
import "@testing-library/jest-dom";
import Router from "react-router-dom";
import { BrowserRouter } from "react-router-dom";
import { render, screen } from "test/testUtils";
import {
render as testRender,
screen as testScreen,
} from "@testing-library/react";
import { fireEvent } from "@testing-library/react";
import Settings from "../settings";
import * as reactRedux from "react-redux";
import configureStore from "redux-mock-store";
import { Provider } from "react-redux";

// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -159,16 +151,9 @@ const mockWorkspaceData = {
new: false,
};

const mockHistoryPush = jest.fn();

const mockStore = configureStore([]);

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
useParams: jest.fn(),
useHistory: () => ({
push: mockHistoryPush,
}),
}));

function renderComponent() {
Expand Down Expand Up @@ -205,19 +190,4 @@ describe("<Settings />", () => {
expect(tabList.length).toBeGreaterThanOrEqual(2);
expect(tabList.length).toBeLessThanOrEqual(3);
});

it("should redirect to workspace page if user wants to go back", () => {
testRender(
<BrowserRouter>
<Provider store={mockStore(mockWorkspaceData)}>
<Settings />
</Provider>
</BrowserRouter>,
);
const backBtn = testScreen.getByText("Back");
fireEvent.click(backBtn);
expect(mockHistoryPush).toHaveBeenCalledWith(
`/applications?workspaceId=${mockWorkspaceData.id}`,
);
});
});
2 changes: 1 addition & 1 deletion app/client/src/pages/workspace/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function Settings() {
<>
<SettingsWrapper data-testid="t--settings-wrapper" isMobile={isMobile}>
<StyledStickyHeader isMobile={isMobile}>
<BackButton goTo={`/applications?workspaceId=${workspaceId}`} />
<BackButton />
<SettingsPageHeader
buttonText="Add users"
onButtonClick={onButtonClick}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.appsmith.external.constants.spans.ce;

import static com.appsmith.external.constants.spans.ConsolidatedApiSpanNames.APPLICATION_ID_SPAN;
import static com.appsmith.external.constants.spans.ConsolidatedApiSpanNames.CONSOLIDATED_API_PREFIX;

public class ApplicationSpanCE {
public static final String APPLICATION_FETCH_FROM_DB = CONSOLIDATED_API_PREFIX + "app_db";
public static final String APPLICATION_ID_FETCH_REDIS_SPAN = APPLICATION_ID_SPAN + ".read_redis";
public static final String APPLICATION_ID_UPDATE_REDIS_SPAN = APPLICATION_ID_SPAN + ".update_redis";
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,9 @@ public Mono<Application> findByBaseIdBranchNameAndApplicationMode(
? applicationPermission.getReadPermission()
: applicationPermission.getEditPermission();

return findByBranchNameAndBaseApplicationId(branchName, defaultApplicationId, permissionForApplication);
return findByBranchNameAndBaseApplicationId(branchName, defaultApplicationId, permissionForApplication)
.name(APPLICATION_FETCH_FROM_DB)
.tap(Micrometer.observation(observationRegistry));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ public Flux<ActionDTO> getUnpublishedActions(
Mono<NewPage> branchedPageMono = !StringUtils.hasLength(params.getFirst(FieldName.PAGE_ID))
? Mono.just(new NewPage())
: newPageService.findByBranchNameAndBasePageId(
branchName, params.getFirst(FieldName.PAGE_ID), pagePermission.getReadPermission());
branchName, params.getFirst(FieldName.PAGE_ID), pagePermission.getReadPermission(), null);
Mono<Application> branchedApplicationMono = !StringUtils.hasLength(params.getFirst(FieldName.APPLICATION_ID))
? Mono.just(new Application())
: applicationService.findByBranchNameAndBaseApplicationId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public interface NewPageServiceCE extends CrudService<NewPage, String> {
Flux<NewPage> findNewPagesByApplicationId(
String applicationId, AclPermission permission, List<String> includeFields);

Mono<NewPage> findByIdAndBranchName(String id, String branchName);

Mono<PageDTO> saveUnpublishedPage(PageDTO page);

Mono<PageDTO> createDefault(PageDTO object);
Expand Down Expand Up @@ -71,7 +69,8 @@ Mono<PageDTO> findByNameAndApplicationIdAndViewMode(

Mono<String> getNameByPageId(String pageId, boolean isPublishedName);

Mono<NewPage> findByBranchNameAndBasePageId(String branchName, String defaultPageId, AclPermission permission);
Mono<NewPage> findByBranchNameAndBasePageId(
String branchName, String defaultPageId, AclPermission permission, List<String> projectedFieldNames);

Mono<NewPage> findByBranchNameAndBasePageIdAndApplicationMode(
String branchName, String basePageId, ApplicationMode mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ public Flux<PageDTO> findByApplicationId(String applicationId, AclPermission per
return findNewPagesByApplicationId(applicationId, permission).flatMap(page -> getPageByViewMode(page, view));
}

@Override
public Mono<NewPage> findByIdAndBranchName(String id, String branchName) {
return this.findByBranchNameAndBasePageId(branchName, id, pagePermission.getReadPermission());
}

@Override
public Mono<PageDTO> saveUnpublishedPage(PageDTO page) {

Expand Down Expand Up @@ -511,19 +506,21 @@ public Mono<String> getNameByPageId(String pageId, boolean isPublishedName) {
}

@Override
public Mono<NewPage> findByBranchNameAndBasePageId(String branchName, String basePageId, AclPermission permission) {
public Mono<NewPage> findByBranchNameAndBasePageId(
String branchName, String basePageId, AclPermission permission, List<String> projectedFieldNames) {

if (!StringUtils.hasText(basePageId)) {
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGE_ID));
} else if (!StringUtils.hasText(branchName)) {
return this.findById(basePageId, permission)
return repository
.findById(basePageId, permission, projectedFieldNames)
.name(GET_PAGE_WITHOUT_BRANCH)
.tap(Micrometer.observation(observationRegistry))
.switchIfEmpty(Mono.error(
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE, basePageId)));
}
return repository
.findPageByBranchNameAndBasePageId(branchName, basePageId, permission)
.findPageByBranchNameAndBasePageId(branchName, basePageId, permission, projectedFieldNames)
.name(GET_PAGE_WITH_BRANCH)
.tap(Micrometer.observation(observationRegistry))
.switchIfEmpty(Mono.error(new AppsmithException(
Expand All @@ -541,7 +538,8 @@ public Mono<NewPage> findByBranchNameAndBasePageIdAndApplicationMode(
permission = pagePermission.getReadPermission();
}

return this.findByBranchNameAndBasePageId(branchName, basePageId, permission)
return this.findByBranchNameAndBasePageId(
branchName, basePageId, permission, List.of(NewPage.Fields.id, NewPage.Fields.applicationId))
.name(getQualifiedSpanName(GET_PAGE, mode))
.tap(Micrometer.observation(observationRegistry));
}
Expand All @@ -556,7 +554,7 @@ public Mono<String> findBranchedPageId(String branchName, String basePageId, Acl
return Mono.just(basePageId);
}
return repository
.findPageByBranchNameAndBasePageId(branchName, basePageId, permission)
.findPageByBranchNameAndBasePageId(branchName, basePageId, permission, null)
.switchIfEmpty(Mono.error(new AppsmithException(
AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE_ID, basePageId + ", " + branchName)))
.map(NewPage::getId);
Expand Down
Loading

0 comments on commit a7ba129

Please sign in to comment.