Skip to content
Merged
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
6 changes: 1 addition & 5 deletions packages/sdk-utils/src/percy-enabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export async function isPercyEnabled() {
error = e;
}

if (percy.enabled && percy.version.major !== 1) {
log.info('Unsupported Percy CLI version, disabling snapshots');
log.debug(`Found version: ${percy.version}`);
percy.enabled = false;
} else if (!percy.enabled) {
if (!percy.enabled) {
log.info('Percy is not running, disabling snapshots');
log.debug(error);
}
Expand Down
15 changes: 10 additions & 5 deletions packages/sdk-utils/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,20 @@ describe('SDK Utils', () => {
]));
});

it('disables snapshots when the API version is unsupported', async () => {
await helpers.test('version', '0.1.0');
await expectAsync(isPercyEnabled()).toBeResolvedTo(false);
it('stays enabled against a next-major CLI', async () => {
await helpers.test('version', '2.0.0');
await expectAsync(isPercyEnabled()).toBeResolvedTo(true);

expect(helpers.logger.stdout).toEqual(jasmine.arrayContaining([
'[percy] Unsupported Percy CLI version, disabling snapshots'
expect(helpers.logger.stdout).not.toEqual(jasmine.arrayContaining([
jasmine.stringMatching(/Unsupported Percy CLI version/)
]));
});

it('stays enabled against a 0.x CLI', async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[Low] 0.x CLI spec does not represent a reachable scenario

This mocks /percy/healthcheck returning 0.1.0, but per the PR's own account the legacy pre-1.0 agent never implemented that endpoint — a real 0.x agent fails in the try/catch and is disabled as "Percy is not running" before any version is read. The spec is really re-asserting "the major gate is gone" with an arbitrary version string, so the name implies a legacy-agent compatibility guarantee the code does not make.

Suggestion: rename to something like 'stays enabled regardless of the reported version', or fold it into the 2.x spec as parametrized cases.

Reviewer: stack-code-reviewer

await helpers.test('version', '0.1.0');
await expectAsync(isPercyEnabled()).toBeResolvedTo(true);
});

it('returns false if the build fails during a snapshot', async () => {
await helpers.test('error', '/percy/snapshot');
await helpers.test('build-failure');
Expand Down
Loading