Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ async function main(): Promise<void> {
if (!help) {
const { token, host } = await getCredentials();

const telemetryEnabled = await isTelemetryEnabled();
const telemetryEnabled = env.PRISMIC_TELEMETRY_ENABLED ?? (await isTelemetryEnabled());
const sentryEnabled = env.PRISMIC_SENTRY_ENABLED ?? (telemetryEnabled && env.PROD);

if (env.PRISMIC_SENTRY_ENABLED ?? (telemetryEnabled && env.PROD)) {
if (sentryEnabled) {
await initSentry({ host, repo });
}
if (env.PRISMIC_TELEMETRY_ENABLED ?? telemetryEnabled) {
if (telemetryEnabled) {
await initTracking({ host, repo });
}

Expand All @@ -132,7 +133,7 @@ async function main(): Promise<void> {
process.on("exit", () => spawnTokenRefresh());
}

if (!exp || exp > now) {
if ((sentryEnabled || telemetryEnabled) && (!exp || exp > now)) {
getProfile({ token, host })
.then((profile) => {
trackUser(profile);
Expand Down
21 changes: 18 additions & 3 deletions test/token-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ it("creates an access token with --allow-releases", async ({
expect(auth!.scope).toBe("master+releases");
});

it("creates a write token", async ({ expect, prismic, repo, token, host }) => {
// Wroom 500s under concurrent same-user write-token creates; keep this sequential.
it.sequential("creates a write token", async ({ expect, prismic, repo, token, host }) => {
const { stdout, stderr, exitCode } = await prismic("token", ["create", "--write"]);
expect(exitCode, stderr).toBe(0);
expect(stdout).toContain("Token created:");
Expand All @@ -57,7 +58,14 @@ it("creates a write token", async ({ expect, prismic, repo, token, host }) => {
expect(found).toBeDefined();
});

it("creates a write token with a custom --name", async ({ expect, prismic, repo, token, host }) => {
// Wroom 500s under concurrent same-user write-token creates; keep this sequential.
it.sequential("creates a write token with a custom --name", async ({
expect,
prismic,
repo,
token,
host,
}) => {
const { stdout, stderr, exitCode } = await prismic("token", [
"create",
"--write",
Expand All @@ -75,7 +83,14 @@ it("creates a write token with a custom --name", async ({ expect, prismic, repo,
expect(found!.app_name).toBe("My Seed Token");
});

it("outputs a write token as JSON with --json", async ({ expect, prismic, repo, token, host }) => {
// Wroom 500s under concurrent same-user write-token creates; keep this sequential.
it.sequential("outputs a write token as JSON with --json", async ({
expect,
prismic,
repo,
token,
host,
}) => {
Comment thread
angeloashmore marked this conversation as resolved.
const { stdout, stderr, exitCode } = await prismic("token", ["create", "--write", "--json"]);
expect(exitCode, stderr).toBe(0);

Expand Down
3 changes: 2 additions & 1 deletion test/token-delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ it("deletes an access token", async ({ expect, prismic, repo, token, host }) =>
expect(allAuths.find((a) => a.token === created.token)).toBeUndefined();
});

it("deletes a write token", async ({ expect, prismic, repo, token, host }) => {
// Wroom 500s under concurrent same-user write-token creates; keep this sequential.
it.sequential("deletes a write token", async ({ expect, prismic, repo, token, host }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write-token tests still race across files

Low Severity

it.sequential only serializes tests within a file. With default file parallelism, write-token creates in token-create.test.ts can still overlap createWriteToken in token-delete.test.ts for the same E2E user, so the Wroom 500 race the comments call out can persist.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fe45ddd. Configure here.

const created = await createWriteToken({ repo, token, host });

const { stdout, stderr, exitCode } = await prismic("token", ["delete", created.token]);
Expand Down
Loading