chore(lint): forbid declaring tests inside for loops (#14921)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
a8927712f8
commit
fd7ee2c30a
86 files changed
+6142
-6059
No files matched your search
@@ -2287,7 +2287,7 @@ it.effect("routes Azure reads and writes through the requested organization's ch
|
||||
}),
|
||||
);
|
||||
|
||||
for (const checkout of [
|
||||
it.effect.each([
|
||||
{
|
||||
host: "ssh.dev.azure.com",
|
||||
repository: "v3/org-b/project/web",
|
||||
@@ -2303,57 +2303,55 @@ for (const checkout of [
|
||||
repository: "DefaultCollection/project/_git/web",
|
||||
remoteUrl: "https://org-b.visualstudio.com/DefaultCollection/project/_git/web",
|
||||
},
|
||||
]) {
|
||||
it.effect(`routes Azure URL reads and writes through a ${checkout.host} checkout`, () =>
|
||||
Effect.gen(function* () {
|
||||
const seen: string[] = [];
|
||||
const target = project({
|
||||
id: "target",
|
||||
title: "target",
|
||||
workspaceRoot: "/target",
|
||||
provider: "azure-devops",
|
||||
...checkout,
|
||||
});
|
||||
const service = yield* makeService({
|
||||
projects: [
|
||||
...["org-a/project/_git/web", "org-b/other-project/_git/web"].map((repository) =>
|
||||
project({
|
||||
id: repository,
|
||||
title: repository,
|
||||
workspaceRoot: `/${repository}`,
|
||||
provider: "azure-devops",
|
||||
host: "dev.azure.com",
|
||||
repository,
|
||||
}),
|
||||
),
|
||||
target,
|
||||
],
|
||||
providers: [
|
||||
fakeProvider("azure-devops", {
|
||||
getChangeRequestSummary: (input) =>
|
||||
Effect.sync(() => {
|
||||
seen.push(`read ${input.cwd} ${input.repository}`);
|
||||
return changeRequest(7, "2026-07-02T00:00:00Z");
|
||||
}),
|
||||
runAction: (input) =>
|
||||
Effect.sync(() => {
|
||||
seen.push(`write ${input.cwd} ${input.repository}`);
|
||||
}),
|
||||
])("routes Azure URL reads and writes through a $host checkout", (checkout) =>
|
||||
Effect.gen(function* () {
|
||||
const seen: string[] = [];
|
||||
const target = project({
|
||||
id: "target",
|
||||
title: "target",
|
||||
workspaceRoot: "/target",
|
||||
provider: "azure-devops",
|
||||
...checkout,
|
||||
});
|
||||
const service = yield* makeService({
|
||||
projects: [
|
||||
...["org-a/project/_git/web", "org-b/other-project/_git/web"].map((repository) =>
|
||||
project({
|
||||
id: repository,
|
||||
title: repository,
|
||||
workspaceRoot: `/${repository}`,
|
||||
provider: "azure-devops",
|
||||
host: "dev.azure.com",
|
||||
repository,
|
||||
}),
|
||||
],
|
||||
});
|
||||
const reference = {
|
||||
projectId: "org-a/project/_git/web" as ProjectId,
|
||||
host: "dev.azure.com",
|
||||
repository: "org-b/project/_git/web",
|
||||
number: 7,
|
||||
};
|
||||
yield* service.summary(reference, { recoverTransientFailure: false });
|
||||
yield* service.runAction({ ...reference, action: "merge" });
|
||||
assert.deepStrictEqual(seen, ["read /target web", "write /target web", "read /target web"]);
|
||||
}),
|
||||
);
|
||||
}
|
||||
),
|
||||
target,
|
||||
],
|
||||
providers: [
|
||||
fakeProvider("azure-devops", {
|
||||
getChangeRequestSummary: (input) =>
|
||||
Effect.sync(() => {
|
||||
seen.push(`read ${input.cwd} ${input.repository}`);
|
||||
return changeRequest(7, "2026-07-02T00:00:00Z");
|
||||
}),
|
||||
runAction: (input) =>
|
||||
Effect.sync(() => {
|
||||
seen.push(`write ${input.cwd} ${input.repository}`);
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
const reference = {
|
||||
projectId: "org-a/project/_git/web" as ProjectId,
|
||||
host: "dev.azure.com",
|
||||
repository: "org-b/project/_git/web",
|
||||
number: 7,
|
||||
};
|
||||
yield* service.summary(reference, { recoverTransientFailure: false });
|
||||
yield* service.runAction({ ...reference, action: "merge" });
|
||||
assert.deepStrictEqual(seen, ["read /target web", "write /target web", "read /target web"]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("refuses Azure cross-organization reads and writes without its checkout", () =>
|
||||
Effect.gen(function* () {
|
||||
@@ -5042,104 +5040,102 @@ it.effect('resolves an author filter of "me" to the viewer before narrowing a ho
|
||||
}),
|
||||
);
|
||||
|
||||
for (const crossHost of [false, true]) {
|
||||
it.effect(
|
||||
`authorizes stack rebases and refreshes sibling layers (cross-host: ${crossHost})`,
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
let taken = 0;
|
||||
let summaryReads = 0;
|
||||
let mutationFails = false;
|
||||
let stackRebase = true;
|
||||
let stackActions = true;
|
||||
const capabilities = {
|
||||
diff: true,
|
||||
comment: true,
|
||||
actions: ["update-branch"] as const,
|
||||
mergeMethods: ["merge"] as const,
|
||||
updateMethods: ["rebase"] as const,
|
||||
get stackActions() {
|
||||
return stackActions;
|
||||
},
|
||||
search: true,
|
||||
reactions: true,
|
||||
review: FULL_REVIEW,
|
||||
reviewers: FULL_REVIEWERS,
|
||||
};
|
||||
const service = yield* makeService({
|
||||
projects: [
|
||||
project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" }),
|
||||
project({
|
||||
id: "p2",
|
||||
title: "enterprise",
|
||||
workspaceRoot: "/b",
|
||||
repository: "acme/web",
|
||||
host: "enterprise.test",
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
fakeProvider("github", {
|
||||
capabilities,
|
||||
getViewerPermissions: () =>
|
||||
Effect.succeed({
|
||||
actions: [],
|
||||
stackRebase,
|
||||
comment: true,
|
||||
resolve: false,
|
||||
verdicts: [],
|
||||
requestReviewers: false,
|
||||
}),
|
||||
getChangeRequestSummary: () =>
|
||||
Effect.sync(() => {
|
||||
summaryReads++;
|
||||
return changeRequest(8, "2026-07-01T00:00:00Z");
|
||||
}),
|
||||
runAction: () =>
|
||||
Effect.gen(function* () {
|
||||
taken++;
|
||||
if (mutationFails) return yield* requestFailed;
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
const input = {
|
||||
...(crossHost ? { host: "enterprise.test" } : {}),
|
||||
projectId: "p1" as ProjectId,
|
||||
repository: "acme/web",
|
||||
number: 3,
|
||||
action: "update-branch" as const,
|
||||
updateMethod: "rebase" as const,
|
||||
stackNumber: 50,
|
||||
expectedStackHeads: [{ number: 3, headSha: "ccc" }],
|
||||
};
|
||||
yield* service.runAction(input);
|
||||
assert.strictEqual(taken, 1);
|
||||
const unrelated = { ...input, number: 8 };
|
||||
yield* service.summary(unrelated);
|
||||
assert.strictEqual(summaryReads, 1);
|
||||
stackRebase = false;
|
||||
assert.strictEqual(
|
||||
(yield* Effect.flip(service.runAction(input)))._tag,
|
||||
"PullRequestOperationError",
|
||||
);
|
||||
stackRebase = true;
|
||||
stackActions = false;
|
||||
assert.strictEqual(
|
||||
(yield* Effect.flip(service.runAction(input)))._tag,
|
||||
"PullRequestOperationError",
|
||||
);
|
||||
assert.strictEqual(taken, 1);
|
||||
yield* service.summary(unrelated);
|
||||
assert.strictEqual(summaryReads, 1);
|
||||
stackActions = true;
|
||||
mutationFails = true;
|
||||
yield* Effect.flip(service.runAction(input));
|
||||
assert.strictEqual(taken, 2);
|
||||
yield* service.summary(unrelated);
|
||||
assert.strictEqual(summaryReads, 2);
|
||||
}),
|
||||
);
|
||||
}
|
||||
it.effect.each([false, true])(
|
||||
"authorizes stack rebases and refreshes sibling layers (cross-host: %s)",
|
||||
(crossHost) =>
|
||||
Effect.gen(function* () {
|
||||
let taken = 0;
|
||||
let summaryReads = 0;
|
||||
let mutationFails = false;
|
||||
let stackRebase = true;
|
||||
let stackActions = true;
|
||||
const capabilities = {
|
||||
diff: true,
|
||||
comment: true,
|
||||
actions: ["update-branch"] as const,
|
||||
mergeMethods: ["merge"] as const,
|
||||
updateMethods: ["rebase"] as const,
|
||||
get stackActions() {
|
||||
return stackActions;
|
||||
},
|
||||
search: true,
|
||||
reactions: true,
|
||||
review: FULL_REVIEW,
|
||||
reviewers: FULL_REVIEWERS,
|
||||
};
|
||||
const service = yield* makeService({
|
||||
projects: [
|
||||
project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" }),
|
||||
project({
|
||||
id: "p2",
|
||||
title: "enterprise",
|
||||
workspaceRoot: "/b",
|
||||
repository: "acme/web",
|
||||
host: "enterprise.test",
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
fakeProvider("github", {
|
||||
capabilities,
|
||||
getViewerPermissions: () =>
|
||||
Effect.succeed({
|
||||
actions: [],
|
||||
stackRebase,
|
||||
comment: true,
|
||||
resolve: false,
|
||||
verdicts: [],
|
||||
requestReviewers: false,
|
||||
}),
|
||||
getChangeRequestSummary: () =>
|
||||
Effect.sync(() => {
|
||||
summaryReads++;
|
||||
return changeRequest(8, "2026-07-01T00:00:00Z");
|
||||
}),
|
||||
runAction: () =>
|
||||
Effect.gen(function* () {
|
||||
taken++;
|
||||
if (mutationFails) return yield* requestFailed;
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
const input = {
|
||||
...(crossHost ? { host: "enterprise.test" } : {}),
|
||||
projectId: "p1" as ProjectId,
|
||||
repository: "acme/web",
|
||||
number: 3,
|
||||
action: "update-branch" as const,
|
||||
updateMethod: "rebase" as const,
|
||||
stackNumber: 50,
|
||||
expectedStackHeads: [{ number: 3, headSha: "ccc" }],
|
||||
};
|
||||
yield* service.runAction(input);
|
||||
assert.strictEqual(taken, 1);
|
||||
const unrelated = { ...input, number: 8 };
|
||||
yield* service.summary(unrelated);
|
||||
assert.strictEqual(summaryReads, 1);
|
||||
stackRebase = false;
|
||||
assert.strictEqual(
|
||||
(yield* Effect.flip(service.runAction(input)))._tag,
|
||||
"PullRequestOperationError",
|
||||
);
|
||||
stackRebase = true;
|
||||
stackActions = false;
|
||||
assert.strictEqual(
|
||||
(yield* Effect.flip(service.runAction(input)))._tag,
|
||||
"PullRequestOperationError",
|
||||
);
|
||||
assert.strictEqual(taken, 1);
|
||||
yield* service.summary(unrelated);
|
||||
assert.strictEqual(summaryReads, 1);
|
||||
stackActions = true;
|
||||
mutationFails = true;
|
||||
yield* Effect.flip(service.runAction(input));
|
||||
assert.strictEqual(taken, 2);
|
||||
yield* service.summary(unrelated);
|
||||
assert.strictEqual(summaryReads, 2);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("refuses a way of updating a branch that the host or the viewer does not allow", () =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
Reference in new issue
Block a user