Skip to content

Commit

Permalink
fix: Deprecate Git Workspaces [INS-5070] (#8436)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavkout authored Mar 6, 2025
1 parent 114071a commit 6a6483b
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 484 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { test } from '../../playwright/test';

test.describe('design document operations', async () => {
test('can name design documents', async ({ page }) => {
await page.getByRole('button', { name: 'New Document' }).click();
await page.getByRole('button', { name: 'New Document' }).click();
await page.getByPlaceholder('my-spec.yaml').fill('jurassic park');
await page.getByPlaceholder('my-spec.yaml').press('Enter');
await page.getByTestId('project').click();
await page.getByLabel('Files').getByLabel('jurassic park').click();
});

test('can delete a test suite with confirmation modal', async ({ page }) => {
await page.getByRole('button', { name: 'New Document' }).click();
await page.getByRole('button', { name: 'New Document' }).click();
await page.getByPlaceholder('my-spec.yaml').fill('jurassic park');
await page.getByPlaceholder('my-spec.yaml').press('Enter');
await page.getByTestId('workspace-test').click();
Expand Down
203 changes: 102 additions & 101 deletions packages/insomnia-smoke-test/tests/smoke/git-interactions.test.ts
Original file line number Diff line number Diff line change
@@ -1,116 +1,117 @@
import { test } from '../../playwright/test';
// TODO: Switch this to git project
// import { test } from '../../playwright/test';

test('Git Interactions (clone, checkout branch, pull, push, stage changes, ...)', async ({ page }) => {
const gitSyncSmokeTestToken = process.env.GIT_SYNC_SMOKE_TEST_TOKEN;
test.setTimeout(600000);
// test('Git Interactions (clone, checkout branch, pull, push, stage changes, ...)', async ({ page }) => {
// const gitSyncSmokeTestToken = process.env.GIT_SYNC_SMOKE_TEST_TOKEN;
// test.setTimeout(600000);

// read env variable to skip test
if (!gitSyncSmokeTestToken) {
console.log('Skipping, set GIT_SYNC_SMOKE_TEST_TOKEN to run, TIP: "gh auth login to get a token" and "export GIT_SYNC_SMOKE_TEST_TOKEN=$(gh auth token)"');
test.skip();
return;
}
// // read env variable to skip test
// if (!gitSyncSmokeTestToken) {
// console.log('Skipping, set GIT_SYNC_SMOKE_TEST_TOKEN to run, TIP: "gh auth login to get a token" and "export GIT_SYNC_SMOKE_TEST_TOKEN=$(gh auth token)"');
// test.skip();
// return;
// }

// generate a uuid string
const testUUID = crypto.randomUUID();
// // generate a uuid string
// const testUUID = crypto.randomUUID();

// git clone
await page.waitForSelector('[data-test-git-enable="true"]');
await page.getByLabel('Clone git repository').click();
await page.getByRole('tab', { name: ' Git' }).click();
await page.getByPlaceholder('https://github.com/org/repo.git').fill('https://github.com/Kong/insomnia-git-example.git');
await page.getByPlaceholder('Name').fill('Test User');
await page.getByPlaceholder('Email').fill('[email protected]');
await page.getByPlaceholder('MyUser').fill('test');
await page.getByPlaceholder('88e7ee63b254e4b0bf047559eafe86ba9dd49507').fill(gitSyncSmokeTestToken);
await page.getByTestId('git-repository-settings-modal__sync-btn').click();
await page.getByLabel('Toggle preview').click();
// // git clone
// await page.waitForSelector('[data-test-git-enable="true"]');
// await page.getByLabel('Clone git repository').click();
// await page.getByRole('tab', { name: ' Git' }).click();
// await page.getByPlaceholder('https://github.com/org/repo.git').fill('https://github.com/Kong/insomnia-git-example.git');
// await page.getByPlaceholder('Name').fill('Test User');
// await page.getByPlaceholder('Email').fill('[email protected]');
// await page.getByPlaceholder('MyUser').fill('test');
// await page.getByPlaceholder('88e7ee63b254e4b0bf047559eafe86ba9dd49507').fill(gitSyncSmokeTestToken);
// await page.getByTestId('git-repository-settings-modal__sync-btn').click();
// await page.getByLabel('Toggle preview').click();

// switch branches
await page.getByTestId('git-dropdown').click();
await page.getByText('Branches').click();
await page.getByLabel('main').getByText('main').click();
await page.getByText('abc').click();
await page.getByLabel('abc').getByRole('button', { name: 'Fetch' }).click();
await page.getByText('abc *').click();
await page.getByRole('heading', { name: 'Branches', exact: true }).press('Escape');
// // switch branches
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Branches').click();
// await page.getByLabel('main').getByText('main').click();
// await page.getByText('abc').click();
// await page.getByLabel('abc').getByRole('button', { name: 'Fetch' }).click();
// await page.getByText('abc *').click();
// await page.getByRole('heading', { name: 'Branches', exact: true }).press('Escape');

// perform some changes and commit them
await page.locator('pre').filter({ hasText: 'title: Endpoint Security' }).click();
await page.getByRole('textbox').fill(' test');
// make sure the changes are stored
await page.waitForTimeout(1000);
await page.getByTestId('git-dropdown').click();
await page.getByText('Commit').click();
await page.getByRole('row', { name: 'spec.yaml' }).click();
await page.locator('button[name="Stage all changes"]').click();
await page.getByPlaceholder('This is a helpful message').click();
await page.getByPlaceholder('This is a helpful message').fill('example commit message');
await page.getByRole('button', { name: 'Commit', exact: true }).click();
// // perform some changes and commit them
// await page.locator('pre').filter({ hasText: 'title: Endpoint Security' }).click();
// await page.getByRole('textbox').fill(' test');
// // make sure the changes are stored
// await page.waitForTimeout(1000);
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Commit').click();
// await page.getByRole('row', { name: 'spec.yaml' }).click();
// await page.locator('button[name="Stage all changes"]').click();
// await page.getByPlaceholder('This is a helpful message').click();
// await page.getByPlaceholder('This is a helpful message').fill('example commit message');
// await page.getByRole('button', { name: 'Commit', exact: true }).click();

// switch back to main branch, which should not have said changes
await page.getByTestId('git-dropdown').click();
await page.getByText('main').click();
await page.getByTestId('git-dropdown').click();
await page.getByText('Branches').click();
await page.getByText('main *').click();
await page.getByText('main *').press('Escape');
await page.getByTestId('CodeEditor').getByText('Endpoint Security').click();
// // switch back to main branch, which should not have said changes
// await page.getByTestId('git-dropdown').click();
// await page.getByText('main').click();
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Branches').click();
// await page.getByText('main *').click();
// await page.getByText('main *').press('Escape');
// await page.getByTestId('CodeEditor').getByText('Endpoint Security').click();

// switch to the branch with the changes and check if they are there
await page.getByTestId('git-dropdown').click();
await page.getByText('abc').click();
await page.getByTestId('git-dropdown').click();
await page.getByText('Branches').click();
await page.getByText('abc *').click();
await page.getByRole('heading', { name: 'Branches', exact: true }).press('Escape');
await page.getByLabel('Toggle preview').click();
// TODO: the following action is flaky and seems pointless, added above operation to make it work
await page.getByText('Endpoint Security test').click();
// await page.getByTestId('git-dropdown').click();
// await page.getByText('abc').click();
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Branches').click();
// await page.getByText('abc *').click();
// await page.getByRole('heading', { name: 'Branches', exact: true }).press('Escape');
// await page.getByLabel('Toggle preview').click();
// // TODO: the following action is flaky and seems pointless, added above operation to make it work
// await page.getByText('Endpoint Security test').click();

// check git history
await page.getByTestId('git-dropdown').click();
await page.getByText('Fetch').click();
// // check git history
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Fetch').click();

await page.getByTestId('git-dropdown').click();
await page.getByText('History').click();
await page.getByRole('rowheader', { name: 'example commit message' }).click();
await page.getByRole('gridcell', { name: 'just now' }).click();
await page.getByRole('heading', { name: 'History', exact: true }).click();
await page.getByRole('heading', { name: 'History', exact: true }).press('Escape');
// await page.getByTestId('git-dropdown').click();
// await page.getByText('History').click();
// await page.getByRole('rowheader', { name: 'example commit message' }).click();
// await page.getByRole('gridcell', { name: 'just now' }).click();
// await page.getByRole('heading', { name: 'History', exact: true }).click();
// await page.getByRole('heading', { name: 'History', exact: true }).press('Escape');

// push changes test
await page.getByTestId('git-dropdown').click();
await page.getByText('Branches').click();
await page.getByLabel('push-pull-test').getByRole('button', { name: 'Fetch' }).click();
await page.getByText('push-pull-test *').click();
await page.getByText('push-pull-test *').press('Escape');
await page.getByTestId('workspace-debug').click();
await page.getByLabel('Create in collection').click();
await page.getByLabel('New Folder').click();
await page.getByLabel('Name', { exact: true }).click();
await page.getByLabel('Name', { exact: true }).fill(`My Folder ${testUUID}`);
await page.getByRole('button', { name: 'Create', exact: true }).click();
await page.getByTestId('git-dropdown').click();
// // push changes test
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Branches').click();
// await page.getByLabel('push-pull-test').getByRole('button', { name: 'Fetch' }).click();
// await page.getByText('push-pull-test *').click();
// await page.getByText('push-pull-test *').press('Escape');
// await page.getByTestId('workspace-debug').click();
// await page.getByLabel('Create in collection').click();
// await page.getByLabel('New Folder').click();
// await page.getByLabel('Name', { exact: true }).click();
// await page.getByLabel('Name', { exact: true }).fill(`My Folder ${testUUID}`);
// await page.getByRole('button', { name: 'Create', exact: true }).click();
// await page.getByTestId('git-dropdown').click();

// Commit changes
await page.getByText('Commit').click();
await page.getByRole('row', { name: `My Folder ${testUUID}`, exact: true }).click();
await page.locator('button[name="Stage all changes"]').click();
await page.getByPlaceholder('This is a helpful message').click();
await page.getByPlaceholder('This is a helpful message').fill(`commit test ${testUUID}`);
await page.getByRole('button', { name: 'Commit', exact: true }).click();
// // Commit changes
// await page.getByText('Commit').click();
// await page.getByRole('row', { name: `My Folder ${testUUID}`, exact: true }).click();
// await page.locator('button[name="Stage all changes"]').click();
// await page.getByPlaceholder('This is a helpful message').click();
// await page.getByPlaceholder('This is a helpful message').fill(`commit test ${testUUID}`);
// await page.getByRole('button', { name: 'Commit', exact: true }).click();

// Push changes
await page.getByTestId('git-dropdown').click();
await page.getByText('Push', { exact: true }).click();
await page.getByTestId('git-dropdown').click();
// // Push changes
// await page.getByTestId('git-dropdown').click();
// await page.getByText('Push', { exact: true }).click();
// await page.getByTestId('git-dropdown').click();

// Check if the changes are pushed
await page.getByText('Fetch').click();
await page.getByTestId('git-dropdown').click();
await page.getByText('History').click();
await page.getByRole('rowheader', { name: `commit test ${testUUID}` }).click();
await page.getByRole('heading', { name: 'History', exact: true }).click();
await page.getByRole('heading', { name: 'History', exact: true }).press('Escape');
});
// // Check if the changes are pushed
// await page.getByText('Fetch').click();
// await page.getByTestId('git-dropdown').click();
// await page.getByText('History').click();
// await page.getByRole('rowheader', { name: `commit test ${testUUID}` }).click();
// await page.getByRole('heading', { name: 'History', exact: true }).click();
// await page.getByRole('heading', { name: 'History', exact: true }).press('Escape');
// });
38 changes: 0 additions & 38 deletions packages/insomnia-smoke-test/tests/smoke/git-sync.test.ts

This file was deleted.

18 changes: 0 additions & 18 deletions packages/insomnia-smoke-test/tests/smoke/oauth-gitlab.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import { SyncMergeModal } from '../modals/sync-merge-modal';
interface Props {
gitRepository: GitRepository | null;
isInsomniaSyncEnabled: boolean;
showDeprecatedWarning: boolean;
}

export const GitSyncDropdown: FC<Props> = ({ gitRepository, isInsomniaSyncEnabled }) => {
export const GitSyncDropdown: FC<Props> = ({ gitRepository, isInsomniaSyncEnabled, showDeprecatedWarning }) => {
const { organizationId, projectId, workspaceId } = useParams() as {
organizationId: string;
projectId: string;
Expand Down Expand Up @@ -353,6 +354,14 @@ export const GitSyncDropdown: FC<Props> = ({ gitRepository, isInsomniaSyncEnable

return (
<>
{showDeprecatedWarning && <div className='p-[--padding-sm]'>
<div className='flex flex-wrap justify-between items-center gap-2 p-[--padding-xs] border border-solid border-[--hl-md] bg-opacity-50 bg-[rgba(var(--color-warning-rgb),var(--tw-bg-opacity))] text-[--color-font-warning] rounded'>
<p className='text-sm'>
<Icon icon="exclamation-triangle" className='mr-2' />
You are using the legacy Git integration in this project, learn more about converting to the new Git Sync capability. <Button className="underline" onPress={() => window.main.openInBrowser('https://docs.insomnia.rest/insomnia/git-sync')}>Migration Guide</Button>
</p>
</div>
</div>}
<MenuTrigger>
<div className="flex items-center h-[--line-height-sm] w-full aria-pressed:bg-[--hl-sm] text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-sm">
<Button
Expand Down
Loading

0 comments on commit 6a6483b

Please sign in to comment.