fix(editor): Persist tag filter when clicking tag directly in workflows page (#9709)

This commit is contained in:
Tomi Turtiainen 2024-06-12 12:06:50 +03:00 committed by GitHub
parent f9aa340015
commit 0502738c0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -21,6 +21,8 @@ describe('WorkflowsView', () => {
let usersStore: ReturnType<typeof useUsersStore>; let usersStore: ReturnType<typeof useUsersStore>;
let projectsStore: ReturnType<typeof useProjectsStore>; let projectsStore: ReturnType<typeof useProjectsStore>;
const routerReplaceMock = vi.fn();
const renderComponent = createComponentRenderer(WorkflowsView, { const renderComponent = createComponentRenderer(WorkflowsView, {
global: { global: {
mocks: { mocks: {
@ -29,7 +31,7 @@ describe('WorkflowsView', () => {
params: {}, params: {},
}, },
$router: { $router: {
replace: vi.fn(), replace: routerReplaceMock,
}, },
}, },
}, },
@ -90,11 +92,13 @@ describe('WorkflowsView', () => {
await waitFor(() => { await waitFor(() => {
expect(getAllByTestId('resources-list-item').length).toBeLessThan(5); expect(getAllByTestId('resources-list-item').length).toBeLessThan(5);
}); });
expect(routerReplaceMock).toHaveBeenLastCalledWith({ query: { tags: '1' } });
await userEvent.click(getByTestId('workflows-filter-reset')); await userEvent.click(getByTestId('workflows-filter-reset'));
await waitFor(() => { await waitFor(() => {
expect(getAllByTestId('resources-list-item')).toHaveLength(5); expect(getAllByTestId('resources-list-item')).toHaveLength(5);
}); });
expect(routerReplaceMock).toHaveBeenLastCalledWith({ query: undefined });
await userEvent.click( await userEvent.click(
getAllByTestId('resources-list-item')[3].querySelector('.n8n-tag') as HTMLElement, getAllByTestId('resources-list-item')[3].querySelector('.n8n-tag') as HTMLElement,
@ -102,5 +106,6 @@ describe('WorkflowsView', () => {
await waitFor(() => { await waitFor(() => {
expect(getAllByTestId('resources-list-item').length).toBeLessThan(5); expect(getAllByTestId('resources-list-item').length).toBeLessThan(5);
}); });
expect(routerReplaceMock).toHaveBeenLastCalledWith({ query: { tags: '1' } });
}); });
}); });

View file

@ -269,6 +269,12 @@ const WorkflowsView = defineComponent({
}, },
}, },
watch: { watch: {
filters: {
deep: true,
handler() {
this.saveFiltersOnQueryString();
},
},
'filters.tags'() { 'filters.tags'() {
this.sendFiltersTelemetry('tags'); this.sendFiltersTelemetry('tags');
}, },
@ -295,7 +301,6 @@ const WorkflowsView = defineComponent({
methods: { methods: {
onFiltersUpdated(filters: Filters) { onFiltersUpdated(filters: Filters) {
this.filters = filters; this.filters = filters;
this.saveFiltersOnQueryString();
}, },
addWorkflow() { addWorkflow() {
this.uiStore.nodeViewInitialized = false; this.uiStore.nodeViewInitialized = false;