Skip to content

Commit 6fb2c04

Browse files
committed
feat: enhance Git project folder handling and improve test descriptions
1 parent 9cbc310 commit 6fb2c04

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

packages/insomnia-smoke-test/playwright/pages/project/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ export class ProjectPage extends BasePage {
164164
await this.page.getByRole('button', { name: 'Open existing folder' }).click();
165165
await this.page.getByRole('button', { name: 'Choose folder' }).click();
166166
await this.page.getByRole('button', { name: 'Open', exact: true }).click();
167+
// Confirm the "Do you trust this folder?" dialog before the folder is opened/initialized.
168+
await this.page.getByRole('button', { name: 'Open folder' }).click();
167169
}
168170

169171
/**
@@ -178,10 +180,12 @@ export class ProjectPage extends BasePage {
178180
await this.page.getByRole('textbox', { name: 'Project name' }).press('ControlOrMeta+a');
179181
await this.page.getByRole('textbox', { name: 'Project name' }).fill(name);
180182
await this.page.getByText('Git Sync').click();
181-
await this.page.getByRole('button', { name: 'Access Token author Git' }).click();
183+
await this.page.getByRole('button', { name: 'Git Credentials Authorized as' }).click();
182184
await this.page.getByRole('option', { name: 'Custom Git Credential' }).click();
183185
await this.page.getByRole('textbox', { name: 'Repository URL' }).click();
184-
await this.page.getByRole('textbox', { name: 'Repository URL' }).fill('git-server.git');
186+
// Use the reachable git test server URL so remote branches can be listed.
187+
// deriveRepoName() still yields "git-server" from this URL.
188+
await this.page.getByRole('textbox', { name: 'Repository URL' }).fill('http://localhost:4010/git/git-server.git');
185189
await this.page.getByRole('button', { name: 'Show suggestions Branch' }).click();
186190
await this.page.getByRole('option', { name: 'master' }).click();
187191
// Pick the custom clone destination before scanning.

packages/insomnia-smoke-test/tests/smoke/git-local-repos.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test.describe('Git repositories in user-chosen folders', () => {
2424

2525
await insomnia.projectPage.openGitProjectFromFolder('Opened Folder Project', folder);
2626

27-
// `git init` must have run inside the chosen folder (decision OQ2).
27+
// `git init` must have run inside the chosen folder.
2828
await expect.poll(() => fs.existsSync(path.join(folder, '.git')), { timeout: 30_000 }).toBe(true);
2929

3030
// The project landed — no error banner.
@@ -43,7 +43,7 @@ test.describe('Git repositories in user-chosen folders', () => {
4343
// Back to the project dashboard, then try to adopt the same folder again.
4444
await insomnia.projectPage.openGitProjectFromFolder('Second Adoption', folder);
4545

46-
// The hard-block surfaces an error mentioning the already-connected folder (OQ5).
46+
// The hard-block surfaces an error mentioning the already-connected folder.
4747
await expect.soft(page.getByText(/already connected to this folder/i)).toBeVisible();
4848
} finally {
4949
fs.rmSync(folder, { recursive: true, force: true });

packages/insomnia/src/main/git-service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ export async function loadGitRepository({ projectId, workspaceId }: { projectId:
577577
// its drive unmounted) BEFORE creating the FS client — `fsClient` auto-creates
578578
// its base dir, which would silently resurrect a deleted folder as empty and
579579
// let the watcher wipe the database. We surface an "unavailable" state and let
580-
// the user re-locate or remove the project; we never auto-remove it (OQ6/D4).
580+
// the user re-locate or remove the project; we never auto-remove it.
581581
if (gitRepository.directory) {
582582
let isAvailable = false;
583583
try {
@@ -1195,7 +1195,7 @@ export const cloneGitRepoAction = async ({
11951195
}
11961196

11971197
// When a user-chosen clone location is provided, validate it and guard
1198-
// against two projects targeting the same folder (decision OQ5 — hard block).
1198+
// against two projects targeting the same folder.
11991199
if (directory) {
12001200
if (!path.isAbsolute(directory)) {
12011201
return { errors: ['Clone location must be an absolute path.'] };
@@ -1592,10 +1592,10 @@ export const cloneGitRepoAction = async ({
15921592
*
15931593
* Unlike {@link cloneGitRepoAction} this performs no network clone — it points
15941594
* Insomnia at a folder already on disk:
1595-
* - If the folder is not yet a git repo, `GitVCS.init` runs `git init` (OQ2).
1595+
* - If the folder is not yet a git repo, `GitVCS.init` runs `git init`.
15961596
* - Existing Insomnia YAML is imported by the watcher; a repo with no Insomnia
1597-
* data simply yields an empty project ready to populate (OQ1).
1598-
* - Two projects may not target the same folder (OQ5 — hard block).
1597+
* data simply yields an empty project ready to populate.
1598+
* - Two projects may not target the same folder.
15991599
*/
16001600
export const openGitRepoAction = async ({
16011601
organizationId,
@@ -1632,7 +1632,7 @@ export const openGitRepoAction = async ({
16321632
};
16331633
}
16341634

1635-
// Hard-block if another project already owns this folder (OQ5).
1635+
// Hard-block if another project already owns this folder.
16361636
const existing = await services.gitRepository.getByDirectory(resolvedDirectory);
16371637
if (existing) {
16381638
return { errors: [`A project is already connected to this folder: ${resolvedDirectory}`] };
@@ -1770,7 +1770,7 @@ export const relocateGitRepoAction = async ({
17701770
return { errors: ['The repository is already in that folder.'] };
17711771
}
17721772

1773-
// Hard-block if another project already owns the target (OQ5).
1773+
// Hard-block if another project already owns the target.
17741774
const existing = await services.gitRepository.getByDirectory(targetDir);
17751775
if (existing && existing._id !== repo._id) {
17761776
return { errors: [`A project is already connected to this folder: ${targetDir}`] };

0 commit comments

Comments
 (0)