Skip to content

Commit

Permalink
feat: validate name as a required value (#1368)
Browse files Browse the repository at this point in the history
* feat: validate name as a required value

* fix: typo

* fixup! feat: validate name as a required value

---------

Co-authored-by: spaenleh <[email protected]>
  • Loading branch information
LinaYahya and spaenleh authored Jul 24, 2024
1 parent 4d395aa commit d46dd8a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
21 changes: 21 additions & 0 deletions cypress/e2e/item/create/createLink.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
);
});
});
});
12 changes: 12 additions & 0 deletions cypress/fixtures/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
}),
});
2 changes: 1 addition & 1 deletion src/components/item/form/link/LinkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const LinkForm = ({
<NameForm
item={item}
autoFocus={false}
required={false}
required
setChanges={onChange}
updatedProperties={updatedProperties}
/>
Expand Down

0 comments on commit d46dd8a

Please sign in to comment.