Skip to content
Open
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: 6 additions & 0 deletions packages/core/src/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ export function createSnapshotsQueue(percy) {
await runDoctorOnFailure(percy);
} else if (build?.id) {
await percy.client.finalizeBuild(build.id);
if (build.layoutUsed) {
percy.log.warn('Tip: VRA is Percy\'s recommended visual review mode — more accurate and adaptable than Layout. Learn more: https://www.browserstack.com/docs/percy/ai-agents/visual-review-agent/overview.');
}
percy.log.info(`Finalized build #${build.number}: ${build.url}`, { build });
} else {
percy.log.warn('Build not created', { build });
Expand All @@ -444,6 +447,9 @@ export function createSnapshotsQueue(percy) {
.handle('push', (snapshot, existing) => {
let { name, meta } = snapshot;

// track layout usage to tip about VRA when the build is finalized
if (snapshot.enableLayout) build.layoutUsed = true;

// log immediately when not deferred or dry-running
if (!percy.deferUploads) percy.log.info(`Snapshot taken: ${snapshotLogName(name, meta)}`, meta);
if (percy.dryRun) percy.log.info(`Snapshot found: ${snapshotLogName(name, meta)}`, meta);
Expand Down
68 changes: 68 additions & 0 deletions packages/core/test/snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2194,6 +2194,74 @@ describe('Snapshot', () => {
});
});
});

describe('VRA layout tip', () => {
let tip = '[percy] Tip: VRA is Percy\'s recommended visual review mode — more accurate and adaptable than Layout. Learn more: https://www.browserstack.com/docs/percy/ai-agents/visual-review-agent/overview.';

it('logs a VRA tip before finalizing when a snapshot has layout enabled', async () => {
await percy.snapshot({
name: 'test snapshot',
url: 'http://localhost:8000',
domSnapshot: '<html></html>',
enableLayout: true
});

await percy.stop();

expect(logger.stderr).toContain(tip);
expect(logger.stdout).toContain(
'[percy] Finalized build #1: https://percy.io/test/test/123'
);
});

it('logs the VRA tip when enableLayout is set globally in config', async () => {
percy.config.snapshot.enableLayout = true;

await percy.snapshot({
name: 'test snapshot',
url: 'http://localhost:8000',
domSnapshot: '<html></html>'
});

await percy.stop();

expect(logger.stderr).toContain(tip);
});

it('logs the VRA tip only once when multiple snapshots have layout enabled', async () => {
await percy.snapshot({
name: 'snapshot one',
url: 'http://localhost:8000',
domSnapshot: '<html></html>',
enableLayout: true
});
await percy.snapshot({
name: 'snapshot two',
url: 'http://localhost:8000',
domSnapshot: '<html></html>',
enableLayout: true
});

await percy.stop();

expect(logger.stderr.filter(l => l === tip).length).toEqual(1);
});

it('does not log the VRA tip when no snapshot has layout enabled', async () => {
await percy.snapshot({
name: 'test snapshot',
url: 'http://localhost:8000',
domSnapshot: '<html></html>'
});

await percy.stop();

expect(logger.stderr).not.toContain(tip);
expect(logger.stdout).toContain(
'[percy] Finalized build #1: https://percy.io/test/test/123'
);
});
});
});

// ── runDoctorOnFailure ────────────────────────────────────────────────────────
Expand Down
Loading