Repository navigation
feat(listings): add ignore list context menu to listing description #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
orangecoding
merged 7 commits into
orangecoding:master
from
chbndrhnns:feat/context-menu-ignore-list-v2
Oct 31, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0445df2
feat(listings): add ignore list context menu to listing description
chbndrhnns a7c8333
style(listings): use token font size and single quotes in less
chbndrhnns f9523da
fix(storage): accept string[] in appendJobBlacklist and return early …
chbndrhnns 2d13cd4
chore(locales): drop unused addToBlacklistHelp key
chbndrhnns a690e36
fix(listings): use errorMessage and localized fallback for blacklist …
chbndrhnns 1d6af43
fix(listings): gate ignore list context menu on job.isOnlyShared
chbndrhnns d6c00c2
fix(listings): restrict ignore list selection to description body and…
chbndrhnns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| /* | ||
| * Copyright (c) 2026 by Christian Kellner. | ||
| * Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause | ||
| */ | ||
|
|
||
| import { vi, describe, it, expect, beforeEach } from 'vitest'; | ||
| import Database from 'better-sqlite3'; | ||
| import Fastify from 'fastify'; | ||
|
|
||
| let db; | ||
|
|
||
| vi.mock('../../lib/services/storage/SqliteConnection.js', () => ({ | ||
| default: { | ||
| query: (sql, params = {}) => db.prepare(sql).all(params), | ||
| execute: (sql, params = {}) => db.prepare(sql).run(params), | ||
| withTransaction: (cb) => db.transaction(() => cb(db))(), | ||
| }, | ||
| })); | ||
|
|
||
| vi.mock('../../lib/services/storage/settingsStorage.js', () => ({ | ||
| getSettings: async () => ({ demoMode: false }), | ||
| upsertSettings: () => {}, | ||
| })); | ||
|
|
||
| const ALICE = { id: 'u1', username: 'alice', isAdmin: false }; | ||
| const BOB = { id: 'u2', username: 'bob', isAdmin: false }; | ||
| const ADMIN = { id: 'a1', username: 'root', isAdmin: true }; | ||
|
|
||
| describe('POST /api/jobs/:jobId/blacklist', () => { | ||
| let app; | ||
| let currentUser; | ||
|
|
||
| const build = async () => { | ||
| const plugin = (await import('../../lib/api/routes/jobRouter.js')).default; | ||
| const instance = Fastify(); | ||
| instance.addHook('preHandler', async (request) => { | ||
| request.currentUser = currentUser; | ||
| request.session = { currentUser: currentUser?.id }; | ||
| }); | ||
| await instance.register(plugin, { prefix: '/api/jobs' }); | ||
| return instance; | ||
| }; | ||
|
|
||
| beforeEach(async () => { | ||
| currentUser = ALICE; | ||
| db = new Database(':memory:'); | ||
| db.exec(` | ||
| CREATE TABLE jobs ( | ||
| id TEXT PRIMARY KEY, | ||
| user_id TEXT, | ||
| enabled INTEGER DEFAULT 1, | ||
| name TEXT, | ||
| blacklist TEXT, | ||
| provider TEXT, | ||
| notification_adapter TEXT, | ||
| shared_with_user TEXT, | ||
| spatial_filter TEXT, | ||
| spec_filter TEXT, | ||
| commute_filter TEXT, | ||
| deal_type TEXT, | ||
| last_run_at INTEGER | ||
| ); | ||
| CREATE TABLE configured_adapter ( | ||
| id TEXT PRIMARY KEY, | ||
| user_id TEXT, | ||
| name TEXT, | ||
| adapter_id TEXT, | ||
| visibility TEXT, | ||
| fields TEXT | ||
| ); | ||
| CREATE TABLE listings ( | ||
| id TEXT PRIMARY KEY, | ||
| job_id TEXT, | ||
| is_active INTEGER DEFAULT 1, | ||
| manually_deleted INTEGER DEFAULT 0 | ||
| ); | ||
| `); | ||
|
|
||
| db.prepare( | ||
| ` | ||
| INSERT INTO jobs (id, user_id, enabled, name, blacklist, provider, notification_adapter, shared_with_user, deal_type) | ||
| VALUES (?, ?, 1, ?, ?, '[]', '[]', '[]', 'rent') | ||
| `, | ||
| ).run('job-alice', 'u1', 'Alice Job', JSON.stringify(['OldWord'])); | ||
|
|
||
| app = await build(); | ||
| }); | ||
|
|
||
| it('rejects empty or whitespace-only word input with 400', async () => { | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/job-alice/blacklist', | ||
| payload: { word: ' ' }, | ||
| }); | ||
| expect(res.statusCode).toBe(400); | ||
| expect(JSON.parse(res.payload).error).toBe('No valid blacklist word provided'); | ||
| }); | ||
|
|
||
| it('returns 404 if job does not exist', async () => { | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/nonexistent-job/blacklist', | ||
| payload: { word: 'Tauschwohnung' }, | ||
| }); | ||
| expect(res.statusCode).toBe(404); | ||
| }); | ||
|
|
||
| it('returns 403 if another user tries to modify the job', async () => { | ||
| currentUser = BOB; | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/job-alice/blacklist', | ||
| payload: { word: 'Tauschwohnung' }, | ||
| }); | ||
| expect(res.statusCode).toBe(403); | ||
| }); | ||
|
|
||
| it('successfully appends word and trims whitespace', async () => { | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/job-alice/blacklist', | ||
| payload: { word: ' Tauschwohnung ' }, | ||
| }); | ||
| expect(res.statusCode).toBe(200); | ||
| const body = JSON.parse(res.payload); | ||
| expect(body.success).toBe(true); | ||
| expect(body.added).toEqual(['Tauschwohnung']); | ||
| expect(body.blacklist).toEqual(['OldWord', 'Tauschwohnung']); | ||
|
|
||
| const row = db.prepare('SELECT blacklist FROM jobs WHERE id = ?').get('job-alice'); | ||
| expect(JSON.parse(row.blacklist)).toEqual(['OldWord', 'Tauschwohnung']); | ||
| }); | ||
|
|
||
| it('deduplicates case-insensitively when word already exists', async () => { | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/job-alice/blacklist', | ||
| payload: { word: 'oldword' }, | ||
| }); | ||
| expect(res.statusCode).toBe(200); | ||
| const body = JSON.parse(res.payload); | ||
| expect(body.success).toBe(true); | ||
| expect(body.added).toEqual([]); | ||
| expect(body.blacklist).toEqual(['OldWord']); | ||
| }); | ||
|
|
||
| it('supports words array in body', async () => { | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/job-alice/blacklist', | ||
| payload: { words: ['WBS', 'Zwangsversteigerung', 'oldword'] }, | ||
| }); | ||
| expect(res.statusCode).toBe(200); | ||
| const body = JSON.parse(res.payload); | ||
| expect(body.success).toBe(true); | ||
| expect(body.added).toEqual(['WBS', 'Zwangsversteigerung']); | ||
| expect(body.blacklist).toEqual(['OldWord', 'WBS', 'Zwangsversteigerung']); | ||
| }); | ||
|
|
||
| it('allows admin to modify any job', async () => { | ||
| currentUser = ADMIN; | ||
| const res = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/jobs/job-alice/blacklist', | ||
| payload: { word: 'AdminAdded' }, | ||
| }); | ||
| expect(res.statusCode).toBe(200); | ||
| const body = JSON.parse(res.payload); | ||
| expect(body.added).toEqual(['AdminAdded']); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.