Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cypress/e2e/account/homePage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestHelper {
{
method: HttpMethod.Get,
url: new RegExp(
`${API_HOST}/members/${ID_FORMAT}/avatar/(original|large|medium|small)\\?replyUrl\\=true`,
String.raw`${API_HOST}/members/${ID_FORMAT}/avatar/(original|large|medium|small)\?replyUrl\=true`,
),
},
({ reply }) => {
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/account/settings/storage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ describe('Storage files', () => {
const numberPages = Math.ceil(files.length / filesPerPage);

for (let i = 1; i <= numberPages; i += 1) {
const currentNbOfFiles =
files.length > i * filesPerPage ? i * filesPerPage : files.length;
const currentNbOfFiles = Math.min(files.length, i * filesPerPage);
cy.get('tbody tr').should('have.length', currentNbOfFiles);

files.slice(0, currentNbOfFiles).forEach((file, fileIndex) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,17 @@ import { addItemLoginSchema } from './utils';
const ALERT_BUTTON = `[role="alert"] button`;
const DIALOG_SELECTOR = `[role="dialog"]`;

const checkItemLoginSetting = ({
mode,
disabled = false,
}: {
mode: string;
disabled?: boolean;
}) => {
if (!disabled) {
cy.get(`#${SHARE_ITEM_PSEUDONYMIZED_SCHEMA_ID} + input`).should(
'have.value',
mode,
);
} else {
cy.get(`#${SHARE_ITEM_PSEUDONYMIZED_SCHEMA_ID}`).then((el) => {
// test classnames are 'disabled'
expect(el.parent().html()).to.contain('disabled');
});
}
const checkItemLoginSettingIsEnabled = ({ mode }: { mode: string }) => {
cy.get(`#${SHARE_ITEM_PSEUDONYMIZED_SCHEMA_ID} + input`).should(
'have.value',
mode,
);
};
const checkItemLoginSettingIsDisabled = () => {
cy.get(`#${SHARE_ITEM_PSEUDONYMIZED_SCHEMA_ID}`).then((el) => {
// test classnames are 'disabled'
expect(el.parent().html()).to.contain('disabled');
});
};

const editItemLoginSetting = (mode: string) => {
Expand Down Expand Up @@ -77,18 +70,15 @@ describe('Item Login', () => {
cy.visit(buildItemPath(item.id));
cy.get(`#${buildShareButtonId(item.id)}`).click();

checkItemLoginSetting({
checkItemLoginSettingIsEnabled({
mode: ItemLoginSchemaType.Username,
});
editItemLoginSetting(ItemLoginSchemaType.UsernameAndPassword);

// disabled at child level
cy.visit(buildItemPath(child.id));
cy.get(`#${buildShareButtonId(child.id)}`).click();
checkItemLoginSetting({
mode: ItemLoginSchemaType.UsernameAndPassword,
disabled: true,
});
checkItemLoginSettingIsDisabled();
});

it('read permission', () => {
Expand Down
27 changes: 14 additions & 13 deletions cypress/e2e/builder/item/edit/editLink.cy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { HttpMethod, PackedLinkItemFactory, buildLinkExtra } from '@graasp/sdk';

import {
ACCESSIBLE_ITEMS_TABLE_ID,
EDIT_ITEM_BUTTON_CLASS,
EDIT_ITEM_MODAL_CANCEL_BUTTON_ID,
EDIT_MODAL_ID,
ITEM_FORM_CONFIRM_BUTTON_ID,
ITEM_FORM_LINK_INPUT_ID,
ITEM_FORM_NAME_INPUT_ID,
ITEM_MAIN_CLASS,
TEXT_EDITOR_CLASS,
buildDataCyWrapper,
buildEditButtonId,
buildItemMenuDataCy,
ACCESSIBLE_ITEMS_TABLE_ID,
EDIT_ITEM_BUTTON_CLASS,
EDIT_ITEM_MODAL_CANCEL_BUTTON_ID,
EDIT_MODAL_ID,
ITEM_FORM_CONFIRM_BUTTON_ID,
ITEM_FORM_LINK_INPUT_ID,
ITEM_FORM_NAME_INPUT_ID,
ITEM_MAIN_CLASS,
TEXT_EDITOR_CLASS,
buildDataCyWrapper,
buildEditButtonId,
buildItemMenuDataCy,
} from '../../../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../../../fixtures/members';
import { EDIT_ITEM_PAUSE } from '../../../../support/constants';
Expand Down Expand Up @@ -124,7 +124,8 @@ describe('Edit Link', () => {
cy.get(buildDataCyWrapper(buildItemMenuDataCy(itemToEdit.id))).click();
editItemLink({
...itemToEdit,
...{ name: newName, url: newUrl },
name: newName,
url: newUrl,
});

cy.wait('@editItemLink').then(
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/builder/item/order/reorderItems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Order Items', () => {
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/children`),
url: new RegExp(String.raw`${API_HOST}/items/${ID_FORMAT}/children`),
},
({ reply }) => reply(orderedItems),
).as('getChildren');
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/builder/memberships/editItemMembership.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
buildPermissionOptionId,
buildShareButtonId,
} from '../../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../../fixtures/members';
import { MEMBERS } from '../../../fixtures/members';
import { CURRENT_MEMBER, MEMBERS } from '../../../fixtures/members';
import { ItemForTest } from '../../../support/types';
import { ITEMS_WITH_MEMBERSHIPS } from '../fixtures/memberships';
import { buildItemPath, buildItemSharePath } from '../utils';
Expand Down
36 changes: 9 additions & 27 deletions cypress/e2e/player/shuffle.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [2, 4, 1, 3, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -112,9 +110,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [2, 4, 1, 3, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -151,9 +147,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [2, 4, 1, 3, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -191,9 +185,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [1, 4, 3, 2, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -244,9 +236,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [1, 2, 3, 4, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -285,9 +275,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [3, 4, 2, 1, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -340,9 +328,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [3, 2, 1, 4, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -380,9 +366,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [3, 2, 1, 4, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down Expand Up @@ -423,9 +407,7 @@ describe.skip('Shuffle', () => {
const shuffledOrder = [3, 4, 1, 2, 5];

// last should always be last
expect(shuffledOrder[shuffledOrder.length - 1]).to.equal(
shuffledOrder.length,
);
expect(shuffledOrder.at(-1)).to.equal(shuffledOrder.length);

cy.get(`.${buildTreeItemClass(root.id)}`)
.siblings(`ul.${TREE_NODE_GROUP_CLASS}:first`)
Expand Down
2 changes: 1 addition & 1 deletion cypress/fixtures/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export const generateLotsOfFoldersOnHome = ({
creator?: ItemForTest['creator'];
memberships?: ItemForTest['memberships'];
}): ItemForTest[] =>
Array.from(Array(folderCount)).map(() => {
Array.from(new Array(folderCount)).map(() => {
const itemId = v4();
return {
...DEFAULT_FOLDER_ITEM,
Expand Down
22 changes: 14 additions & 8 deletions cypress/support/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export const mockPutItemLoginSchema = (
cy.intercept(
{
method: HttpMethod.Put,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/login-schema$`),
url: new RegExp(String.raw`${API_HOST}/items/${ID_FORMAT}/login-schema$`),
},
({ reply }) => {
if (shouldThrowError) {
Expand All @@ -336,7 +336,7 @@ export const mockDeleteItemLoginSchema = (): void => {
cy.intercept(
{
method: HttpMethod.Delete,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/login-schema$`),
url: new RegExp(String.raw`${API_HOST}/items/${ID_FORMAT}/login-schema$`),
},
({ reply }) => {
// check query match item login schema
Expand Down Expand Up @@ -372,7 +372,9 @@ export const mockGetItemLoginSchema = (items: ItemForTest[]): void => {
{
method: HttpMethod.Get,
// TODO: use build url
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/login\\-schema$`),
url: new RegExp(
String.raw`${API_HOST}/items/${ID_FORMAT}/login\-schema$`,
),
},
({ reply, url }) => {
const itemId = url.slice(API_HOST.length).split('/')[2];
Expand All @@ -395,7 +397,9 @@ export const mockGetItemLoginSchemaType = (items: ItemForTest[]): void => {
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/login\\-schema\\-type$`),
url: new RegExp(
String.raw`${API_HOST}/items/${ID_FORMAT}/login\-schema\-type$`,
),
},
({ reply, url }) => {
const itemId = url.slice(API_HOST.length).split('/')[2];
Expand Down Expand Up @@ -1197,7 +1201,7 @@ export const mockGetChildren = ({ items }: { items: ItemForTest[] }): void => {
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/children`),
url: new RegExp(String.raw`${API_HOST}/items/${ID_FORMAT}/children`),
},
({ url, reply }) => {
const id = url.slice(API_HOST.length).split('/')[2];
Expand Down Expand Up @@ -1898,7 +1902,7 @@ export const mockGetDescendants = (
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/descendants`),
url: new RegExp(String.raw`${API_HOST}/items/${ID_FORMAT}/descendants`),
},
({ url, reply }) => {
const id = url.slice(API_HOST.length).split('/')[2];
Expand Down Expand Up @@ -2319,7 +2323,9 @@ export const mockGetMembershipRequestsForItem = (
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/memberships/requests$`),
url: new RegExp(
String.raw`${API_HOST}/items/${ID_FORMAT}/memberships/requests$`,
),
},
({ reply, url }) => {
const urlParams = url.split('/');
Expand Down Expand Up @@ -2362,7 +2368,7 @@ export const mockGetItemMembershipsForItem = (
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/${ID_FORMAT}/memberships$`),
url: new RegExp(String.raw`${API_HOST}/items/${ID_FORMAT}/memberships$`),
},
({ reply, url }) => {
const itemId = url.split('/')[4];
Expand Down
8 changes: 6 additions & 2 deletions src/components/chatbox/Chatbox/MessageActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type MouseEvent, useState } from 'react';
import { type JSX, type MouseEvent, useState } from 'react';
import { useTranslation } from 'react-i18next';

import { Delete, Edit, MoreVert } from '@mui/icons-material';
Expand Down Expand Up @@ -36,7 +36,11 @@ const StyledListItemIcon = styled(ListItemIcon)({
},
});

export function MessageActions({ message, isOwn = false, itemId }: Props) {
export function MessageActions({
message,
isOwn = false,
itemId,
}: Readonly<Props>): JSX.Element {
const [menuOpen, setMenuOpen] = useState(false);
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
const { t } = useTranslation(NS.Chatbox);
Expand Down