Skip to content

Commit

Permalink
Add e2e test for context menu #901
Browse files Browse the repository at this point in the history
  • Loading branch information
ngormsen committed Jul 14, 2021
1 parent 85fd95a commit 4d120cd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getCodeMapNodeFromPath } from "../../util/codeMapHelper"
import { ThreeSceneService } from "../codeMap/threeViewer/threeSceneService"
import { DialogService } from "../dialog/dialog.service"
import { BlacklistService } from "../../state/store/fileSettings/blacklist/blacklist.service"
import { ERROR_MESSAGES } from "../../util/fileValidator"

export enum ClickType {
RightClick = 2
Expand Down Expand Up @@ -170,7 +171,7 @@ export class NodeContextMenuController
}

if (this.blacklistService.resultsInEmptyMap([blacklistItem])) {
this.dialogService.showErrorDialog("Excluding all buildings is not possible.", "Blacklist Error")
this.dialogService.showErrorDialog(ERROR_MESSAGES.blacklistError, "Blacklist Error")
} else {
this.storeService.dispatch(addBlacklistItem(blacklistItem))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@ import { NodeContextMenuPageObject } from "./nodeContextMenu.po"
import { SearchPanelModeSelectorPageObject } from "../searchPanelModeSelector/searchPanelModeSelector.po"
import { MapTreeViewLevelPageObject } from "../mapTreeView/mapTreeView.level.po"
import { CodeMapPageObject } from "../codeMap/codeMap.po"
import { ERROR_MESSAGES } from "../../util/fileValidator"
import { DialogErrorPageObject } from "../dialog/dialog.error.po"

describe("NodeContextMenu", () => {
let contextMenu: NodeContextMenuPageObject
let searchPanelModeSelector: SearchPanelModeSelectorPageObject
let mapTreeViewLevel: MapTreeViewLevelPageObject
let codeMap: CodeMapPageObject
let dialogError: DialogErrorPageObject

beforeEach(async () => {
contextMenu = new NodeContextMenuPageObject()
searchPanelModeSelector = new SearchPanelModeSelectorPageObject()
mapTreeViewLevel = new MapTreeViewLevelPageObject()
codeMap = new CodeMapPageObject()
dialogError = new DialogErrorPageObject()

await goto()
})

it("should show error message when user excludes all files", async () => {
await searchPanelModeSelector.toggleTreeView()
await mapTreeViewLevel.openContextMenu("/root")
await contextMenu.clickOnExclude()

expect(await dialogError.getMessage()).toEqual(`${ERROR_MESSAGES.blacklistError}`)
})

it("right clicking a folder should open a context menu with color options", async () => {
await searchPanelModeSelector.toggleTreeView()
await mapTreeViewLevel.openContextMenu("/root")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ export class NodeContextMenuPageObject {
async isClosed() {
await page.waitForSelector("#codemap-context-menu", { hidden: true })
}

async clickOnExclude() {
await clickButtonOnPageElement(`[id='exclude-button']`, { button: "left" })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BlacklistService, BlacklistSubscriber } from "../../state/store/fileSet
import { SearchPatternService, SearchPatternSubscriber } from "../../state/store/dynamicSettings/searchPattern/searchPattern.service"
import { DialogService } from "../dialog/dialog.service"
import { addBlacklistItem } from "../../state/store/fileSettings/blacklist/blacklist.actions"
import { ERROR_MESSAGES } from "../../util/fileValidator"

export class SearchBarController implements BlacklistSubscriber, SearchPatternSubscriber {
private static DEBOUNCE_TIME = 400
Expand Down Expand Up @@ -53,7 +54,7 @@ export class SearchBarController implements BlacklistSubscriber, SearchPatternSu
const blacklistItems: BlacklistItem[] = this.parseValidBlacklistItems(blacklistType)

if (blacklistType === BlacklistType.exclude && this.blacklistService.resultsInEmptyMap(blacklistItems)) {
this.dialogService.showErrorDialog("Excluding all buildings is not possible.", "Blacklist Error")
this.dialogService.showErrorDialog(ERROR_MESSAGES.blacklistError, "Blacklist Error")
} else {
for (const blackItem of blacklistItems) {
this.storeService.dispatch(addBlacklistItem(blackItem))
Expand Down
3 changes: 2 additions & 1 deletion visualization/app/codeCharta/util/fileValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const ERROR_MESSAGES = {
fixedFoldersOutOfBounds: "Coordinates of fixed folders must be within a range of 0 and 100.",
fixedFoldersOverlapped: "Folders may not overlap.",
fixedFoldersNotAllowed: "Fixated folders may not be defined in API-Version < 1.2.",
fileAlreadyExists: "File already exists."
fileAlreadyExists: "File already exists.",
blacklistError: "Excluding all buildings is not possible."
}

export function validate(nameDataPair: NameDataPair, storeService: StoreService) {
Expand Down

0 comments on commit 4d120cd

Please sign in to comment.