mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-13 00:03:00 +00:00
test: pin the enterprise refusal the role pickers read as 'not under roles'
The server's sentence and the frontend's copy of it were coupled by nothing, so rewording either one turned every role picker on a community build into a failed lookup. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
8e9980346e
commit
4e1d5f9d02
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const request = vi.fn()
|
||||
vi.mock('$lib/gen/core/request', () => ({ request: (...args: unknown[]) => request(...args) }))
|
||||
vi.mock('$lib/gen', () => ({ OpenAPI: {} }))
|
||||
vi.mock('$lib/cloud', () => ({ isCloudHosted: () => false }))
|
||||
|
||||
import { listUsableDatatableRoles } from './datatableUsableRoles'
|
||||
|
||||
const refuse = (body: string) => () =>
|
||||
Promise.reject(Object.assign(new Error('Bad Request'), { body }))
|
||||
|
||||
describe('listUsableDatatableRoles', () => {
|
||||
// The refusal is recognised by its sentence, so rewording it on one side alone would turn every
|
||||
// data table on a build without the Enterprise Edition into a failed lookup rather than one
|
||||
// that is not under roles.
|
||||
it('reads the enterprise refusal as not under roles, and rethrows anything else', async () => {
|
||||
request.mockImplementation(refuse('Data table roles are a Windmill Enterprise Edition feature'))
|
||||
expect(await listUsableDatatableRoles('ws', 'main')).toEqual({
|
||||
permissioned: false,
|
||||
roles: [],
|
||||
default_role: 'admin'
|
||||
})
|
||||
|
||||
request.mockImplementation(refuse('Data table not found'))
|
||||
const rethrown = await listUsableDatatableRoles('ws', 'main').catch((e) => e)
|
||||
expect(rethrown).toBeInstanceOf(Error)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user