Repository navigation
Add featured community listings surfaced as onboarding starter packages #765
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 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,130 @@ | ||
| import { expect, test } from './playwright-utils.ts' | ||
| import { seedCommunityListingInE2eDatabase } from './d1-utils.ts' | ||
|
|
||
| test('admins can feature trusted listings and members see them in onboarding', async ({ | ||
| page, | ||
| seedE2eUser, | ||
| login, | ||
| }) => { | ||
| const runId = Date.now() | ||
| const trustedListingId = `e2e-featured-listing-${runId}` | ||
| const trustedListingName = `@kody/featured-package-${runId}` | ||
| const untrustedListingId = `e2e-unfeaturable-listing-${runId}` | ||
| const adminUser = await seedE2eUser({ | ||
| email: `featured-admin-${runId}@example.com`, | ||
| username: `featured-admin-${runId}`, | ||
| password: 'featured-admin-password', | ||
| admin: true, | ||
| }) | ||
| const memberUser = await seedE2eUser({ | ||
| email: `featured-member-${runId}@example.com`, | ||
| username: `featured-member-${runId}`, | ||
| password: 'featured-member-password', | ||
| }) | ||
| await seedCommunityListingInE2eDatabase({ | ||
| listingId: trustedListingId, | ||
| ownerEmail: memberUser.email, | ||
| name: trustedListingName, | ||
| description: 'Trusted listing seeded for the featured e2e test.', | ||
| tags: ['featured'], | ||
| trusted: true, | ||
| }) | ||
| await seedCommunityListingInE2eDatabase({ | ||
| listingId: untrustedListingId, | ||
| ownerEmail: memberUser.email, | ||
| name: `@kody/unfeaturable-package-${runId}`, | ||
| description: 'Untrusted listing seeded for the featured e2e test.', | ||
| tags: ['featured'], | ||
| }) | ||
|
|
||
| // Non-admin members never see the featuring controls and cannot hit the | ||
| // API. | ||
| await login({ | ||
| email: memberUser.email, | ||
| password: memberUser.password, | ||
| mode: 'login', | ||
| }) | ||
| await page.goto(`/community/${trustedListingId}`) | ||
| await expect(page.getByText('Fork with your agent')).toBeVisible() | ||
| await expect(page.getByTestId('community-admin-feature')).toHaveCount(0) | ||
| const memberFeatureResponse = await page.request.post( | ||
| `/community/${trustedListingId}/feature.json`, | ||
| { | ||
| data: { featured: true }, | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }, | ||
| ) | ||
| expect(memberFeatureResponse.status()).toBe(403) | ||
|
|
||
| // Without any featured listings, onboarding falls back to the browse CTA. | ||
| await page.goto('/onboarding') | ||
| await expect( | ||
| page.getByRole('heading', { name: 'Explore community packages' }), | ||
| ).toBeVisible() | ||
| await expect(page.getByTestId('onboarding-starter-packages')).toHaveCount(0) | ||
|
|
||
| // Admins can feature the trusted listing from the detail page. | ||
| await page.context().clearCookies() | ||
| await login({ | ||
| email: adminUser.email, | ||
| password: adminUser.password, | ||
| mode: 'login', | ||
| }) | ||
| await page.goto(`/community/${trustedListingId}`) | ||
| await expect(page.getByTestId('community-admin-feature')).toBeVisible() | ||
| await page.getByRole('button', { name: 'Feature in onboarding' }).click() | ||
| await expect( | ||
| page.getByRole('button', { name: 'Remove from onboarding' }), | ||
| ).toBeVisible() | ||
| await expect( | ||
| page.getByTestId('community-detail-featured-badge'), | ||
| ).toBeVisible() | ||
|
|
||
| // Untrusted listings cannot be featured: the button stays disabled. | ||
| await page.goto(`/community/${untrustedListingId}`) | ||
| await expect( | ||
| page.getByRole('button', { name: 'Feature in onboarding' }), | ||
| ).toBeDisabled() | ||
| await expect( | ||
| page.getByText('Only trusted listings can be featured in onboarding.'), | ||
| ).toBeVisible() | ||
|
|
||
| // Members now see the featured listing as an onboarding starter package. | ||
| await page.context().clearCookies() | ||
| await login({ | ||
| email: memberUser.email, | ||
| password: memberUser.password, | ||
| mode: 'login', | ||
| }) | ||
| await page.goto('/onboarding') | ||
| await expect(page.getByTestId('onboarding-starter-packages')).toBeVisible() | ||
| const starterLink = page.getByTestId(`onboarding-starter-${trustedListingId}`) | ||
| await expect(starterLink).toBeVisible() | ||
| await expect(starterLink).toContainText(trustedListingName) | ||
| await starterLink.click() | ||
| await expect(page).toHaveURL(new RegExp(`/community/${trustedListingId}$`)) | ||
| await expect( | ||
| page.getByRole('button', { name: 'Install', exact: true }), | ||
| ).toBeVisible() | ||
|
|
||
| // Removing the mark pulls the listing from onboarding again. | ||
| await page.context().clearCookies() | ||
| await login({ | ||
| email: adminUser.email, | ||
| password: adminUser.password, | ||
| mode: 'login', | ||
| }) | ||
| await page.goto(`/community/${trustedListingId}`) | ||
| await page.getByRole('button', { name: 'Remove from onboarding' }).click() | ||
| await expect( | ||
| page.getByRole('button', { name: 'Feature in onboarding' }), | ||
| ).toBeVisible() | ||
| await expect(page.getByTestId('community-detail-featured-badge')).toHaveCount( | ||
| 0, | ||
| ) | ||
| await page.goto('/onboarding') | ||
| await expect( | ||
| page.getByRole('heading', { name: 'Explore community packages' }), | ||
| ).toBeVisible() | ||
| await expect(page.getByTestId('onboarding-starter-packages')).toHaveCount(0) | ||
| }) |
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.