-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dima/local-integration-tests
- Loading branch information
Showing
39 changed files
with
1,387 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
let SDK; | ||
|
||
module.exports = { | ||
getSDK() { | ||
return SDK; | ||
}, | ||
setSDK(pluginSDK) { | ||
SDK = pluginSDK; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
const mockDataLayer = jest.fn(); | ||
jest.mock("@dcos/data-service", () => ({ | ||
graphqlObservable: mockDataLayer | ||
})); | ||
|
||
import { marbles } from "rxjs-marbles/jest"; | ||
import { | ||
queryCosmosForUIVersions, | ||
queryUIServiceForMetadata | ||
} from "#PLUGINS/ui-update/queries"; | ||
import { take } from "rxjs/operators"; | ||
import { of } from "rxjs"; | ||
import { DEFAULT_UI_METADATA } from "#SRC/js/data/ui-update/UIMetadata"; | ||
|
||
describe("queries", () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
describe("#queryCosmosForUIVersions", () => { | ||
it( | ||
"returns package result from query", | ||
marbles(m => { | ||
const queryResp$ = m.cold("--j|", { | ||
j: { | ||
data: { | ||
package: { | ||
name: "dcos-ui", | ||
versions: [ | ||
{ | ||
version: "2.0.0", | ||
revision: "1" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}); | ||
mockDataLayer.mockReturnValueOnce(queryResp$); | ||
|
||
const query$ = queryCosmosForUIVersions(); | ||
const result$ = query$.pipe(take(1)); | ||
m.expect(result$).toBeObservable( | ||
m.cold("--(j|)", { | ||
j: { | ||
name: "dcos-ui", | ||
versions: [ | ||
{ | ||
version: "2.0.0", | ||
revision: "1" | ||
} | ||
] | ||
} | ||
}) | ||
); | ||
}) | ||
); | ||
|
||
it("makes a single query to data-layer", () => { | ||
mockDataLayer.mockReturnValueOnce(of({})); | ||
|
||
queryCosmosForUIVersions(); | ||
expect(mockDataLayer).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
describe("#queryUIServiceForMetadata", () => { | ||
it( | ||
"returns result from ui-update-service", | ||
marbles(m => { | ||
const queryResp$ = m.cold("--j|", { | ||
j: { | ||
data: { | ||
ui: { | ||
clientBuild: "unit_test+v2.50.1", | ||
packageVersion: "2.50.1", | ||
packageVersionIsDefault: false, | ||
serverBuild: "master+v2.50.1+hfges" | ||
} | ||
} | ||
} | ||
}); | ||
mockDataLayer.mockReturnValueOnce(queryResp$); | ||
|
||
const query$ = queryUIServiceForMetadata(); | ||
const result$ = query$.pipe(take(1)); | ||
m.expect(result$).toBeObservable( | ||
m.cold("--(j|)", { | ||
j: { | ||
clientBuild: "unit_test+v2.50.1", | ||
packageVersion: "2.50.1", | ||
packageVersionIsDefault: false, | ||
serverBuild: "master+v2.50.1+hfges" | ||
} | ||
}) | ||
); | ||
}) | ||
); | ||
|
||
it( | ||
"makes a single query to data-layer", | ||
marbles(m => { | ||
const queryResp$ = m.cold("--j|", { | ||
j: { | ||
data: { | ||
ui: { | ||
clientBuild: "unit_test+v2.50.1", | ||
packageVersion: "2.50.1", | ||
packageVersionIsDefault: false, | ||
serverBuild: "master+v2.50.1+hfges" | ||
} | ||
} | ||
} | ||
}); | ||
mockDataLayer.mockReturnValueOnce(queryResp$); | ||
|
||
queryUIServiceForMetadata(); | ||
expect(mockDataLayer).toHaveBeenCalledTimes(1); | ||
}) | ||
); | ||
|
||
it( | ||
"returns default ui metadata if query errors", | ||
marbles(m => { | ||
const queryResp$ = m.cold("--#", undefined, { | ||
message: "Query Failed", | ||
name: "Error" | ||
}); | ||
mockDataLayer.mockReturnValueOnce(queryResp$); | ||
|
||
const query$ = queryUIServiceForMetadata(); | ||
const result$ = query$.pipe(take(1)); | ||
m.expect(result$).toBeObservable( | ||
m.cold("--(j|)", { | ||
j: DEFAULT_UI_METADATA | ||
}) | ||
); | ||
}) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { graphqlObservable } from "@dcos/data-service"; | ||
import gql from "graphql-tag"; | ||
import { default as uiServiceSchema } from "#SRC/js/data/ui-update"; | ||
import { delay } from "rxjs/operators"; | ||
|
||
function rollbackUI(delayMs: number = 45000) { | ||
return graphqlObservable<{ resetDCOSUI: string | null }>( | ||
gql` | ||
mutation { | ||
resetDCOSUI | ||
} | ||
`, | ||
uiServiceSchema, | ||
{} | ||
).pipe(delay(delayMs)); | ||
} | ||
|
||
function updateUI(version: string, delayMs: number = 45000) { | ||
return graphqlObservable<{ updateDCOSUI: string }>( | ||
gql` | ||
mutation { | ||
updateDCOSUI(newVersion: $version) | ||
} | ||
`, | ||
uiServiceSchema, | ||
{ | ||
version | ||
} | ||
).pipe(delay(delayMs)); | ||
} | ||
|
||
export { rollbackUI, updateUI }; |
Oops, something went wrong.