|
@@ -4,7 +4,31 @@ import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
|
|
|
import ProjectsStore from 'sentry/stores/projectsStore';
|
|
|
import {ProjectInstallPlatform} from 'sentry/views/projectInstall/platform';
|
|
|
|
|
|
+function mockProjectApiResponses(projects) {
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ method: 'GET',
|
|
|
+ url: '/organizations/org-slug/projects/',
|
|
|
+ body: projects,
|
|
|
+ });
|
|
|
+
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ method: 'GET',
|
|
|
+ url: '/projects/org-slug/project-slug/rules/',
|
|
|
+ body: [],
|
|
|
+ });
|
|
|
+
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ method: 'GET',
|
|
|
+ url: '/projects/org-slug/project-slug/',
|
|
|
+ body: projects,
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
describe('ProjectInstallPlatform', function () {
|
|
|
+ beforeEach(function () {
|
|
|
+ MockApiClient.clearMockResponses();
|
|
|
+ });
|
|
|
+
|
|
|
it('should render NotFound if no matching integration/platform', async function () {
|
|
|
const routeParams = {
|
|
|
projectId: TestStubs.Project().slug,
|
|
@@ -18,23 +42,7 @@ describe('ProjectInstallPlatform', function () {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- method: 'GET',
|
|
|
- url: '/organizations/org-slug/projects/',
|
|
|
- body: [{...project, platform: 'lua'}],
|
|
|
- });
|
|
|
-
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- method: 'GET',
|
|
|
- url: '/projects/org-slug/project-slug/rules/',
|
|
|
- body: [],
|
|
|
- });
|
|
|
-
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- method: 'GET',
|
|
|
- url: '/projects/org-slug/project-slug/',
|
|
|
- body: [{...project, platform: 'lua'}],
|
|
|
- });
|
|
|
+ mockProjectApiResponses([{...project, platform: 'lua'}]);
|
|
|
|
|
|
render(
|
|
|
<ProjectInstallPlatform
|
|
@@ -71,23 +79,7 @@ describe('ProjectInstallPlatform', function () {
|
|
|
// this is needed because we don't handle a loading state in the UI
|
|
|
ProjectsStore.loadInitialData([{...project, platform: 'other'}]);
|
|
|
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- method: 'GET',
|
|
|
- url: '/organizations/org-slug/projects/',
|
|
|
- body: [{...project, platform: 'other'}],
|
|
|
- });
|
|
|
-
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- method: 'GET',
|
|
|
- url: '/projects/org-slug/project-slug/rules/',
|
|
|
- body: [],
|
|
|
- });
|
|
|
-
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- method: 'GET',
|
|
|
- url: '/projects/org-slug/project-slug/',
|
|
|
- body: [{...project, platform: 'other'}],
|
|
|
- });
|
|
|
+ mockProjectApiResponses([{...project, platform: 'other'}]);
|
|
|
|
|
|
render(
|
|
|
<ProjectInstallPlatform
|
|
@@ -108,4 +100,46 @@ describe('ProjectInstallPlatform', function () {
|
|
|
expect(router.push).toHaveBeenCalledTimes(1);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ it('should render getting started docs for correct platform', async function () {
|
|
|
+ const project = TestStubs.Project({platform: 'javascript'});
|
|
|
+
|
|
|
+ const routeParams = {
|
|
|
+ projectId: project.slug,
|
|
|
+ platform: 'python',
|
|
|
+ };
|
|
|
+
|
|
|
+ const {router, route, routerContext} = initializeOrg({
|
|
|
+ router: {
|
|
|
+ location: {
|
|
|
+ query: {},
|
|
|
+ },
|
|
|
+ params: routeParams,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ ProjectsStore.loadInitialData([project]);
|
|
|
+
|
|
|
+ mockProjectApiResponses([project]);
|
|
|
+
|
|
|
+ render(
|
|
|
+ <ProjectInstallPlatform
|
|
|
+ router={router}
|
|
|
+ route={route}
|
|
|
+ location={router.location}
|
|
|
+ routeParams={routeParams}
|
|
|
+ routes={router.routes}
|
|
|
+ params={routeParams}
|
|
|
+ />,
|
|
|
+ {
|
|
|
+ context: routerContext,
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(
|
|
|
+ await screen.findByRole('heading', {
|
|
|
+ name: 'Configure JavaScript SDK',
|
|
|
+ })
|
|
|
+ ).toBeInTheDocument();
|
|
|
+ });
|
|
|
});
|