environments/review-follow-has-4jhse4/deployments/3360
commit
da6be7ba4c
@ -0,0 +1,20 @@
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useDeleteEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks';
|
||||
|
||||
import type { Group } from 'soapbox/schemas';
|
||||
|
||||
function useDeleteGroupStatus(group: Group, statusId: string) {
|
||||
const api = useApi();
|
||||
const { deleteEntity, isSubmitting } = useDeleteEntity(
|
||||
Entities.STATUSES,
|
||||
() => api.delete(`/api/v1/groups/${group.id}/statuses/${statusId}`),
|
||||
);
|
||||
|
||||
return {
|
||||
mutate: deleteEntity,
|
||||
isSubmitting,
|
||||
};
|
||||
}
|
||||
|
||||
export { useDeleteGroupStatus };
|
@ -1,24 +0,0 @@
|
||||
import React, { useCallback } from 'react';
|
||||
|
||||
import GroupCard from 'soapbox/components/group-card';
|
||||
import { useAppSelector } from 'soapbox/hooks';
|
||||
import { makeGetGroup } from 'soapbox/selectors';
|
||||
|
||||
interface IGroupContainer {
|
||||
id: string
|
||||
}
|
||||
|
||||
const GroupContainer: React.FC<IGroupContainer> = (props) => {
|
||||
const { id, ...rest } = props;
|
||||
|
||||
const getGroup = useCallback(makeGetGroup(), []);
|
||||
const group = useAppSelector(state => getGroup(state, id));
|
||||
|
||||
if (group) {
|
||||
return <GroupCard group={group} {...rest} />;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default GroupContainer;
|
@ -1,58 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import { getSettings } from 'soapbox/actions/settings';
|
||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||
import { normalizeAd, normalizeCard } from 'soapbox/normalizers';
|
||||
|
||||
import type { AdProvider } from '.';
|
||||
|
||||
/** Rumble ad API entity. */
|
||||
interface RumbleAd {
|
||||
type: number
|
||||
impression: string
|
||||
click: string
|
||||
asset: string
|
||||
expires: number
|
||||
}
|
||||
|
||||
/** Response from Rumble ad server. */
|
||||
interface RumbleApiResponse {
|
||||
count: number
|
||||
ads: RumbleAd[]
|
||||
}
|
||||
|
||||
/** Provides ads from Soapbox Config. */
|
||||
const RumbleAdProvider: AdProvider = {
|
||||
getAds: async(getState) => {
|
||||
const state = getState();
|
||||
const settings = getSettings(state);
|
||||
const soapboxConfig = getSoapboxConfig(state);
|
||||
const endpoint = soapboxConfig.extensions.getIn(['ads', 'endpoint']) as string | undefined;
|
||||
|
||||
if (endpoint) {
|
||||
try {
|
||||
const { data } = await axios.get<RumbleApiResponse>(endpoint, {
|
||||
headers: {
|
||||
'Accept-Language': settings.get('locale', '*') as string,
|
||||
},
|
||||
});
|
||||
|
||||
return data.ads.map(item => normalizeAd({
|
||||
impression: item.impression,
|
||||
card: normalizeCard({
|
||||
type: item.type === 1 ? 'link' : 'rich',
|
||||
image: item.asset,
|
||||
url: item.click,
|
||||
}),
|
||||
expires_at: new Date(item.expires * 1000),
|
||||
}));
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
};
|
||||
|
||||
export default RumbleAdProvider;
|
@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
|
||||
import { buildGroup } from 'soapbox/jest/factory';
|
||||
import { render, screen } from 'soapbox/jest/test-helpers';
|
||||
import { Group } from 'soapbox/types/entities';
|
||||
|
||||
import GroupHeader from '../group-header';
|
||||
|
||||
let group: Group;
|
||||
|
||||
describe('<GroupHeader />', () => {
|
||||
describe('without a group', () => {
|
||||
it('should render the blankslate', () => {
|
||||
render(<GroupHeader group={null} />);
|
||||
expect(screen.getByTestId('group-header-missing')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the Group has been deleted', () => {
|
||||
it('only shows name, header, and avatar', () => {
|
||||
group = buildGroup({ display_name: 'my group', deleted_at: new Date().toISOString() });
|
||||
render(<GroupHeader group={group} />);
|
||||
|
||||
expect(screen.queryAllByTestId('group-header-missing')).toHaveLength(0);
|
||||
expect(screen.queryAllByTestId('group-actions')).toHaveLength(0);
|
||||
expect(screen.queryAllByTestId('group-meta')).toHaveLength(0);
|
||||
expect(screen.getByTestId('group-header-image')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('group-avatar')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('group-name')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with a valid Group', () => {
|
||||
it('only shows all fields', () => {
|
||||
group = buildGroup({ display_name: 'my group', deleted_at: null });
|
||||
render(<GroupHeader group={group} />);
|
||||
|
||||
expect(screen.queryAllByTestId('group-header-missing')).toHaveLength(0);
|
||||
expect(screen.getByTestId('group-actions')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('group-meta')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('group-header-image')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('group-avatar')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('group-name')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,320 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
|
||||
import { __stub } from 'soapbox/api';
|
||||
import { buildGroup, buildGroupMember, buildGroupRelationship } from 'soapbox/jest/factory';
|
||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
import { GroupRoles } from 'soapbox/schemas/group-member';
|
||||
|
||||
import GroupMemberListItem from '../group-member-list-item';
|
||||
|
||||
describe('<GroupMemberListItem />', () => {
|
||||
describe('account rendering', () => {
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember({}, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should render the users avatar', async () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship(),
|
||||
});
|
||||
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('group-member-list-item')).toHaveTextContent(groupMember.account.display_name);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('role badge', () => {
|
||||
const accountId = '4';
|
||||
const group = buildGroup();
|
||||
|
||||
describe('when the user is an Owner', () => {
|
||||
const groupMember = buildGroupMember({ role: GroupRoles.OWNER }, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should render the correct badge', async () => {
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('role-badge')).toHaveTextContent('owner');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the user is an Admin', () => {
|
||||
const groupMember = buildGroupMember({ role: GroupRoles.ADMIN }, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should render the correct badge', async () => {
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('role-badge')).toHaveTextContent('admin');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the user is an User', () => {
|
||||
const groupMember = buildGroupMember({ role: GroupRoles.USER }, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should render no correct badge', async () => {
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryAllByTestId('role-badge')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('as a Group owner', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.OWNER,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
|
||||
describe('when the user has role of "user"', () => {
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember({}, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
username: 'tiger',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when "canPromoteToAdmin is true', () => {
|
||||
it('should render dropdown with correct Owner actions', async () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(async() => {
|
||||
await user.click(screen.getByTestId('icon-button'));
|
||||
});
|
||||
|
||||
const dropdownMenu = screen.getByTestId('dropdown-menu');
|
||||
expect(dropdownMenu).toHaveTextContent('Assign admin role');
|
||||
expect(dropdownMenu).toHaveTextContent('Kick @tiger from group');
|
||||
expect(dropdownMenu).toHaveTextContent('Ban from group');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when "canPromoteToAdmin is false', () => {
|
||||
it('should prevent promoting user to Admin', async () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin={false} />);
|
||||
|
||||
await waitFor(async() => {
|
||||
await user.click(screen.getByTestId('icon-button'));
|
||||
await user.click(screen.getByTitle('Assign admin role'));
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('toast')).toHaveTextContent('Admin limit reached');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the user has role of "admin"', () => {
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember(
|
||||
{
|
||||
role: GroupRoles.ADMIN,
|
||||
},
|
||||
{
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
username: 'tiger',
|
||||
},
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should render dropdown with correct Owner actions', async () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(async() => {
|
||||
await user.click(screen.getByTestId('icon-button'));
|
||||
});
|
||||
|
||||
const dropdownMenu = screen.getByTestId('dropdown-menu');
|
||||
expect(dropdownMenu).toHaveTextContent('Remove admin role');
|
||||
expect(dropdownMenu).toHaveTextContent('Kick @tiger from group');
|
||||
expect(dropdownMenu).toHaveTextContent('Ban from group');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('as a Group admin', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.ADMIN,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
|
||||
describe('when the user has role of "user"', () => {
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember({}, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
username: 'tiger',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should render dropdown with correct Admin actions', async () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(async() => {
|
||||
await user.click(screen.getByTestId('icon-button'));
|
||||
});
|
||||
|
||||
const dropdownMenu = screen.getByTestId('dropdown-menu');
|
||||
expect(dropdownMenu).not.toHaveTextContent('Assign admin role');
|
||||
expect(dropdownMenu).toHaveTextContent('Kick @tiger from group');
|
||||
expect(dropdownMenu).toHaveTextContent('Ban from group');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the user has role of "admin"', () => {
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember(
|
||||
{
|
||||
role: GroupRoles.ADMIN,
|
||||
},
|
||||
{
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
username: 'tiger',
|
||||
},
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render the dropdown', async () => {
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(async() => {
|
||||
expect(screen.queryAllByTestId('icon-button')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the user has role of "owner"', () => {
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember(
|
||||
{
|
||||
role: GroupRoles.OWNER,
|
||||
},
|
||||
{
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
username: 'tiger',
|
||||
},
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render the dropdown', async () => {
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(async() => {
|
||||
expect(screen.queryAllByTestId('icon-button')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('as a Group user', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.USER,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
const accountId = '4';
|
||||
const groupMember = buildGroupMember({}, {
|
||||
id: accountId,
|
||||
display_name: 'tiger woods',
|
||||
username: 'tiger',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet(`/api/v1/accounts/${accountId}`).reply(200, groupMember.account);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render the dropdown', async () => {
|
||||
render(<GroupMemberListItem group={group} member={groupMember} canPromoteToAdmin />);
|
||||
|
||||
await waitFor(async() => {
|
||||
expect(screen.queryAllByTestId('icon-button')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,123 @@
|
||||
import React from 'react';
|
||||
|
||||
import { buildGroup, buildGroupTag, buildGroupRelationship } from 'soapbox/jest/factory';
|
||||
import { render, screen } from 'soapbox/jest/test-helpers';
|
||||
import { GroupRoles } from 'soapbox/schemas/group-member';
|
||||
|
||||
import GroupTagListItem from '../group-tag-list-item';
|
||||
|
||||
describe('<GroupTagListItem />', () => {
|
||||
describe('tag name', () => {
|
||||
const name = 'hello';
|
||||
|
||||
it('should render the tag name', () => {
|
||||
const group = buildGroup();
|
||||
const tag = buildGroupTag({ name });
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
|
||||
expect(screen.getByTestId('group-tag-list-item')).toHaveTextContent(`#${name}`);
|
||||
});
|
||||
|
||||
describe('when the tag is "visible"', () => {
|
||||
const group = buildGroup();
|
||||
const tag = buildGroupTag({ name, visible: true });
|
||||
|
||||
it('renders the default name', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.getByTestId('group-tag-name')).toHaveClass('text-gray-900');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the tag is not "visible" and user is Owner', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.OWNER,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
const tag = buildGroupTag({
|
||||
name,
|
||||
visible: false,
|
||||
});
|
||||
|
||||
it('renders the subtle name', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.getByTestId('group-tag-name')).toHaveClass('text-gray-400');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the tag is not "visible" and user is Admin or User', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.ADMIN,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
const tag = buildGroupTag({
|
||||
name,
|
||||
visible: false,
|
||||
});
|
||||
|
||||
it('renders the subtle name', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.getByTestId('group-tag-name')).toHaveClass('text-gray-900');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('pinning', () => {
|
||||
describe('as an owner', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.OWNER,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
|
||||
describe('when the tag is visible', () => {
|
||||
const tag = buildGroupTag({ visible: true });
|
||||
|
||||
it('renders the pin icon', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.getByTestId('pin-icon')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the tag is not visible', () => {
|
||||
const tag = buildGroupTag({ visible: false });
|
||||
|
||||
it('does not render the pin icon', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.queryAllByTestId('pin-icon')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('as a non-owner', () => {
|
||||
const group = buildGroup({
|
||||
relationship: buildGroupRelationship({
|
||||
role: GroupRoles.ADMIN,
|
||||
member: true,
|
||||
}),
|
||||
});
|
||||
|
||||
describe('when the tag is visible', () => {
|
||||
const tag = buildGroupTag({ visible: true });
|
||||
|
||||
it('does not render the pin icon', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.queryAllByTestId('pin-icon')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the tag is not visible', () => {
|
||||
const tag = buildGroupTag({ visible: false });
|
||||
|
||||
it('does not render the pin icon', () => {
|
||||
render(<GroupTagListItem group={group} tag={tag} isPinnable />);
|
||||
expect(screen.queryAllByTestId('pin-icon')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,33 +1,88 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import {
|
||||
groupSchema,
|
||||
accountSchema,
|
||||
adSchema,
|
||||
cardSchema,
|
||||
groupMemberSchema,
|
||||
groupRelationshipSchema,
|
||||
groupSchema,
|
||||
groupTagSchema,
|
||||
relationshipSchema,
|
||||
type Account,
|
||||
type Ad,
|
||||
type Card,
|
||||
type Group,
|
||||
type GroupMember,
|
||||
type GroupRelationship,
|
||||
type GroupTag,
|
||||
type Relationship,
|
||||
} from 'soapbox/schemas';
|
||||
import { GroupRoles } from 'soapbox/schemas/group-member';
|
||||
|
||||
// TODO: there's probably a better way to create these factory functions.
|
||||
// This looks promising but didn't work on my first attempt: https://github.com/anatine/zod-plugins/tree/main/packages/zod-mock
|
||||
|
||||
function buildGroup(props: Record<string, any> = {}): Group {
|
||||
function buildAccount(props: Partial<Account> = {}): Account {
|
||||
return accountSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildCard(props: Partial<Card> = {}): Card {
|
||||
return cardSchema.parse(Object.assign({
|
||||
url: 'https://soapbox.test',
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildGroup(props: Partial<Group> = {}): Group {
|
||||
return groupSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildGroupRelationship(props: Record<string, any> = {}): GroupRelationship {
|
||||
function buildGroupRelationship(props: Partial<GroupRelationship> = {}): GroupRelationship {
|
||||
return groupRelationshipSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildGroupTag(props: Record<string, any> = {}): GroupTag {
|
||||
function buildGroupTag(props: Partial<GroupTag> = {}): GroupTag {
|
||||
return groupTagSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
name: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildGroupMember(
|
||||
props: Partial<GroupMember> = {},
|
||||
accountProps: Partial<Account> = {},
|
||||
): GroupMember {
|
||||
return groupMemberSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
account: buildAccount(accountProps),
|
||||
role: GroupRoles.USER,
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildAd(props: Partial<Ad> = {}): Ad {
|
||||
return adSchema.parse(Object.assign({
|
||||
card: buildCard(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildRelationship(props: Partial<Relationship> = {}): Relationship {
|
||||
return relationshipSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
export { buildGroup, buildGroupRelationship, buildGroupTag };
|
||||
export {
|
||||
buildAd,
|
||||
buildCard,
|
||||
buildGroup,
|
||||
buildGroupMember,
|
||||
buildGroupRelationship,
|
||||
buildGroupTag,
|
||||
buildRelationship,
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue