-
Notifications
You must be signed in to change notification settings - Fork 0
feat: expand @ocom-verification coverage for community management #299
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
Open
henry-casper
wants to merge
4
commits into
main
Choose a base branch
from
feat/Expand-@ocom-verification-coverage-for-Community-Management
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0ee3146
feat: expand @ocom-verification coverage for community management
henry-casper e55bd58
fix: replace URL regex with pathname predicate in submit-community-form
henry-casper 5245750
fix: address PR 299 review findings
henry-casper 6e03626
Merge origin/main (PR #297 staff-role coverage) into PR #299
henry-casper 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
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
43 changes: 43 additions & 0 deletions
43
...ages/ocom-verification/acceptance-api/src/contexts/community/questions/community-field.ts
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,43 @@ | ||
| import { type AnswersQuestions, notes, Question, type UsesAbilities } from '@serenity-js/core'; | ||
| import { QueryCommunity } from '../../../shared/abilities/query-community.ts'; | ||
| import type { CommunityNotes } from '../notes/community-notes.ts'; | ||
|
|
||
| type CommunityFieldName = 'name' | 'domain' | 'whiteLabelDomain' | 'handle'; | ||
|
|
||
| /** | ||
| * Question that reads a single settings field of the community the scenario is | ||
| * acting on (the community noted as `lastCommunityId`), straight from the API. | ||
| */ | ||
| export class CommunityField extends Question<Promise<string>> { | ||
| static named(fieldName: CommunityFieldName): CommunityField { | ||
| return new CommunityField(fieldName); | ||
| } | ||
|
|
||
| private constructor(private readonly fieldName: CommunityFieldName) { | ||
| super(`community ${fieldName}`); | ||
| } | ||
|
|
||
| override async answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string> { | ||
| const communityId = await this.readNote(actor, 'lastCommunityId'); | ||
| if (!communityId) { | ||
| throw new Error(`No community id found in actor notes; cannot read the community ${this.fieldName}. Did the actor act on a community first?`); | ||
| } | ||
|
|
||
| const community = await QueryCommunity.as(actor).byId(actor, communityId); | ||
| if (!community) { | ||
| throw new Error(`Community "${communityId}" was not found through the API`); | ||
| } | ||
|
|
||
| return String(community[this.fieldName] ?? ''); | ||
| } | ||
|
|
||
| override toString = () => `community ${this.fieldName}`; | ||
|
|
||
| private async readNote(actor: AnswersQuestions & UsesAbilities, key: keyof CommunityNotes): Promise<string | undefined> { | ||
| try { | ||
| return await actor.answer(notes<Record<typeof key, string>>().get(key)); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
| } | ||
32 changes: 32 additions & 0 deletions
32
...com-verification/acceptance-api/src/contexts/community/questions/viewed-community-name.ts
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,32 @@ | ||
| import { type AnswersQuestions, notes, Question, type UsesAbilities } from '@serenity-js/core'; | ||
| import type { CommunityNotes } from '../notes/community-notes.ts'; | ||
|
|
||
| /** | ||
| * Question that reads the community name observed by the actor's most recent | ||
| * view flow (recorded in `lastViewedCommunityName`). | ||
| */ | ||
| export class ViewedCommunityName extends Question<Promise<string>> { | ||
| static displayed(): ViewedCommunityName { | ||
| return new ViewedCommunityName(); | ||
| } | ||
|
|
||
| private constructor() { | ||
| super('viewed community name'); | ||
| } | ||
|
|
||
| override async answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string> { | ||
| let viewedName: string | undefined; | ||
| try { | ||
| viewedName = await actor.answer(notes<CommunityNotes>().get('lastViewedCommunityName')); | ||
| } catch { | ||
| viewedName = undefined; | ||
| } | ||
|
|
||
| if (!viewedName) { | ||
| throw new Error('No viewed community name found in actor notes. Did the actor view a community first?'); | ||
| } | ||
| return viewedName; | ||
| } | ||
|
|
||
| override toString = () => 'viewed community name'; | ||
| } |
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
1 change: 1 addition & 0 deletions
1
packages/ocom-verification/acceptance-api/src/contexts/community/step-definitions/index.ts
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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| // Community context step definitions | ||
| import './create-community.steps.ts'; | ||
| import './update-community-settings.steps.ts'; |
16 changes: 16 additions & 0 deletions
16
...es/ocom-verification/acceptance-api/src/contexts/community/step-definitions/last-actor.ts
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,16 @@ | ||
| import { actors } from '@ocom-verification/verification-shared/test-data'; | ||
|
|
||
| /** | ||
| * Tracks the most recent actor a community step acted as, so follow-up | ||
| * `Then` steps that omit the actor name resolve to the correct actor across | ||
| * the community step-definition files. | ||
| */ | ||
| let lastActorName = actors.CommunityOwner.name; | ||
|
|
||
| export function setLastActorName(actorName: string): void { | ||
| lastActorName = actorName; | ||
| } | ||
|
|
||
| export function getLastActorName(): string { | ||
| return lastActorName; | ||
| } |
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.