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

Commit

Permalink
Merge branch 'main' of https://github.com/graasp/graasp-builder into …
Browse files Browse the repository at this point in the history
…729-fix-duplicate-membership
  • Loading branch information
LinaYahya committed Jan 18, 2024
2 parents 23c23d2 + 1f18249 commit c19e8f2
Show file tree
Hide file tree
Showing 42 changed files with 3,245 additions and 1,662 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.4.1](https://github.com/graasp/graasp-builder/compare/v2.4.0...v2.4.1) (2024-01-11)


### Bug Fixes

* **ar:** update ([#942](https://github.com/graasp/graasp-builder/issues/942)) ([54efe96](https://github.com/graasp/graasp-builder/commit/54efe961ea41acdb7d34876199877558834d8b4e))
* **deps:** update dependency @sentry/react to v7.93.0 ([#927](https://github.com/graasp/graasp-builder/issues/927)) ([f16a0d4](https://github.com/graasp/graasp-builder/commit/f16a0d462b234a74ce721bd34fdb8ea44948fc85))
* **de:** update ([#938](https://github.com/graasp/graasp-builder/issues/938)) ([dedc367](https://github.com/graasp/graasp-builder/commit/dedc3679d3a8d15cb28dcf98a8bc548ef2b4203f))
* **es:** add spanish ([#937](https://github.com/graasp/graasp-builder/issues/937)) ([e84c78b](https://github.com/graasp/graasp-builder/commit/e84c78b2918218c9aeac584d80025dcd7df1c385))
* fix reorder in table ([#944](https://github.com/graasp/graasp-builder/issues/944)) ([7b1adb7](https://github.com/graasp/graasp-builder/commit/7b1adb79e42f0683379a1be90b6a0b09032d9a69))
* **fr:** update ([#940](https://github.com/graasp/graasp-builder/issues/940)) ([55f6f76](https://github.com/graasp/graasp-builder/commit/55f6f76ab7f8b713ee9715ae9f439d9e2c8bbaa8))
* **it:** update ([#939](https://github.com/graasp/graasp-builder/issues/939)) ([6050742](https://github.com/graasp/graasp-builder/commit/6050742a229f72a0340f2ca8bcb39bb7f74f7b45))

## [2.4.0](https://github.com/graasp/graasp-builder/compare/v2.3.1...v2.4.0) (2023-12-22)


Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/item/copy/gridCopyItem.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
HOME_MODAL_ITEM_ID,
ITEM_MENU_COPY_BUTTON_CLASS,
TREE_MODAL_MY_ITEMS_ID,
buildItemCard,
buildItemMenu,
buildItemMenuButtonId,
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('Copy Item in Grid', () => {

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[2];
const toItemPath = TREE_MODAL_MY_ITEMS_ID;
const toItemPath = HOME_MODAL_ITEM_ID;
copyItem({ id: copyItemId, toItemPath });

cy.wait('@copyItems').then(({ request: { url } }) => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/item/copy/listCopyItem.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
buildItemPath,
} from '../../../../src/config/paths';
import {
HOME_MODAL_ITEM_ID,
ITEM_MENU_COPY_BUTTON_CLASS,
TREE_MODAL_MY_ITEMS_ID,
TREE_MODAL_SHARED_ITEMS_ID,
buildItemMenu,
buildItemMenuButtonId,
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Copy Item in List', () => {

// copy
const { id: copyItemId } = SAMPLE_ITEMS.items[2];
copyItem({ id: copyItemId, toItemPath: TREE_MODAL_MY_ITEMS_ID });
copyItem({ id: copyItemId, toItemPath: HOME_MODAL_ITEM_ID });

cy.wait('@copyItems').then(({ request: { url } }) => {
expect(url).to.contain(copyItemId);
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/item/copy/listCopyMultiple.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
HOME_MODAL_ITEM_ID,
ITEMS_TABLE_COPY_SELECTED_ITEMS_ID,
TREE_MODAL_MY_ITEMS_ID,
buildItemsTableRowIdAttribute,
} from '../../../../src/config/selectors';
import ITEM_LAYOUT_MODES from '../../../../src/enums/itemLayoutModes';
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('Copy items in List', () => {

// copy
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
copyItems({ itemIds, toItemPath: TREE_MODAL_MY_ITEMS_ID });
copyItems({ itemIds, toItemPath: HOME_MODAL_ITEM_ID });

cy.wait('@copyItems').then(({ request: { url } }) => {
itemIds.forEach((id) => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/item/home/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('Home', () => {
);

// visit child
const { id: childChildId } = SAMPLE_ITEMS.items[2];
const { id: childChildId } = SAMPLE_ITEMS.items[3];
cy.goToItemInGrid(childChildId);

// expect no children
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('Home', () => {
});

// visit child
const { id: childChildId } = SAMPLE_ITEMS.items[2];
const { id: childChildId } = SAMPLE_ITEMS.items[3];
cy.goToItemInList(childChildId);

// expect no children
Expand Down
8 changes: 3 additions & 5 deletions cypress/e2e/item/move/gridMoveItem.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
ITEM_MENU_MOVE_BUTTON_CLASS,
TREE_MODAL_MY_ITEMS_ID,
buildItemMenu,
buildItemMenuButtonId,
} from '../../../../src/config/selectors';
Expand All @@ -21,7 +20,7 @@ const moveItem = ({
`#${buildItemMenu(movedItemId)} .${ITEM_MENU_MOVE_BUTTON_CLASS}`,
).click();

cy.fillTreeModal(toItemPath);
cy.handleTreeMenu(toItemPath);
};

describe('Move Item in Grid', () => {
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('Move Item in Grid', () => {

// move
const { id: movedItem } = SAMPLE_ITEMS.items[2];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[3];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[1];
moveItem({ id: movedItem, toItemPath });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
Expand All @@ -70,8 +69,7 @@ describe('Move Item in Grid', () => {

// move
const { id: movedItem } = SAMPLE_ITEMS.items[2];
const toItem = TREE_MODAL_MY_ITEMS_ID;
moveItem({ id: movedItem, toItemPath: toItem });
moveItem({ id: movedItem, toItemPath: 'selectionModalMyGraasp' });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
expect(body.parentId).to.equal(undefined);
Expand Down
59 changes: 48 additions & 11 deletions cypress/e2e/item/move/listMoveItem.cy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
ITEM_MENU_MOVE_BUTTON_CLASS,
TREE_MODAL_MY_ITEMS_ID,
buildItemMenu,
buildItemMenuButtonId,
buildItemRowArrowId,
buildNavigationModalItemId,
} from '../../../../src/config/selectors';
import { ITEM_LAYOUT_MODES } from '../../../../src/enums';
import { SAMPLE_ITEMS } from '../../../fixtures/items';
import { TABLE_ITEM_RENDER_TIME } from '../../../support/constants';

const openMoveModal = ({ id: movedItemId }: { id: string }) => {
const menuSelector = `#${buildItemMenuButtonId(movedItemId)}`;
cy.wait(TABLE_ITEM_RENDER_TIME);
cy.get(menuSelector).click();
cy.get(
`#${buildItemMenu(movedItemId)} .${ITEM_MENU_MOVE_BUTTON_CLASS}`,
).click();
};

const moveItem = ({
id: movedItemId,
toItemPath,
Expand All @@ -18,14 +28,9 @@ const moveItem = ({
toItemPath: string;
rootId?: string;
}) => {
const menuSelector = `#${buildItemMenuButtonId(movedItemId)}`;
cy.wait(TABLE_ITEM_RENDER_TIME);
cy.get(menuSelector).click();
cy.get(
`#${buildItemMenu(movedItemId)} .${ITEM_MENU_MOVE_BUTTON_CLASS}`,
).click();
openMoveModal({ id: movedItemId });

cy.fillTreeModal(toItemPath, rootId);
cy.handleTreeMenu(toItemPath, rootId);
};

describe('Move Item in List', () => {
Expand Down Expand Up @@ -57,7 +62,7 @@ describe('Move Item in List', () => {

// move
const { id: movedItem } = SAMPLE_ITEMS.items[2];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[3];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[1];
moveItem({ id: movedItem, toItemPath });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
Expand All @@ -66,6 +71,39 @@ describe('Move Item in List', () => {
});
});

it('cannot move inside self children', () => {
cy.setUpApi(SAMPLE_ITEMS);
const { id } = SAMPLE_ITEMS.items[0];

// go to children item
cy.visit(buildItemPath(id));

cy.switchMode(ITEM_LAYOUT_MODES.LIST);

const { id: movedItemId } = SAMPLE_ITEMS.items[2];
const parentId = SAMPLE_ITEMS.items[0].id;
const childId = SAMPLE_ITEMS.items[6].id;
openMoveModal({ id: movedItemId });
// parent is disabled
cy.get(`#${buildNavigationModalItemId(parentId)} button`).should(
'be.disabled',
);
cy.get(`#${buildNavigationModalItemId(parentId)}`).trigger('mouseover');
cy.get(`#${buildItemRowArrowId(parentId)}`).click();

// self is disabled
cy.get(`#${buildNavigationModalItemId(movedItemId)} button`).should(
'be.disabled',
);
cy.get(`#${buildNavigationModalItemId(movedItemId)}`).trigger('mouseover');
cy.get(`#${buildItemRowArrowId(movedItemId)}`).click();

// inner child is disabled
cy.get(`#${buildNavigationModalItemId(childId)} button`).should(
'be.disabled',
);
});

it('move item to Home', () => {
cy.setUpApi(SAMPLE_ITEMS);
const { id } = SAMPLE_ITEMS.items[0];
Expand All @@ -77,8 +115,7 @@ describe('Move Item in List', () => {

// move
const { id: movedItem } = SAMPLE_ITEMS.items[2];
const toItem = TREE_MODAL_MY_ITEMS_ID;
moveItem({ id: movedItem, toItemPath: toItem });
moveItem({ id: movedItem, toItemPath: 'selectionModalMyGraasp' });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
expect(body.parentId).to.equal(undefined);
Expand Down
8 changes: 3 additions & 5 deletions cypress/e2e/item/move/listMoveMultiple.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
ITEMS_TABLE_MOVE_SELECTED_ITEMS_ID,
TREE_MODAL_MY_ITEMS_ID,
buildItemsTableRowIdAttribute,
} from '../../../../src/config/selectors';
import { ITEM_LAYOUT_MODES } from '../../../../src/enums';
Expand All @@ -23,7 +22,7 @@ const moveItems = ({

cy.wait(TABLE_ITEM_RENDER_TIME);
cy.get(`#${ITEMS_TABLE_MOVE_SELECTED_ITEMS_ID}`).click();
cy.fillTreeModal(toItemPath);
cy.handleTreeMenu(toItemPath);
};

describe('Move Items in List', () => {
Expand Down Expand Up @@ -55,7 +54,7 @@ describe('Move Items in List', () => {

// move
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[3];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[1];
moveItems({ itemIds, toItemPath });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
Expand All @@ -75,8 +74,7 @@ describe('Move Items in List', () => {

// move
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
const toItem = TREE_MODAL_MY_ITEMS_ID;
moveItems({ itemIds, toItemPath: toItem });
moveItems({ itemIds, toItemPath: 'selectionModalMyGraasp' });

cy.wait('@moveItems').then(({ request: { body, url } }) => {
expect(body.parentId).to.equal(undefined);
Expand Down
28 changes: 28 additions & 0 deletions cypress/fixtures/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const sampleItems: DiscriminatedItem[] = [
settings: {
hasThumbnail: false,
},
extra: {
[ItemType.FOLDER]: {
childrenOrder: ['fdf09f5a-5688-11eb-ae93-0242ac130004'],
},
},
},
{
...DEFAULT_FOLDER_ITEM,
Expand Down Expand Up @@ -99,6 +104,15 @@ const sampleItems: DiscriminatedItem[] = [
hasThumbnail: false,
},
},
{
...DEFAULT_FOLDER_ITEM,
id: 'eef09f5a-5688-11eb-ae93-0242ac130003',
name: 'own_item_name7',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003.eef09f5a_5688_11eb_ae93_0242ac130003',
settings: {
hasThumbnail: false,
},
},
];
export const SAMPLE_ITEMS: ApiConfig = {
items: [
Expand Down Expand Up @@ -195,6 +209,20 @@ export const SAMPLE_ITEMS: ApiConfig = {
},
],
},
{
...sampleItems[6],
memberships: [
{
item: sampleItems[6],
permission: PermissionLevel.Admin,
member: MEMBERS.ANNA,
creator: MEMBERS.ANNA,
createdAt: '2021-08-11T12:56:36.834Z',
updatedAt: '2021-08-11T12:56:36.834Z',
id: '2dd4caf9-538a-317a-86d3-99432b223c12',
},
],
},
],
// memberships: [],
};
Expand Down
42 changes: 39 additions & 3 deletions cypress/support/commands/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CUSTOM_APP_CYPRESS_ID,
CUSTOM_APP_URL_ID,
FOLDER_FORM_DESCRIPTION_ID,
HOME_MODAL_ITEM_ID,
ITEM_FORM_APP_URL_ID,
ITEM_FORM_CONFIRM_BUTTON_ID,
ITEM_FORM_DOCUMENT_TEXT_SELECTOR,
Expand All @@ -13,8 +14,9 @@ import {
SHARE_ITEM_EMAIL_INPUT_ID,
SHARE_ITEM_SHARE_BUTTON_ID,
TREE_MODAL_CONFIRM_BUTTON_ID,
TREE_MODAL_MY_ITEMS_ID,
buildItemFormAppOptionId,
buildItemRowArrowId,
buildNavigationModalItemId,
buildPermissionOptionId,
buildTreeItemId,
} from '../../../src/config/selectors';
Expand Down Expand Up @@ -44,9 +46,44 @@ Cypress.Commands.add(
},
);

Cypress.Commands.add(
'handleTreeMenu',
(toItemPath, treeRootId = HOME_MODAL_ITEM_ID) => {
const ids = getParentsIdsFromPath(toItemPath);

cy.wait(TREE_VIEW_PAUSE);

[HOME_MODAL_ITEM_ID, ...ids].forEach((value, idx, array) => {
cy.get(`#${treeRootId}`).then(($tree) => {
// click on the element
if (idx === array.length - 1) {
cy.wrap($tree)
.get(`#${buildNavigationModalItemId(value)}`)
.first()
.click();
}
// if can't find children click on parent (current value)
if (
idx !== array.length - 1 &&
!$tree.find(`#${buildTreeItemId(array[idx + 1], treeRootId)}`).length
) {
cy.wrap($tree)
.get(`#${buildNavigationModalItemId(value)}`)
.trigger('mouseover')
.get(`#${buildItemRowArrowId(value)}`)
.first()
.click();
}
});
});

cy.get(`#${TREE_MODAL_CONFIRM_BUTTON_ID}`).click();
},
);

Cypress.Commands.add(
'fillTreeModal',
(toItemPath, treeRootId = TREE_MODAL_MY_ITEMS_ID) => {
(toItemPath, treeRootId = HOME_MODAL_ITEM_ID) => {
const ids = getParentsIdsFromPath(toItemPath);

cy.wait(TREE_VIEW_PAUSE);
Expand Down Expand Up @@ -83,7 +120,6 @@ Cypress.Commands.add(
cy.get(`#${TREE_MODAL_CONFIRM_BUTTON_ID}`).click();
},
);

Cypress.Commands.add(
'fillBaseItemModal',
({ name = '' }, { confirm = true } = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const REDIRECTION_TIME = 500;
export const CAPTION_EDIT_PAUSE = 2000;

export const ROW_HEIGHT = 48;
export const TABLE_ITEM_RENDER_TIME = 8000;
export const TABLE_ITEM_RENDER_TIME = 7000;
export const TABLE_MEMBERSHIP_RENDER_TIME = 3000;
export const FIXTURES_THUMBNAILS_FOLDER = './thumbnails';
export const CHATBOX_LOADING_TIME = 5000;
Expand Down
Loading

0 comments on commit c19e8f2

Please sign in to comment.