Skip to content

Commit

Permalink
fix: Update Posthog no-capture (#5693)
Browse files Browse the repository at this point in the history
* feat: add no-capture class for schema view

* fix: add ee nocapture

* fix: update no capture

* fix: update ndv capturing

* feat: remove no capture from empty resources list

* lint: fix

* test: update tests

* test: add json view tests

* fix: update more class to cover

* lint: fix
  • Loading branch information
mutdmour committed Mar 23, 2023
1 parent ac18c0b commit a732374
Show file tree
Hide file tree
Showing 14 changed files with 785 additions and 58 deletions.
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/ExecutionsList.vue
Expand Up @@ -92,7 +92,7 @@
/>
</td>
<td>
<span>{{
<span class="ph-no-capture">{{
execution.workflowName || $locale.baseText('executionsList.unsavedWorkflow')
}}</span>
</td>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/InputPanel.vue
Expand Up @@ -45,7 +45,7 @@
:label="`${truncate(node.name)} ${getMultipleNodesText(node.name)}`"
data-test-id="ndv-input-option"
>
{{ truncate(node.name) }}&nbsp;
<span class="ph-no-capture">{{ truncate(node.name) }}&nbsp;</span>
<span v-if="getMultipleNodesText(node.name)">{{
getMultipleNodesText(node.name)
}}</span>
Expand Down
Expand Up @@ -27,6 +27,7 @@
v-if="expressionOutput"
:class="$style.hint"
data-test-id="parameter-expression-preview"
class="ph-no-capture"
:highlight="!!(expressionOutput && targetItem)"
:hint="expressionOutput"
:singleLine="true"
Expand Down
Expand Up @@ -47,6 +47,7 @@
[$style.selected]: result.value === value,
[$style.hovering]: hoverIndex === i,
}"
class="ph-no-capture"
@click="() => onItemClick(result.value)"
@mouseenter="() => onItemHover(i)"
@mouseleave="() => onItemHoverLeave()"
Expand Down
2 changes: 0 additions & 2 deletions packages/editor-ui/src/components/RunData.vue
Expand Up @@ -290,7 +290,6 @@

<run-data-table
v-else-if="hasNodeRun && displayMode === 'table'"
class="ph-no-capture"
:node="node"
:inputData="inputData"
:mappingEnabled="mappingEnabled"
Expand All @@ -306,7 +305,6 @@

<run-data-json
v-else-if="hasNodeRun && displayMode === 'json'"
class="ph-no-capture"
:paneType="paneType"
:editMode="editMode"
:sessioId="sessionId"
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/RunDataHtml.vue
@@ -1,5 +1,5 @@
<template>
<div class="__html-display" v-html="html"></div>
<div class="__html-display ph-no-capture" v-html="html"></div>
</template>

<script lang="ts">
Expand Down
99 changes: 60 additions & 39 deletions packages/editor-ui/src/components/RunDataJson.test.ts
@@ -1,60 +1,81 @@
import Vue from 'vue';
import { PiniaVuePlugin } from 'pinia';
import { createTestingPinia } from '@pinia/testing';
import { render, screen } from '@testing-library/vue';
import { render, screen, cleanup } from '@testing-library/vue';
import RunDataJson from '@/components/RunDataJson.vue';

Vue.use(PiniaVuePlugin);

describe('RunDataJson.vue', () => {
it('renders json values properly', () => {
render(RunDataJson, {
pinia: createTestingPinia(),
props: {
mappingEnabled: true,
editMode: { enabled: false },
inputData: [
{
json: {
list: [1, 2, 3],
record: { name: 'Joe' },
myNumber: 123,
myStringNumber: '456',
myStringText: 'abc',
nil: null,
d: undefined,
},
},
],
node: {
parameters: {
keepOnlySet: false,
values: {},
options: {},
const DEFAULT_SETUP = {
pinia: createTestingPinia(),
props: {
mappingEnabled: true,
editMode: { enabled: false },
inputData: [
{
json: {
list: [1, 2, 3],
record: { name: 'Joe' },
myNumber: 123,
myStringNumber: '456',
myStringText: 'abc',
nil: null,
d: undefined,
},
id: '820ea733-d8a6-4379-8e73-88a2347ea003',
name: 'Set',
type: 'n8n-nodes-base.set',
typeVersion: 1,
position: [380, 1060],
disabled: false,
},
},
mocks: {
$locale: {
baseText() {
return '';
},
],
node: {
parameters: {
keepOnlySet: false,
values: {},
options: {},
},
$store: {
getters: {},
id: '820ea733-d8a6-4379-8e73-88a2347ea003',
name: 'Set',
type: 'n8n-nodes-base.set',
typeVersion: 1,
position: [380, 1060],
disabled: false,
},
},
mocks: {
$locale: {
baseText() {
return '';
},
},
$store: {
getters: {},
},
},
};

beforeEach(cleanup);

it('renders json values properly', () => {
const { container } = render(RunDataJson, DEFAULT_SETUP, (vue) => {
vue.use(PiniaVuePlugin);
});
expect(container).toMatchSnapshot();

expect(screen.getByText('123')).toBeInTheDocument();
expect(screen.getByText('"456"')).toBeInTheDocument();
expect(screen.getByText('"abc"')).toBeInTheDocument();
expect(screen.getByText('null')).toBeInTheDocument();
expect(screen.queryByText('undefined')).not.toBeInTheDocument();
});

it('sets ph-no-capture class correctly', () => {
render(RunDataJson, DEFAULT_SETUP);

expect(screen.getByText('"list"')).not.toHaveClass('ph-no-capture');
expect(screen.getByText('"record"')).not.toHaveClass('ph-no-capture');
expect(screen.getByText('"myStringNumber"')).not.toHaveClass('ph-no-capture');

expect(screen.getByText('123')).toHaveClass('ph-no-capture');
expect(screen.getByText('"456"')).toHaveClass('ph-no-capture');
expect(screen.getByText('"abc"')).toHaveClass('ph-no-capture');
expect(screen.getByText('null')).toHaveClass('ph-no-capture');
});
});
5 changes: 4 additions & 1 deletion packages/editor-ui/src/components/RunDataJson.vue
Expand Up @@ -45,7 +45,9 @@
>
</template>
<template #nodeValue="{ node }">
<span v-if="isNaN(node.index)">{{ getContent(node.content) }}</span>
<span v-if="isNaN(node.index)" class="ph-no-capture">{{
getContent(node.content)
}}</span>
<span
v-else
data-target="mappable"
Expand All @@ -57,6 +59,7 @@
[$style.mappable]: mappingEnabled,
[$style.dragged]: draggingPath === node.path,
}"
class="ph-no-capture"
>{{ getContent(node.content) }}</span
>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/RunDataSchemaItem.vue
Expand Up @@ -96,7 +96,7 @@ const getIconBySchemaType = (type: Schema['type']): string => {
<span v-if="key" :class="{ [$style.arrayIndex]: isSchemaParentTypeArray }">{{ key }}</span>
</span>
</div>
<span v-if="text" :class="$style.text">{{ text }}</span>
<span v-if="text" :class="$style.text" class="ph-no-capture">{{ text }}</span>
<input v-if="level > 0 && isSchemaValueArray" :id="subKey" type="checkbox" checked />
<label v-if="level > 0 && isSchemaValueArray" :class="$style.toggle" :for="subKey">
<font-awesome-icon icon="angle-up" />
Expand Down
9 changes: 6 additions & 3 deletions packages/editor-ui/src/components/RunDataTable.vue
Expand Up @@ -120,6 +120,7 @@
<span
v-if="isSimple(data)"
:class="{ [$style.value]: true, [$style.empty]: isEmpty(data) }"
class="ph-no-capture"
>{{ getValueToRender(data) }}</span
>
<n8n-tree :nodeClass="$style.nodeClass" v-else :value="data">
Expand All @@ -141,9 +142,11 @@
>
</template>
<template #value="{ value }">
<span :class="{ [$style.nestedValue]: true, [$style.empty]: isEmpty(value) }">{{
getValueToRender(value)
}}</span>
<span
:class="{ [$style.nestedValue]: true, [$style.empty]: isEmpty(value) }"
class="ph-no-capture"
>{{ getValueToRender(value) }}</span
>
</template>
</n8n-tree>
</td>
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/VariableSelectorItem.vue
Expand Up @@ -47,11 +47,11 @@
</div>
</div>
<div v-else class="value clickable" @click="selectItem(item)">
<div class="item-title ph-no-capture" :title="item.key">
<div class="item-title" :title="item.key">
{{ item.name }}:
<font-awesome-icon icon="dot-circle" title="Select Item" />
</div>
<div class="item-value">
<div class="item-value ph-no-capture">
{{ item.value !== undefined ? item.value : $locale.baseText('variableSelectorItem.empty') }}
</div>
</div>
Expand Down

0 comments on commit a732374

Please sign in to comment.