Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
feat: use packed item (#1140)
Browse files Browse the repository at this point in the history
* feat: use packed, remove shared item route

* refactor: remove tags

refactor: update tests

test: update tests

refactor: fix tests

refactor: fix tests

refactor: fix tests

refactor: refactor test

fix(test): update flacky tags and viewLink tests

fix(test): update itemSettings and thumbnail test

fix(test): remove not checked test in Analytics for item settings

fix(test): remove only in itemSettings test

fix(test): remove WS test of deleted WS events

feat: upgrade deps

fix: fix issues during rebase

fix(test): update path of THUMBNAIL_MEDIUM_PATH

* fix: pass item id to LinkItem of new UI version

feat: update deps

feat: remove only in tests

feat: remove only

* fix(test): add hasThumbnail setting in viewThumbnails test to fix flacky test

* fix(test): add public tag in items to fix public and published tests

---------

Co-authored-by: Thibault Reidy <thibault.reidy@hotmail.ch>
  • Loading branch information
pyphilia and ReidyT authored May 7, 2024
1 parent 78123af commit 65ea828
Show file tree
Hide file tree
Showing 114 changed files with 1,796 additions and 2,839 deletions.
45 changes: 9 additions & 36 deletions cypress/e2e/authentication.cy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { CookieKeys } from '@graasp/sdk';
import { CookieKeys, PackedFolderItemFactory } from '@graasp/sdk';

import {
HOME_PATH,
ITEMS_PATH,
REDIRECT_PATH,
SHARED_ITEMS_PATH,
buildItemPath,
} from '../../src/config/paths';
import {
CREATE_ITEM_BUTTON_ID,
HEADER_APP_BAR_ID,
ITEM_MAIN_CLASS,
} from '../../src/config/selectors';
import { SAMPLE_ITEMS } from '../fixtures/items';
import { HEADER_APP_BAR_ID, ITEM_MAIN_CLASS } from '../../src/config/selectors';
import {
REDIRECTION_TIME,
REQUEST_FAILURE_LOADING_TIME,
Expand All @@ -22,7 +16,7 @@ import { SIGN_IN_PATH } from '../support/paths';
describe('Authentication', () => {
describe('Signed Off > Redirect to sign in route', () => {
beforeEach(() => {
cy.setUpApi({ ...SAMPLE_ITEMS, currentMember: null });
cy.setUpApi({ currentMember: null });
});
it('Home', () => {
cy.visit(HOME_PATH);
Expand All @@ -31,32 +25,22 @@ describe('Authentication', () => {
timeout: REQUEST_FAILURE_LOADING_TIME,
}).should('have.property', 'value', HOME_PATH);
});
it('Shared Items', () => {
cy.visit(SHARED_ITEMS_PATH);
cy.url().should('include', SIGN_IN_PATH);
cy.getCookie(CookieKeys.RedirectUrl, {
timeout: REQUEST_FAILURE_LOADING_TIME,
}).should('have.property', 'value', SHARED_ITEMS_PATH);
});
});

describe('Signed In', () => {
const ENV = { items: [PackedFolderItemFactory()] };

beforeEach(() => {
cy.setUpApi(SAMPLE_ITEMS);
cy.setUpApi(ENV);
});

describe('Load page correctly', () => {
it('Home', () => {
cy.visit(HOME_PATH);
cy.get(`#${HEADER_APP_BAR_ID}`).should('exist');
});
it('Shared Items', () => {
cy.visit(SHARED_ITEMS_PATH);
cy.get(`#${HEADER_APP_BAR_ID}`).should('exist');
cy.get(`#${CREATE_ITEM_BUTTON_ID}`).should('not.exist');
});
it('Item', () => {
cy.visit(buildItemPath(SAMPLE_ITEMS.items?.[0].id));
cy.visit(buildItemPath(ENV.items[0].id));
cy.get(`#${HEADER_APP_BAR_ID}`).should('exist');
cy.get(`.${ITEM_MAIN_CLASS}`).should('exist');
});
Expand All @@ -79,23 +63,12 @@ describe('Authentication', () => {
}).should('include', ITEMS_PATH);
});

it('SharedItems', () => {
cy.setCookie(CookieKeys.RedirectUrl, SHARED_ITEMS_PATH);
cy.visit(REDIRECT_PATH);
cy.url({
timeout: REDIRECTION_TIME,
}).should('include', SHARED_ITEMS_PATH);
});

it('Item', () => {
cy.setCookie(
CookieKeys.RedirectUrl,
buildItemPath(SAMPLE_ITEMS.items?.[0].id),
);
cy.setCookie(CookieKeys.RedirectUrl, buildItemPath(ENV.items[0].id));
cy.visit(REDIRECT_PATH);
cy.url({ timeout: REDIRECTION_TIME }).should(
'include',
buildItemPath(SAMPLE_ITEMS.items?.[0].id),
buildItemPath(ENV.items[0].id),
);
});
});
Expand Down
35 changes: 24 additions & 11 deletions cypress/e2e/invitations/createInvitation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PermissionLevel } from '@graasp/sdk';
import { PackedFolderItemFactory, PermissionLevel } from '@graasp/sdk';

import { buildItemPath } from '../../../src/config/paths';
import {
Expand All @@ -7,7 +7,6 @@ import {
SHARE_ITEM_SHARE_BUTTON_ID,
buildShareButtonId,
} from '../../../src/config/selectors';
import { SAMPLE_ITEMS } from '../../fixtures/items';
import { MEMBERS } from '../../fixtures/members';

const inviteItem = ({
Expand All @@ -33,9 +32,10 @@ const inviteItem = ({

describe('Create Invitation', () => {
it('invite one new member', () => {
cy.setUpApi({ ...SAMPLE_ITEMS, members: Object.values(MEMBERS) });
const items = [PackedFolderItemFactory()];
cy.setUpApi({ items, members: Object.values(MEMBERS) });

const id = SAMPLE_ITEMS.items?.[0].id;
const { id } = items[0];
cy.visit(buildItemPath(id));

// invite
Expand All @@ -55,24 +55,37 @@ describe('Create Invitation', () => {
});

it('cannot invite member with membership', () => {
cy.setUpApi({ ...SAMPLE_ITEMS, members: Object.values(MEMBERS) });
const item = PackedFolderItemFactory({ creator: MEMBERS.ANNA });
const items = [
{
...item,
memberships: [
{
item,
member: MEMBERS.ANNA,
permission: PermissionLevel.Admin,
},
],
},
];
cy.setUpApi({ items, members: Object.values(MEMBERS) });

// go to child item
const { id } = SAMPLE_ITEMS.items[1];
const { id } = items[0];
cy.visit(buildItemPath(id));

// invite
// person to invite
const { email } = MEMBERS.ANNA;
const permission = PermissionLevel.Read;
inviteItem({ id, email, permission });
inviteItem({ id, email, permission: PermissionLevel.Read });

cy.get(`#${SHARE_ITEM_SHARE_BUTTON_ID}`).should('be.disabled');
});

it('cannot invite with invalid data', () => {
cy.setUpApi({ ...SAMPLE_ITEMS, members: Object.values(MEMBERS) });
const items = [PackedFolderItemFactory()];
cy.setUpApi({ items, members: Object.values(MEMBERS) });

const { id } = SAMPLE_ITEMS.items[0];
const { id } = items[0];
cy.visit(buildItemPath(id));

// invite
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/invitations/viewInvitation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

describe('View Invitations', () => {
beforeEach(() => {
cy.setUpApi({ ...ITEMS_WITH_INVITATIONS });
cy.setUpApi(ITEMS_WITH_INVITATIONS);
});

it('view invitation in share item modal', () => {
Expand Down
16 changes: 13 additions & 3 deletions cypress/e2e/item/apps/apps.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { ItemType, PackedAppItemFactory } from '@graasp/sdk';

import { buildItemPath } from '../../../../src/config/paths';
import { APP_USING_CONTEXT_ITEM } from '../../../fixtures/apps';
import { buildAppItemLinkForTest } from '../../../fixtures/apps';

const APP = PackedAppItemFactory({
extra: {
[ItemType.APP]: {
url: `${Cypress.env('VITE_GRAASP_API_HOST')}/${buildAppItemLinkForTest('app.html')}`,
},
},
});

describe('Apps', () => {
it('App should request context', () => {
const { id, name } = APP_USING_CONTEXT_ITEM;
cy.setUpApi({ items: [APP_USING_CONTEXT_ITEM] });
const { id, name } = APP;
cy.setUpApi({ items: [APP] });
cy.visit(buildItemPath(id));

cy.wait(2000);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
PackedFolderItemFactory,
PackedItemBookmarkFactory,
} from '@graasp/sdk';

import i18n from '../../../../src/config/i18n';
import { BOOKMARKED_ITEMS_PATH, HOME_PATH } from '../../../../src/config/paths';
import {
Expand All @@ -8,10 +13,18 @@ import {
buildItemMenuButtonId,
buildItemsTableRowIdAttribute,
} from '../../../../src/config/selectors';
import { SAMPLE_BOOKMARK, SAMPLE_ITEMS } from '../../../fixtures/items';
import { CURRENT_USER } from '../../../fixtures/members';

const BOOKMARKED_ITEMS = [
PackedItemBookmarkFactory(),
PackedItemBookmarkFactory(),
];
const ITEMS = BOOKMARKED_ITEMS.map(({ item }) => item);
const NON_BOOKMARKED_ITEM = PackedFolderItemFactory();

const toggleBookmarkButton = (itemId: string) => {
// todo: remove when refactoring the table
cy.wait(500);
cy.get(`#${buildItemMenuButtonId(itemId)}`).click();
cy.get(`#${buildItemMenu(itemId)} .${BOOKMARKED_ITEM_BUTTON_CLASS}`).click();
};
Expand All @@ -20,7 +33,8 @@ describe('Bookmarked Item', () => {
describe('Member has no bookmarked items', () => {
beforeEach(() => {
cy.setUpApi({
...SAMPLE_ITEMS,
items: ITEMS,
bookmarkedItems: BOOKMARKED_ITEMS,
});
cy.visit(BOOKMARKED_ITEMS_PATH);
});
Expand All @@ -33,8 +47,8 @@ describe('Bookmarked Item', () => {
describe('Member has several valid bookmarked items', () => {
beforeEach(() => {
cy.setUpApi({
...SAMPLE_ITEMS,
bookmarkedItems: SAMPLE_BOOKMARK,
items: [...ITEMS, NON_BOOKMARKED_ITEM],
bookmarkedItems: BOOKMARKED_ITEMS,
});
i18n.changeLanguage(CURRENT_USER.extra.lang as string);
cy.visit(HOME_PATH);
Expand All @@ -45,8 +59,8 @@ describe('Bookmarked Item', () => {
cy.get(`#${CREATE_ITEM_BUTTON_ID}`).should('not.exist');
});

it('add item to bookmarkeds', () => {
const item = SAMPLE_ITEMS.items[0];
it('add item to bookmarks', () => {
const item = NON_BOOKMARKED_ITEM;

toggleBookmarkButton(item.id);

Expand All @@ -55,8 +69,8 @@ describe('Bookmarked Item', () => {
});
});

it('remove item from bookmarkeds', () => {
const itemId = SAMPLE_ITEMS.items[1].id;
it('remove item from bookmarks', () => {
const itemId = ITEMS[1].id;

toggleBookmarkButton(itemId);

Expand All @@ -68,7 +82,7 @@ describe('Bookmarked Item', () => {
it('check bookmarked items view', () => {
cy.visit(BOOKMARKED_ITEMS_PATH);

const itemId = SAMPLE_ITEMS.items[1].id;
const itemId = ITEMS[1].id;

cy.get(buildItemsTableRowIdAttribute(itemId)).should('exist');
});
Expand All @@ -77,7 +91,7 @@ describe('Bookmarked Item', () => {
describe('Error Handling', () => {
it('check bookmarked items view with server error', () => {
cy.setUpApi({
...SAMPLE_ITEMS,
items: ITEMS,
getFavoriteError: true,
});
cy.visit(BOOKMARKED_ITEMS_PATH);
Expand Down
14 changes: 8 additions & 6 deletions cypress/e2e/item/chatbox/chatbox.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MockWebSocket } from '@graasp/query-client';
import { PackedFolderItemFactory } from '@graasp/sdk';

import { v4 } from 'uuid';

Expand All @@ -8,10 +9,7 @@ import {
CHATBOX_INPUT_BOX_ID,
ITEM_CHATBOX_BUTTON_ID,
} from '../../../../src/config/selectors';
import {
ITEM_WITHOUT_CHATBOX_MESSAGES,
ITEM_WITH_CHATBOX_MESSAGES,
} from '../../../fixtures/chatbox';
import { ITEM_WITH_CHATBOX_MESSAGES } from '../../../fixtures/chatbox';
import { CURRENT_USER, MEMBERS } from '../../../fixtures/members';
import { CHATBOX_LOADING_TIME } from '../../../support/constants';

Expand Down Expand Up @@ -79,8 +77,12 @@ describe('Chatbox Scenarios', () => {
});

it('Receive messages in chatbox from websockets', () => {
const item = ITEM_WITHOUT_CHATBOX_MESSAGES;
cy.visitAndMockWs(buildItemPath(item.id), { items: [item] }, client);
const item = PackedFolderItemFactory();
cy.visitAndMockWs(
buildItemPath(item.id),
{ items: [item], members: [MEMBERS] },
client,
);

openChatbox();

Expand Down
Loading

0 comments on commit 65ea828

Please sign in to comment.