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

View file

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