Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cypress/e2e/builder/fixtures/apps.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
AppItemType,
FolderItemType,
PackedAppItemFactory,
PackedFolderItemFactory,
} from '@graasp/sdk';

import { AppItem } from '@/openapi/client';

import { APPS_LIST } from '../../../fixtures/apps/apps';
import { CURRENT_MEMBER } from '../../../fixtures/members';

Expand All @@ -15,14 +16,14 @@ export const buildGetAppData = (id: string): string =>
export const buildAppItemLinkForTest = (filename = '.*'): string =>
`apps/${filename}`;

export const GRAASP_APP_ITEM: AppItemType = PackedAppItemFactory({
export const GRAASP_APP_ITEM: AppItem = PackedAppItemFactory({
name: 'test app',
extra: {
app: { url: APPS_LIST[0].url },
},
creator: CURRENT_MEMBER,
});
export const GRAASP_CUSTOM_APP_ITEM: AppItemType = PackedAppItemFactory({
export const GRAASP_CUSTOM_APP_ITEM: AppItem = PackedAppItemFactory({
name: 'Add Your Custom App',
extra: {
app: { url: APPS_LIST[0].url },
Expand All @@ -36,7 +37,7 @@ export const GRAASP_APP_PARENT_FOLDER: FolderItemType = PackedFolderItemFactory(
},
);

export const GRAASP_APP_CHILDREN_ITEM: AppItemType = PackedAppItemFactory({
export const GRAASP_APP_CHILDREN_ITEM: AppItem = PackedAppItemFactory({
name: 'my app',
extra: {
app: {
Expand Down
15 changes: 8 additions & 7 deletions cypress/e2e/builder/fixtures/chatbox.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
ChatMention,
DiscriminatedItem,
FolderItemFactory,
FolderItemType,
MentionStatus,
PackedFolderItemFactory,
} from '@graasp/sdk';

import type { FolderItem, PackedItem } from '@/openapi/client';

import { DEFAULT_FOLDER_ITEM } from '../../../fixtures/items';
import { CURRENT_MEMBER, MEMBERS } from '../../../fixtures/members';
import { ItemForTest } from '../../../support/types';

const item: FolderItemType = FolderItemFactory({
const item: FolderItem = FolderItemFactory({
...DEFAULT_FOLDER_ITEM,
id: 'adf09f5a-5688-11eb-ae93-0242ac130004',
path: 'adf09f5a_5688_11eb_ae93_0242ac130004',
Expand All @@ -22,7 +22,8 @@ const item: FolderItemType = FolderItemFactory({

// warning: permission admin by default
export const ITEM_WITH_CHATBOX_MESSAGES: ItemForTest = {
...PackedFolderItemFactory(item),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...PackedFolderItemFactory(item as any),
memberships: [
{
item,
Expand Down Expand Up @@ -54,13 +55,13 @@ export const ITEM_WITH_CHATBOX_MESSAGES: ItemForTest = {
],
};

const items: DiscriminatedItem[] = [
{
const items = [
PackedFolderItemFactory({
...DEFAULT_FOLDER_ITEM,
id: '78ad1166-3862-4593-a10c-d380e7b66674',
path: '78ad1166-3862-4593-a10c-d380e7b66674',
name: 'item with chatbox messages',
},
}) as PackedItem,
];

const ITEM_WITH_CHATBOX_MESSAGES_AND_ADMIN: ItemForTest = {
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/builder/fixtures/files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
FileItemFactory,
MaxWidth,
MimeTypes,
PackedFileItemFactory,
Expand Down Expand Up @@ -41,7 +40,7 @@ export const IMAGE_ITEM_DEFAULT: FileItemForTest = {
};

export const IMAGE_ITEM_DEFAULT_WITH_MAX_WIDTH: FileItemForTest = {
...FileItemFactory({
...PackedFileItemFactory({
id: 'bd5519a2-5ba9-4305-b221-185facbe6a29',
name: 'icon.png',
description: 'a default image description',
Expand Down
36 changes: 15 additions & 21 deletions cypress/e2e/builder/fixtures/invitations.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import {
DiscriminatedItem,
Invitation,
PackedFolderItemFactory,
} from '@graasp/sdk';
import { PackedFolderItemFactory } from '@graasp/sdk';

import { v4 } from 'uuid';

import type { PermissionLevel } from '@/openapi/client';
import type {
GenericItem,
Invitation,
PackedItem,
PermissionLevel,
} from '@/openapi/client';

import { MEMBERS } from '../../../fixtures/members';
import { ApiConfig } from '../../../support/types';

export const buildInvitation = (args: {
item: DiscriminatedItem;
item: GenericItem;
email?: string;
permission?: PermissionLevel;
}): Invitation => {
Expand All @@ -24,32 +25,30 @@ export const buildInvitation = (args: {
permission: permission ?? 'read',
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
item,
};
};

// warning: default permission admin
const itemsWithInvitations: DiscriminatedItem[] = [
const itemsWithInvitations = [
PackedFolderItemFactory({
id: 'bcafbd2a-5688-11eb-ae93-0242ac130002',
name: 'parent',
path: 'bcafbd2a_5688_11eb_ae93_0242ac130002',
}),
}) as PackedItem,
PackedFolderItemFactory({
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002',
name: 'own_item_name1',
creator: MEMBERS.BOB,
path: 'bcafbd2a_5688_11eb_ae93_0242ac130002.ecafbd2a_5688_11eb_ae93_0242ac130002',
}),
}) as PackedItem,
];

export const ITEMS_WITH_INVITATIONS = {
items: [
{ ...itemsWithInvitations[0], permission: 'admin' },
itemsWithInvitations[0],
{
...itemsWithInvitations[1],
permission: 'admin',

// for tests only
memberships: [
Expand Down Expand Up @@ -80,7 +79,6 @@ export const ITEMS_WITH_INVITATIONS = {
email: MEMBERS.BOB.email,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
},
{
id: 'ecafbd1a-5688-11eb-be93-0242ac130006',
Expand All @@ -89,7 +87,6 @@ export const ITEMS_WITH_INVITATIONS = {
email: MEMBERS.CEDRIC.email,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
},
{
id: 'ecbfbd2a-5688-11eb-be93-0242ac130007',
Expand All @@ -98,7 +95,6 @@ export const ITEMS_WITH_INVITATIONS = {
email: MEMBERS.DAVID.email,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
},
] as const,
},
Expand All @@ -107,22 +103,22 @@ export const ITEMS_WITH_INVITATIONS = {
} as const satisfies ApiConfig;

// warning: default permission admin
const itemsWithInvitationsWriteAccess: DiscriminatedItem[] = [
const itemsWithInvitationsWriteAccess = [
PackedFolderItemFactory(
{
id: 'bcafbd2a-5688-11eb-ae93-0242ac130002',
path: 'bcafbd2a_5688_11eb_ae93_0242ac130002',
},
{ permission: 'write' },
),
) as PackedItem,
PackedFolderItemFactory(
{
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002',
creator: MEMBERS.BOB,
path: 'bcafbd2a_5688_11eb_ae93_0242ac130002.ecafbd2a_5688_11eb_ae93_0242ac130002',
},
{ permission: 'write' },
),
) as PackedItem,
];
export const ITEM_WITH_INVITATIONS_WRITE_ACCESS: ApiConfig = {
items: [
Expand All @@ -149,7 +145,6 @@ export const ITEM_WITH_INVITATIONS_WRITE_ACCESS: ApiConfig = {
email: MEMBERS.CEDRIC.email,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
},
{
id: 'ecafbd1a-5688-11eb-be93-0242ac130006',
Expand All @@ -158,7 +153,6 @@ export const ITEM_WITH_INVITATIONS_WRITE_ACCESS: ApiConfig = {
email: MEMBERS.DAVID.email,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
},
],
},
Expand Down
14 changes: 6 additions & 8 deletions cypress/e2e/builder/fixtures/items.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
DiscriminatedItem,
ItemValidation,
ItemValidationGroup,
ItemValidationProcess,
ItemValidationStatus,
PackedItem,
PackedFolderItemFactory,
} from '@graasp/sdk';

import type { ItemValidationGroup, PackedItem } from '@/openapi/client';

import { DEFAULT_FOLDER_ITEM } from '../../../fixtures/items';
import { MEMBERS } from '../../../fixtures/members';
import { ApiConfig, ItemForTest } from '../../../support/types';
Expand All @@ -19,12 +19,11 @@ export const generateOwnItems = (number: number): ItemForTest[] => {
const path = (i: number) => id(i).replaceAll('-', '_');

return new Array(number).fill(null).map((_, i) => {
const item = {
...DEFAULT_FOLDER_ITEM,
const item = PackedFolderItemFactory({
id: id(i),
name: `item ${i}`,
path: path(i),
};
}) as PackedItem;

const paddedI = `${i}`.padStart(12, '0');
const mId = `dafebabe-dead-beef-1234-${paddedI}`;
Expand Down Expand Up @@ -230,12 +229,11 @@ export const PublishedItemFactory = (
item: itemToPublish,
createdAt: new Date().toISOString(),
creator: itemToPublish.creator,
totalViews: 0,
},
});

export const ItemValidationGroupFactory = (
validatedItem: DiscriminatedItem,
validatedItem: PackedItem,
{
status = ItemValidationStatus.Success,
isOutDated = false,
Expand Down
27 changes: 10 additions & 17 deletions cypress/e2e/builder/fixtures/links.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import {
LinkItemType,
PackedLinkItemFactory,
buildLinkExtra,
} from '@graasp/sdk';
import { PackedLinkItemFactory, buildLinkExtra } from '@graasp/sdk';

import { CURRENT_MEMBER } from '../../../fixtures/members';

export const GRAASP_LINK_ITEM: LinkItemType = PackedLinkItemFactory({
export const GRAASP_LINK_ITEM = PackedLinkItemFactory({
creator: CURRENT_MEMBER,
extra: buildLinkExtra({
url: 'https://graasp.eu',
Expand All @@ -18,19 +14,16 @@ export const GRAASP_LINK_ITEM: LinkItemType = PackedLinkItemFactory({
}),
});

export const GRAASP_LINK_ITEM_IFRAME_ONLY: LinkItemType = PackedLinkItemFactory(
{
...GRAASP_LINK_ITEM,
id: 'ecafbd2a-5688-11eb-ae91-0242ac130122',
settings: {
showLinkIframe: true,
showLinkButton: false,
},
export const GRAASP_LINK_ITEM_IFRAME_ONLY = PackedLinkItemFactory({
...GRAASP_LINK_ITEM,
id: 'ecafbd2a-5688-11eb-ae91-0242ac130122',
settings: {
showLinkIframe: true,
showLinkButton: false,
},
);
});

export const YOUTUBE_LINK_ITEM: LinkItemType = PackedLinkItemFactory({
type: 'embeddedLink',
export const YOUTUBE_LINK_ITEM = PackedLinkItemFactory({
name: 'graasp youtube link',
description: 'a description for graasp youtube link',
creator: CURRENT_MEMBER,
Expand Down
13 changes: 8 additions & 5 deletions cypress/e2e/builder/fixtures/memberships.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import {
Account,
DiscriminatedItem,
ItemMembership,
Member,
MemberFactory,
PackedFolderItemFactory,
} from '@graasp/sdk';

import { v4 } from 'uuid';

import type { PermissionLevel } from '@/openapi/client';
import type {
GenericItem,
ItemMembership,
PackedItem,
PermissionLevel,
} from '@/openapi/client';

import { MEMBERS } from '../../../fixtures/members';
import { ApiConfig } from '../../../support/types';

export const buildItemMembership = (args: {
permission?: PermissionLevel;
item: DiscriminatedItem;
item: GenericItem;
account: Partial<Account>;
creator?: Member;
}): ItemMembership => ({
Expand All @@ -29,7 +32,7 @@ export const buildItemMembership = (args: {
id: v4(),
});

const sampleItems: DiscriminatedItem[] = [
const sampleItems: PackedItem[] = [
PackedFolderItemFactory({
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002',
name: 'own_item_name1',
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/builder/fixtures/validations.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
DiscriminatedItem,
ItemValidation,
ItemValidationGroup,
ItemValidationProcess,
ItemValidationStatus,
} from '@graasp/sdk';

import type { ItemValidationGroup, PackedItem } from '@/openapi/client';

import { ApiConfig } from '../../../support/types';
import { SAMPLE_PUBLIC_ITEMS } from './items';

export const VALIDATED_ITEM: DiscriminatedItem = {
export const VALIDATED_ITEM: PackedItem = {
...SAMPLE_PUBLIC_ITEMS.items[0],
updatedAt: '2019-07-27T07:45:00Z',
};
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/builder/invitations/createInvitation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PackedFolderItemFactory } from '@graasp/sdk';

import type { PermissionLevel } from '@/openapi/client';
import type { PackedItem, PermissionLevel } from '@/openapi/client';

import {
CREATE_MEMBERSHIP_FORM_ID,
Expand Down Expand Up @@ -57,7 +57,9 @@ describe('Create Invitation', () => {
});

it('cannot invite member with membership', () => {
const item = PackedFolderItemFactory({ creator: MEMBERS.ANNA });
const item = PackedFolderItemFactory({
creator: MEMBERS.ANNA,
}) as PackedItem;
const items = [
{
...item,
Expand Down
Loading