Skip to content

Commit

Permalink
feat: update for item login (#1407)
Browse files Browse the repository at this point in the history
* feat: update for item login

* refactor: apply changes

* refactor: update

* refactor: fix tests

* refactor: fix tests

* fix: permission table

* fix: update deps

* fix: update deps

* fix: copy tests

* fix: selectors for icons in tests

---------

Co-authored-by: spaenleh <[email protected]>
  • Loading branch information
pyphilia and spaenleh authored Aug 26, 2024
1 parent 1c9da1a commit 3e7f6db
Show file tree
Hide file tree
Showing 49 changed files with 650 additions and 680 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/invitations/createInvitation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const inviteItem = ({
cy.get(`#${buildShareButtonId(id)}`).click();

cy.fillShareForm({
member: { email },
email,
permission,
submit,
selector: `#${CREATE_MEMBERSHIP_FORM_ID}`,
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('Create Invitation', () => {
memberships: [
{
item,
member: MEMBERS.ANNA,
account: MEMBERS.ANNA,
permission: PermissionLevel.Admin,
},
],
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/item/copy/copy.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
COPY_MANY_ITEMS_BUTTON_SELECTOR,
ITEM_MENU_COPY_BUTTON_CLASS,
MY_GRAASP_ITEM_PATH,
buildItemCard,
buildItemsGridMoreButtonSelector,
} from '../../../../src/config/selectors';
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('Copy Item', () => {

// copy
const { id: copyItemId } = FOLDER;
copyItem({ id: copyItemId, toItemPath: MY_GRAASP_ITEM_PATH });
copyItem({ id: copyItemId, toItemPath: '' });

cy.wait('@copyItems').then(({ request: { url } }) => {
cy.get(`#${buildItemCard(copyItemId)}`).should('be.visible');
Expand Down Expand Up @@ -86,8 +85,7 @@ describe('Copy Item', () => {

// copy
const { id } = IMAGE_ITEM_CHILD;
const toItemPath = MY_GRAASP_ITEM_PATH;
copyItem({ id, toItemPath });
copyItem({ id, toItemPath: '' });

cy.wait('@copyItems').then(({ request: { url } }) => {
cy.get(`#${buildItemCard(id)}`).should('exist');
Expand Down Expand Up @@ -139,7 +137,6 @@ describe('Copy Item', () => {
folders.forEach((item) => {
cy.selectItem(item.id);
});

// copy on home
copyItems({ toItemPath: toItem.path });

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/item/hide/hideItem.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const HIDDEN_ITEM: ItemForTest = {
{
item: hiddenItem,
permission: PermissionLevel.Admin,
member: MEMBERS.ANNA,
account: MEMBERS.ANNA,
creator: MEMBERS.ANNA,
id: 'ecbfbd2a-5688-12db-ae93-0242ac130002',
createdAt: '2021-08-11T12:56:36.834Z',
Expand All @@ -32,7 +32,7 @@ const HIDDEN_ITEM: ItemForTest = {
{
item: hiddenItem,
permission: PermissionLevel.Read,
member: MEMBERS.BOB,
account: MEMBERS.BOB,
creator: MEMBERS.ANNA,
id: 'ecbfbd2a-5688-12db-ae93-0242ac130002',
createdAt: '2021-08-11T12:56:36.834Z',
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/item/move/move.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
ITEM_MENU_MOVE_BUTTON_CLASS,
MOVE_MANY_ITEMS_BUTTON_SELECTOR,
MY_GRAASP_ITEM_PATH,
buildItemsGridMoreButtonSelector,
buildNavigationModalItemId,
} from '../../../../src/config/selectors';
Expand Down Expand Up @@ -123,7 +122,7 @@ describe('Move Items', () => {

// move
const { id: movedItem } = CHILD;
moveItem({ id: movedItem, toItemPath: MY_GRAASP_ITEM_PATH });
moveItem({ id: movedItem, toItemPath: '' });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
expect(body.parentId).to.equal(undefined);
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/item/publish/viewPublished.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Published Items', () => {
cy.setUpApi({
items,
publishedItemData,
getPublishedItems: true,
getPublishedItemsError: true,
});
cy.visit(PUBLISHED_ITEMS_PATH);

Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/item/trash/delete.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { PackedRecycledItemDataFactory } from '@graasp/sdk';
import { RECYCLE_BIN_PATH } from '../../../../src/config/paths';
import {
CONFIRM_DELETE_BUTTON_ID,
DELETE_SINGLE_ITEM_BUTTON_SELECTOR,
RECYCLE_BIN_DELETE_MANY_ITEMS_BUTTON_ID,
buildItemCard,
} from '../../../../src/config/selectors';

const deleteItem = (id: string) => {
cy.get(`#${buildItemCard(id)} [data-testid="DeleteIcon"]`).click();
cy.get(`#${buildItemCard(id)} ${DELETE_SINGLE_ITEM_BUTTON_SELECTOR}`).click();
cy.get(`#${CONFIRM_DELETE_BUTTON_ID}`).click();
};

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/item/view/viewDocument.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('View Document', () => {
memberships: [
buildItemMembership({
item: DOCUMENT,
member: CURRENT_USER,
account: CURRENT_USER,
}),
],
},
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/item/view/viewLink.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Links', () => {
memberships: [
buildItemMembership({
item: GRAASP_LINK_ITEM,
member: CURRENT_USER,
account: CURRENT_USER,
}),
],
},
Expand All @@ -26,7 +26,7 @@ describe('Links', () => {
memberships: [
buildItemMembership({
item: GRAASP_LINK_ITEM_IFRAME_ONLY,
member: CURRENT_USER,
account: CURRENT_USER,
}),
],
},
Expand All @@ -35,7 +35,7 @@ describe('Links', () => {
memberships: [
buildItemMembership({
item: YOUTUBE_LINK_ITEM,
member: CURRENT_USER,
account: CURRENT_USER,
}),
],
},
Expand Down
16 changes: 8 additions & 8 deletions cypress/e2e/memberships/createItemMembership.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import { MEMBERS } from '../../fixtures/members';

const shareItem = ({
id,
member,
email,
permission,
submit,
}: {
member: { email: string };
email: string;
permission: PermissionLevel;
submit?: boolean;
id: string;
}) => {
cy.get(`#${buildShareButtonId(id)}`).click();

cy.fillShareForm({
member,
email,
permission,
submit,
selector: `#${CREATE_MEMBERSHIP_FORM_ID}`,
Expand All @@ -50,7 +50,7 @@ describe('Create Membership', () => {
// share
const member = MEMBERS.FANNY;
const permission = PermissionLevel.Read;
shareItem({ id, member, permission });
shareItem({ id, email: member.email, permission });

cy.wait('@postInvitations').then(
({
Expand All @@ -71,7 +71,7 @@ describe('Create Membership', () => {

it('cannot share item twice', () => {
const ITEM = PackedFolderItemFactory();
const member = MEMBERS.ANNA;
const account = MEMBERS.ANNA;
cy.setUpApi({
items: [
{
Expand All @@ -80,7 +80,7 @@ describe('Create Membership', () => {
{
item: ITEM,
permission: PermissionLevel.Read,
member,
account,
},
],
},
Expand All @@ -94,7 +94,7 @@ describe('Create Membership', () => {

// fill
const permission = PermissionLevel.Read;
shareItem({ id, member, permission });
shareItem({ id, email: account.email, permission });

cy.get(`#${SHARE_ITEM_SHARE_BUTTON_ID}`).should('be.disabled');
});
Expand All @@ -108,7 +108,7 @@ describe('Create Membership', () => {

// fill
const permission = PermissionLevel.Read;
shareItem({ id, member: { email: 'wrong' }, permission });
shareItem({ id, email: 'wrong', permission });

cy.get(`#${SHARE_ITEM_SHARE_BUTTON_ID}`).should('be.disabled');
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/memberships/deleteItemMembership.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ describe('Delete Membership', () => {
memberships: [
{
permission: PermissionLevel.Admin,
member: CURRENT_USER,
account: CURRENT_USER,
item,
} as unknown as ItemMembership,
{
permission: PermissionLevel.Read,
member: MEMBERS.BOB,
account: MEMBERS.BOB,
item,
} as unknown as ItemMembership,
],
Expand Down
16 changes: 7 additions & 9 deletions cypress/e2e/memberships/editItemMembership.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ItemMembership,
PackedFolderItemFactory,
PermissionLevel,
} from '@graasp/sdk';
import { PackedFolderItemFactory, PermissionLevel } from '@graasp/sdk';

import { buildItemPath, buildItemSharePath } from '../../../src/config/paths';
import {
Expand Down Expand Up @@ -81,15 +77,17 @@ describe('Edit Membership', () => {
const child: ItemForTest = PackedFolderItemFactory();
const memberships = [
{
id: 'membership-0',
permission: PermissionLevel.Admin,
member: CURRENT_USER,
account: CURRENT_USER,
item: child,
} as unknown as ItemMembership,
},
{
id: 'membership-1',
permission: PermissionLevel.Write,
member: MEMBERS.BOB,
account: MEMBERS.BOB,
item,
} as unknown as ItemMembership,
},
];
const items = [
{
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/memberships/viewMemberships.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ describe('View Memberships', () => {

// panel only contains 2 avatars: one user, one +x
// check contains member avatar
for (const { permission, member, id } of filteredMemberships) {
for (const { permission, account, id } of filteredMemberships) {
const { name, email } = Object.values(MEMBERS).find(
({ id: mId }) => mId === member.id,
({ id: mId }) => mId === account.id,
);
// check name and mail
cy.get(buildItemMembershipRowSelector(id))
Expand Down Expand Up @@ -66,9 +66,9 @@ describe('View Memberships Read-Only Mode', () => {
cy.get(`#${buildShareButtonId(item.id)}`).click();

// check contains member avatar
for (const { permission, member, id } of memberships) {
for (const { permission, account, id } of memberships) {
const { name, email } = Object.values(MEMBERS).find(
({ id: mId }) => mId === member.id,
({ id: mId }) => mId === account.id,
);
// check name, mail and permission
cy.get(buildItemMembershipRowSelector(id))
Expand Down
6 changes: 3 additions & 3 deletions cypress/fixtures/chatbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ITEM_WITH_CHATBOX_MESSAGES: ItemForTest = {
{
item,
permission: PermissionLevel.Write,
member: MEMBERS.ANNA,
account: MEMBERS.ANNA,
creator: MEMBERS.ANNA,
createdAt: '2021-09-11T12:56:36.834Z',
updatedAt: '2021-09-11T12:56:36.834Z',
Expand Down Expand Up @@ -72,7 +72,7 @@ const ITEM_WITH_CHATBOX_MESSAGES_AND_ADMIN: ItemForTest = {
{
item: items[0],
permission: PermissionLevel.Admin,
member: MEMBERS.ANNA,
account: MEMBERS.ANNA,
creator: MEMBERS.ANNA,
createdAt: '2021-08-11T12:56:36.834Z',
id: '78ad2166-3862-4593-a13c-d380e7b66674',
Expand Down Expand Up @@ -110,7 +110,7 @@ export const ITEM_WITHOUT_CHATBOX_MESSAGES: ItemForTest = {
export const SAMPLE_MENTIONS: ChatMention[] = [
{
id: '7062d5e6-a4a0-4828-b4b9-8bc9e21f7abd',
member: CURRENT_USER,
account: CURRENT_USER,
createdAt: '2021-08-11T12:56:36.834Z', // '2022-07-18T07:48:05.008Z',
updatedAt: '2021-08-11T12:56:36.834Z', // '2022-07-18T07:48:05.008Z',
status: MentionStatus.Unread,
Expand Down
6 changes: 3 additions & 3 deletions cypress/fixtures/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const ITEMS_WITH_INVITATIONS: ApiConfig = {
id: 'ecafbd2a-5688-11eb-be93-0242ac130002',
item: itemsWithInvitations[0],
permission: PermissionLevel.Admin,
member: MEMBERS.FANNY,
account: MEMBERS.FANNY,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand All @@ -63,7 +63,7 @@ export const ITEMS_WITH_INVITATIONS: ApiConfig = {
id: 'ecafbd2a-5688-11eb-be93-0212ac130002',
item: itemsWithInvitations[0],
permission: PermissionLevel.Admin,
member: MEMBERS.ANNA,
account: MEMBERS.ANNA,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand Down Expand Up @@ -132,7 +132,7 @@ export const ITEM_WITH_INVITATIONS_WRITE_ACCESS: ApiConfig = {
id: 'ecafbd2a-5688-11eb-be93-0242ac130002',
item: itemsWithInvitationsWriteAccess[0],
permission: PermissionLevel.Write,
member: MEMBERS.ANNA,
account: MEMBERS.ANNA,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand Down
Loading

0 comments on commit 3e7f6db

Please sign in to comment.