forked from Joystream/joystream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Membership mappings fixes w.r.t. Joystream/hydra#435 + additional tests
- Loading branch information
Showing
7 changed files
with
89 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,19 +1,28 @@ | ||
import { MembershipMetadata } from '@joystream/metadata-protobuf' | ||
import { CreateInterface } from '@joystream/types' | ||
import { BuyMembershipParameters } from '@joystream/types/members' | ||
import { Utils } from '../../utils' | ||
import { Bytes } from '@polkadot/types' | ||
|
||
type MemberCreationParams = { | ||
root_account: string | ||
controller_account: string | ||
handle: string | ||
name?: string | ||
about?: string | ||
metadata: Bytes | ||
} | ||
|
||
// Common code for Membership fixtures | ||
export function generateParamsFromAccountId(accountId: string): CreateInterface<BuyMembershipParameters> { | ||
const metadataBytes = Utils.metadataToBytes(MembershipMetadata, { | ||
name: `name${accountId.substring(0, 14)}`, | ||
about: `about${accountId.substring(0, 14)}`, | ||
}) | ||
export function generateParamsFromAccountId(accountId: string): MemberCreationParams { | ||
const name = `name${accountId.substring(0, 14)}` | ||
const about = `about${accountId.substring(0, 14)}` | ||
const metadataBytes = Utils.metadataToBytes(MembershipMetadata, { name, about }) | ||
|
||
return { | ||
root_account: accountId, | ||
controller_account: accountId, | ||
handle: `handle${accountId.substring(0, 14)}`, | ||
name, | ||
about, | ||
metadata: metadataBytes, | ||
} | ||
} |
This file contains 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
31 changes: 25 additions & 6 deletions
31
tests/integration-tests/src/flows/membership/updatingProfile.ts
This file contains 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,23 +1,42 @@ | ||
import { FlowProps } from '../../Flow' | ||
import { BuyMembershipHappyCaseFixture, UpdateProfileHappyCaseFixture } from '../../fixtures/membership' | ||
import { | ||
BuyMembershipHappyCaseFixture, | ||
MemberProfileData, | ||
UpdateProfileHappyCaseFixture, | ||
} from '../../fixtures/membership' | ||
|
||
import { extendDebug } from '../../Debugger' | ||
import { FixtureRunner } from '../../Fixture' | ||
import { generateParamsFromAccountId } from '../../fixtures/membership/utils' | ||
|
||
export default async function updatingProfile({ api, query }: FlowProps): Promise<void> { | ||
const debug = extendDebug('flow:member-profile-update') | ||
debug('Started') | ||
api.enableDebugTxLogs() | ||
|
||
const updates: MemberProfileData[] = [ | ||
// Partial updates | ||
// FIXME: Currently handle always need to be provided, see: https://github.com/Joystream/joystream/issues/2503 | ||
{ handle: 'New handle 1', name: 'New name' }, | ||
{ handle: 'New handle 2' }, | ||
// Setting metadata to null | ||
{ handle: 'New handle 3', name: '', about: '' }, | ||
// Full update | ||
{ handle: 'Updated handle', name: 'Updated name', about: 'Updated about' }, | ||
] | ||
|
||
const [account] = (await api.createKeyPairs(1)).map((key) => key.address) | ||
const buyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(api, query, [account]) | ||
await new FixtureRunner(buyMembershipHappyCaseFixture).run() | ||
const [memberId] = buyMembershipHappyCaseFixture.getCreatedMembers() | ||
const updateProfileHappyCaseFixture = new UpdateProfileHappyCaseFixture(api, query, { | ||
account, | ||
memberId, | ||
}) | ||
await new FixtureRunner(updateProfileHappyCaseFixture).runWithQueryNodeChecks() | ||
|
||
let oldValues: MemberProfileData = generateParamsFromAccountId(account) | ||
for (const newValues of updates) { | ||
const context = { account, memberId } | ||
const updateProfileHappyCaseFixture = new UpdateProfileHappyCaseFixture(api, query, context, oldValues, newValues) | ||
await new FixtureRunner(updateProfileHappyCaseFixture).runWithQueryNodeChecks() | ||
oldValues = updateProfileHappyCaseFixture.getExpectedValues() | ||
} | ||
|
||
debug('Done') | ||
} |