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
5 changes: 5 additions & 0 deletions components/snapshot.form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ SnapshotForm.Options = function () {
}]} name={["options","enable-javascript"]} label="Enable Javascript" >
<Switch />
</Form.Item>
<Form.Item valuePropName="checked" rules={[{
required: true
}]} name={["options","enable-layout"]} label="Layout Only" >
<Switch />
</Form.Item>
<Form.Item name={["options","scope"]} label="Scope" >
<Input />
</Form.Item>
Expand Down
3 changes: 0 additions & 3 deletions contents/mutation-observer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ export default function SnapshotModal() {
useEffect(() => {
const onCapture = () => {
if (event) {
console.log('mutation-observer','capture emitted')
CaptureSnapshot(preferences.defaultSnapshotOptions, undefined, event)
SetEvent(undefined)
}
}
eventEmitter.on('capture', onCapture)
console.log('Captur registered')
return () => {
eventEmitter.off('capture', onCapture)
}
Expand All @@ -75,7 +73,6 @@ export default function SnapshotModal() {
}
if (autoCapture) {
if (e.type == 'load') {
console.log('mutation-observer','load emitted')
CaptureSnapshot(preferences.defaultSnapshotOptions, undefined, event)
} else {
observer.observe(window.document, observerOptions)
Expand Down
2 changes: 1 addition & 1 deletion contents/percy-dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function SnapshotModal() {
await CaptureSnapshot(options,req.body?.name)
res.send({ success: true })
} catch (err) {
console.log(err)
console.error(err)
res.send({ success: false, error: err })
}
}
Expand Down
1 change: 0 additions & 1 deletion options/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default function ChromeExtensionOptions() {
const [discoveryOptions] = Form.useForm()
const [preferences] = useLocalStorage<Preferences>('preferences')
useEffect(() => {
console.log(preferences)
if (preferences) {
snapshotOptions.setFieldsValue({ options: preferences.defaultSnapshotOptions })
discoveryOptions.setFieldsValue(preferences.discoveryOptions)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "percy-extension",
"displayName": "Percy Web Extension",
"version": "0.0.2",
"version": "0.0.3",
"description": "Percy Web Extension",
"author": "BrowserStack Pvt Ltd",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions schemas/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const SnapshotOptionsSchema = z.object({
"min-height": z.string().default("1024"),
"percy-css": z.string().optional(),
"scope": z.string().optional(),
"enable-javascript": z.boolean().default(false)
"enable-javascript": z.boolean().default(false),
"enable-layout":z.boolean().default(false)
})
export const SnapshotSchema = z.object({
dom: z.any(),
Expand All @@ -14,7 +15,8 @@ export const SnapshotSchema = z.object({
})).default({
widths: [375, 1280],
"min-height": "1024",
"enable-javascript": false
"enable-javascript": false,
"enable-layout": false
}),
url: z.string().url(),
headers: z.record(z.string()).optional(),
Expand Down
2 changes: 0 additions & 2 deletions tabs/snapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default function SnapshotsList() {
},
updateSnapshot: () => {
form.validateFields().then(({ options,name }) => {
console.log(options)
const snapshot = build.snapshots[modalOpen.name]
if (snapshot) {
snapshot.options = options
Expand Down Expand Up @@ -52,7 +51,6 @@ export default function SnapshotsList() {
Percy.clearBuild()
},
openPreview: (snapshot: Snapshot) => {
console.log(snapshot.dom)
var newWindow = window.open("");
newWindow.document.write(snapshot.dom.html)
}
Expand Down
6 changes: 2 additions & 4 deletions utils/percy-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ export class Percy {
percyConfig['percy'] = {
token: build.token
}
console.log(percyConfig)
return fetch(`${appUrl}/percy/start`, {
method: 'POST',
headers: {
"content-type": "application/json"
},
body: JSON.stringify(percyConfig)
}).then((res) => {
res.text().then(console.log)
return res.status == 200
}).catch((err) => {
return false
Expand Down Expand Up @@ -133,6 +131,7 @@ export class Percy {
widths: snapshot.options.widths?.map((w) => Number(w)).filter((w) => !Number.isNaN(w)),
minHeight: Number(snapshot.options["min-height"] || 0),
enableJavaScript: snapshot.options["enable-javascript"],
enableLayout: snapshot.options['enable-layout'],
requestHeaders: snapshot.headers
}
try {
Expand All @@ -147,13 +146,12 @@ export class Percy {
if (errors.length == 0) {
await Percy.clearBuild()
}
console.log(running)
chrome.tabs.create({
url: buildInfo?.build?.url
})
return true;
} catch (err) {
console.log(err)
console.error(err)
return false
} finally {
await LocalStorage.set('finalizing', false)
Expand Down