-
Notifications
You must be signed in to change notification settings - Fork 0
OUT-4015: gate Client Home Actions dropdown on app install published status #231
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d5476cc
feat(OUT-4015): add published status to app install schema
SandipBajracharya 3ce073f
feat(OUT-4015): gate Your Actions on published app installs
SandipBajracharya c08e019
feat(OUT-4015): show non drafts installed apps
SandipBajracharya 8cb8203
test(OUT-4015): cover non-draft install filtering
SandipBajracharya 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,83 @@ | ||
| import { AppInstallStatus, type AppInstallsData } from '@assembly/types' | ||
| import InstalledAppsService from '@installed-apps/lib/installed-apps.service' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { createInternalUser } from '../factories' | ||
|
|
||
| vi.mock('server-only', () => ({})) | ||
| vi.mock('@assembly/assembly-client', () => ({ default: vi.fn() })) | ||
| vi.mock('@/config/env', () => ({ default: { TASKS_APP_ID: 'tasks-app-id' } })) | ||
|
|
||
| // A fully-registered action label — required for an install to become "actionable". | ||
| const REGISTERED_LABEL = { verb: 'sign', singularNoun: 'document', pluralNoun: 'documents' } | ||
|
|
||
| const createInstall = (overrides: Partial<AppInstallsData> = {}): AppInstallsData => ({ | ||
| id: 'install-1', | ||
| appId: 'app-1', | ||
| displayName: 'App One', | ||
| icon: 'folder', | ||
| disabled: false, | ||
| isDraft: false, | ||
| isInternalApp: false, | ||
| status: AppInstallStatus.PUBLISHED, | ||
| ...overrides, | ||
| }) | ||
|
|
||
| // Builds the service against a stubbed AssemblyClient. `labels` maps installId → the action label | ||
| // its notification-settings fetch returns; installs not listed fall back to REGISTERED_LABEL. | ||
| const buildService = (installs: AppInstallsData[], labels: Record<string, unknown> = {}) => { | ||
| const getInstalls = vi.fn().mockResolvedValue(installs) | ||
| const getInstallNotificationSettings = vi.fn(async (id: string) => ({ | ||
| actionLabel: id in labels ? labels[id] : REGISTERED_LABEL, | ||
| })) | ||
| const assembly = { getInstalls, getInstallNotificationSettings } | ||
| const service = new InstalledAppsService(createInternalUser(), assembly as never) | ||
| return { service, getInstalls, getInstallNotificationSettings } | ||
| } | ||
|
|
||
| describe('InstalledAppsService#getActionableInstalls', () => { | ||
| beforeEach(() => vi.clearAllMocks()) | ||
|
|
||
| it('hides app-builder drafts and never fetches their notification settings', async () => { | ||
| const { service, getInstallNotificationSettings } = buildService([ | ||
| createInstall({ id: 'draft-1', appId: 'app-draft', status: AppInstallStatus.DRAFT }), | ||
| createInstall({ id: 'pub-1', appId: 'app-pub', status: AppInstallStatus.PUBLISHED }), | ||
| ]) | ||
|
|
||
| const result = await service.getActionableInstalls() | ||
|
|
||
| expect(result.map((r) => r.installId)).toEqual(['pub-1']) | ||
| expect(getInstallNotificationSettings).toHaveBeenCalledTimes(1) | ||
| expect(getInstallNotificationSettings).toHaveBeenCalledWith('pub-1') | ||
| }) | ||
|
|
||
| it('includes a published install carrying a registered action label', async () => { | ||
| const { service } = buildService([createInstall({ id: 'pub-1', appId: 'app-pub' })]) | ||
|
|
||
| const result = await service.getActionableInstalls() | ||
|
|
||
| expect(result).toHaveLength(1) | ||
| expect(result[0]).toMatchObject({ installId: 'pub-1', appId: 'app-pub', actionLabel: REGISTERED_LABEL }) | ||
| }) | ||
|
|
||
| it('hides only explicit drafts — missing/null status is treated as non-draft and shown (denylist)', async () => { | ||
| const { service } = buildService([ | ||
| createInstall({ id: 'draft-1', appId: 'app-draft', status: AppInstallStatus.DRAFT }), | ||
| createInstall({ id: 'undefined-1', appId: 'app-undefined', status: undefined }), | ||
| createInstall({ id: 'null-1', appId: 'app-null', status: null }), | ||
| ]) | ||
|
|
||
| const result = await service.getActionableInstalls() | ||
|
|
||
| expect(result.map((r) => r.installId)).toEqual(['undefined-1', 'null-1']) | ||
| }) | ||
|
|
||
| it('excludes a published install that has not registered a complete action label', async () => { | ||
| const { service } = buildService([createInstall({ id: 'pub-1', appId: 'app-pub' })], { | ||
| 'pub-1': { verb: 'sign', singularNoun: '', pluralNoun: '' }, | ||
| }) | ||
|
|
||
| const result = await service.getActionableInstalls() | ||
|
|
||
| expect(result).toEqual([]) | ||
| }) | ||
| }) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe install.status === AppINstallStatus.PUBLISHED is better?