diff --git a/cypress/e2e/item/create/createLink.cy.ts b/cypress/e2e/item/create/createLink.cy.ts index aaf66b910..288eec87c 100644 --- a/cypress/e2e/item/create/createLink.cy.ts +++ b/cypress/e2e/item/create/createLink.cy.ts @@ -6,6 +6,7 @@ import { GRAASP_LINK_ITEM, GRAASP_LINK_ITEM_NO_PROTOCOL, INVALID_LINK_ITEM, + LINK_ITEM_WITH_BLANK_NAME, } from '../../../fixtures/links'; import { CREATE_ITEM_PAUSE } from '../../../support/constants'; import { createLink } from '../../../support/createUtils'; @@ -86,5 +87,25 @@ describe('Create Link', () => { true, ); }); + + it('cannot have an empty name', () => { + const FOLDER = PackedFolderItemFactory(); + cy.setUpApi({ items: [FOLDER] }); + const { id } = FOLDER; + + // go to children item + cy.visit(buildItemPath(id)); + + // create + createLink(LINK_ITEM_WITH_BLANK_NAME, { + confirm: false, + }); + + cy.get(`#${ITEM_FORM_CONFIRM_BUTTON_ID}`).should( + 'have.prop', + 'disabled', + true, + ); + }); }); }); diff --git a/cypress/fixtures/links.ts b/cypress/fixtures/links.ts index bb3f62187..e34f60245 100644 --- a/cypress/fixtures/links.ts +++ b/cypress/fixtures/links.ts @@ -71,3 +71,15 @@ export const INVALID_LINK_ITEM: LinkItemType = PackedLinkItemFactory({ icons: [], }), }); + +export const LINK_ITEM_WITH_BLANK_NAME: LinkItemType = PackedLinkItemFactory({ + creator: CURRENT_USER, + name: '', + description: 'a description for graasp youtube link', + extra: buildLinkExtra({ + url: 'https://www.youtube.com/watch?v=FmiEgBMTPLo', + html: '', + thumbnails: [], + icons: [], + }), +}); diff --git a/src/components/item/form/link/LinkForm.tsx b/src/components/item/form/link/LinkForm.tsx index 07203d0fb..9ef232b3d 100644 --- a/src/components/item/form/link/LinkForm.tsx +++ b/src/components/item/form/link/LinkForm.tsx @@ -182,7 +182,7 @@ const LinkForm = ({