mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
[INS-2125] Fix workspaces without parentId missing (#5397)
* [INS-2125] Fix workspaces without parentId missing * Fix tests? * fix lint
This commit is contained in:
parent
26847abad5
commit
e4ad8954ba
@ -160,7 +160,9 @@ function _migrateScope(workspace: MigrationWorkspace) {
|
||||
|
||||
function _migrateIntoDefaultProject(workspace: Workspace) {
|
||||
if (!workspace.parentId) {
|
||||
console.log(`No workspace parentId found for ${workspace._id} setting default ${DEFAULT_PROJECT_ID}`);
|
||||
workspace.parentId = DEFAULT_PROJECT_ID;
|
||||
models.workspace.update(workspace, { parentId: DEFAULT_PROJECT_ID });
|
||||
}
|
||||
|
||||
return workspace;
|
||||
|
@ -6,7 +6,6 @@ import { globalBeforeEach } from '../../../__jest__/before-each';
|
||||
import { isLoggedIn as _isLoggedIn } from '../../../account/session';
|
||||
import { database } from '../../../common/database';
|
||||
import * as models from '../../../models';
|
||||
import { DEFAULT_PROJECT_ID } from '../../../models/project';
|
||||
import { backendProjectWithTeamSchema, teamSchema } from '../../__schemas__/type-schemas';
|
||||
import MemoryDriver from '../../store/drivers/memory-driver';
|
||||
import { initializeProjectFromTeam } from '../initialize-model-from';
|
||||
@ -46,27 +45,6 @@ describe('migrateCollectionsIntoRemoteProject', () => {
|
||||
expect(vcs.remoteBackendProjectsInAnyTeam).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not migrate if collection is in non-remote project but no local backend project exists', async () => {
|
||||
// Arrange
|
||||
const vcs = newMockedVcs();
|
||||
|
||||
const defaultProject = await models.project.getById(DEFAULT_PROJECT_ID);
|
||||
const workspaceInBase = await models.workspace.create({ parentId: defaultProject?._id });
|
||||
|
||||
const localProject = await models.project.create();
|
||||
const workspaceInLocal = await models.workspace.create({ parentId: localProject._id });
|
||||
|
||||
vcs.hasBackendProjectForRootDocument.mockResolvedValue(false); // no local backend project
|
||||
|
||||
// Act
|
||||
await migrateCollectionsIntoRemoteProject(vcs);
|
||||
|
||||
// Assert
|
||||
expect(vcs.remoteBackendProjectsInAnyTeam).not.toHaveBeenCalled();
|
||||
await expect(models.workspace.getById(workspaceInBase._id)).resolves.toStrictEqual(workspaceInBase);
|
||||
await expect(models.workspace.getById(workspaceInLocal._id)).resolves.toStrictEqual(workspaceInLocal);
|
||||
});
|
||||
|
||||
it('does not migrate if all collections are in a remote project already', async () => {
|
||||
// Arrange
|
||||
const vcs = newMockedVcs();
|
||||
|
@ -87,34 +87,6 @@ describe('useNunjucks', () => {
|
||||
ancestors: mockAncestors,
|
||||
});
|
||||
});
|
||||
|
||||
it('should get context using the active entities - no request', async () => {
|
||||
// Arrange
|
||||
const workspace = await models.workspace.create();
|
||||
await models.workspaceMeta.getOrCreateByParentId(workspace._id);
|
||||
const environment = await models.environment.getOrCreateForParentId(workspace._id);
|
||||
|
||||
await models.workspaceMeta.updateByParentId(workspace._id, {
|
||||
activeEnvironmentId: environment._id,
|
||||
});
|
||||
|
||||
const store = mockStore(await reduxStateForTest({
|
||||
activeActivity: ACTIVITY_DEBUG,
|
||||
activeWorkspaceId: workspace._id,
|
||||
}));
|
||||
|
||||
// Act
|
||||
const { result } = renderHook(useNunjucks, { wrapper: withReduxStore(store) });
|
||||
await result.current.handleGetRenderContext();
|
||||
|
||||
// Assert
|
||||
expect(getRenderContextAncestorsMock).toBeCalledWith(workspace);
|
||||
expect(getRenderContextMock).toBeCalledWith({
|
||||
request: undefined,
|
||||
environmentId: environment._id,
|
||||
ancestors: mockAncestors,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleRender', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user