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

Fix/2762/Set loaded files via url to multiple mode by default #2769

Merged
merged 6 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

## [unreleased] (Added 🚀 | Changed | Removed 🗑 | Fixed 🐞 | Chore 👨‍💻 👩‍💻)

### Fixed 🐞

- Set files loaded via URL to multiple mode by default when delta mode is not selected [#2769](https://github.com/MaibornWolff/codecharta/pull/2769)

## [1.95.1] - 2022-04-01

### Changed
Expand Down
30 changes: 29 additions & 1 deletion visualization/app/codeCharta/codeCharta.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { setAppSettings } from "./state/store/appSettings/appSettings.actions"
import { ThreeCameraService } from "./ui/codeMap/threeViewer/threeCameraService"
import sample1 from "./assets/sample1.cc.json"
import sample2 from "./assets/sample2.cc.json"
import { LayoutAlgorithm } from "./codeCharta.model"
import { CCFile, LayoutAlgorithm } from "./codeCharta.model"
import { GlobalSettingsHelper } from "./util/globalSettingsHelper"
import { GLOBAL_SETTINGS } from "./util/dataMocks"
import { setIsWhiteBackground } from "./state/store/appSettings/isWhiteBackground/isWhiteBackground.actions"
Expand All @@ -20,6 +20,8 @@ import { setHideFlatBuildings } from "./state/store/appSettings/hideFlatBuilding
import { setExperimentalFeaturesEnabled } from "./state/store/appSettings/enableExperimentalFeatures/experimentalFeaturesEnabled.actions"
import { setLayoutAlgorithm } from "./state/store/appSettings/layoutAlgorithm/layoutAlgorithm.actions"
import { setMaxTreeMapFiles } from "./state/store/appSettings/maxTreeMapFiles/maxTreeMapFiles.actions"
import { FileSelectionState, FileState } from "./model/files/files"
import { setFiles } from "./state/store/files/files.actions"

describe("codeChartaController", () => {
let codeChartaController: CodeChartaController
Expand Down Expand Up @@ -233,7 +235,33 @@ describe("codeChartaController", () => {

expect(storeService.dispatch).not.toHaveBeenCalled()
})

it("should set files to multiple mode when no 'mode' parameter is given", () => {
const fileState: FileState[] = [{ file: {} as CCFile, selectedAs: FileSelectionState.None }]
storeService.dispatch(setFiles(fileState))
storeService.dispatch = jest.fn()
codeChartaController["urlUtils"].getParameterByName = jest.fn().mockReturnValue(null)

codeChartaController["setRenderStateFromUrl"]()

expect(storeService.dispatch).toHaveBeenCalledWith({ payload: [{}], type: "SET_MULTIPLE" })
})

it("should set files to delta mode when 'mode=delta' parameter is given", () => {
const fileState: FileState[] = [
{ file: {} as CCFile, selectedAs: FileSelectionState.None },
{ file: {} as CCFile, selectedAs: FileSelectionState.None }
]
storeService.dispatch(setFiles(fileState))
storeService.dispatch = jest.fn()
codeChartaController["urlUtils"].getParameterByName = jest.fn().mockReturnValue("Delta")

codeChartaController["setRenderStateFromUrl"]()

expect(storeService.dispatch).toHaveBeenCalledWith({ payload: { comparisonFile: {}, referenceFile: {} }, type: "SET_DELTA" })
})
})

describe("version check", () => {
beforeEach(() => {
restartSystem()
Expand Down
6 changes: 2 additions & 4 deletions visualization/app/codeCharta/codeCharta.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StoreService } from "./state/store.service"
import { setAppSettings } from "./state/store/appSettings/appSettings.actions"
import { setIsLoadingFile } from "./state/store/appSettings/isLoadingFile/isLoadingFile.actions"
import packageJson from "../../package.json"
import { setDelta, setMultiple, setSingle } from "./state/store/files/files.actions"
import { setDelta, setMultiple } from "./state/store/files/files.actions"
import { getCCFiles } from "./model/files/files.helper"
import sample1 from "./assets/sample1.cc.json"
import sample2 from "./assets/sample2.cc.json"
Expand Down Expand Up @@ -84,10 +84,8 @@ export class CodeChartaController {

if (renderState === "Delta" && files.length >= 2) {
this.storeService.dispatch(setDelta(files[0], files[1]))
} else if (renderState === "Multiple") {
this.storeService.dispatch(setMultiple(files))
} else {
this.storeService.dispatch(setSingle(files[0]))
this.storeService.dispatch(setMultiple(files))
}
}

Expand Down
1 change: 0 additions & 1 deletion visualization/app/codeCharta/e2e/url.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe("codecharta", () => {
it("should load data when file parameters in url are valid", async () => {
await mockResponses()
await goto(`${CC_URL}?file=fileOne.json&file=fileTwo.json`)
await checkSelectedFileName("Sample Project with Edges")
Hall-Ma marked this conversation as resolved.
Show resolved Hide resolved
await checkAllFileNames(["Sample Project with Edges", "Sample Project"])
})

Expand Down
5 changes: 5 additions & 0 deletions visualization/app/codeCharta/util/urlExtractor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ describe("urlExtractor", () => {
expect(result).toBe("valid.json")
})

it("should return null when parameter for renderMode is not given", () => {
const result = urlExtractor.getParameterByName("mode")
expect(result).toBe(null)
})

it("should return renderMode for given parameter name 'mode'", () => {
$location.absUrl = jest.fn(() => {
return "http://testurl?file=valid.json&mode=Delta"
Expand Down