This repository has been archived by the owner on Jan 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from graasp/16/shareItems
feat: display shared items
- Loading branch information
Showing
32 changed files
with
628 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { PERMISSION_LEVELS } from '../../src/config/constants'; | ||
import { buildItemPath } from '../../src/config/paths'; | ||
import { | ||
buildItemCard, | ||
buildItemMenu, | ||
ITEM_MENU_BUTTON_CLASS, | ||
ITEM_MENU_SHARE_BUTTON_CLASS, | ||
SHARE_ITEM_MODAL_PERMISSION_SELECT_ID, | ||
SHARE_ITEM_MODAL_SHARE_BUTTON_ID, | ||
buildPermissionOptionId, | ||
SHARE_ITEM_MODAL_EMAIL_INPUT_ID, | ||
} from '../../src/config/selectors'; | ||
import { MEMBERS, SIMPLE_ITEMS } from '../fixtures/items'; | ||
|
||
const shareItem = ({ id, member, permission }) => { | ||
const menuSelector = `#${buildItemCard(id)} .${ITEM_MENU_BUTTON_CLASS}`; | ||
cy.get(menuSelector).click(); | ||
cy.get(`#${buildItemMenu(id)} .${ITEM_MENU_SHARE_BUTTON_CLASS}`).click(); | ||
|
||
// select permission | ||
cy.get(`#${SHARE_ITEM_MODAL_PERMISSION_SELECT_ID}`).click(); | ||
cy.get(`#${buildPermissionOptionId(permission)}`).click(); | ||
|
||
// input mail | ||
cy.get(`#${SHARE_ITEM_MODAL_EMAIL_INPUT_ID}`).type(member.email); | ||
|
||
cy.get(`#${SHARE_ITEM_MODAL_SHARE_BUTTON_ID}`).click(); | ||
}; | ||
|
||
describe('Share Item', () => { | ||
it('share item on Home', () => { | ||
cy.setUpApi({ items: SIMPLE_ITEMS, members: Object.values(MEMBERS) }); | ||
cy.visit('/'); | ||
|
||
// share | ||
const { id } = SIMPLE_ITEMS[0]; | ||
const member = MEMBERS.ANNA; | ||
shareItem({ id, member, permission: PERMISSION_LEVELS.WRITE }); | ||
|
||
cy.wait('@shareItem').then(() => { | ||
cy.get(`#${buildItemCard(id)}`).should('exist'); | ||
}); | ||
}); | ||
|
||
it('share item in item', () => { | ||
cy.setUpApi({ items: SIMPLE_ITEMS, members: Object.values(MEMBERS) }); | ||
|
||
// go to children item | ||
cy.visit(buildItemPath(SIMPLE_ITEMS[0].id)); | ||
|
||
// share | ||
const { id } = SIMPLE_ITEMS[2]; | ||
const member = MEMBERS.ANNA; | ||
shareItem({ id, member, permission: PERMISSION_LEVELS.READ }); | ||
|
||
cy.wait('@shareItem').then(() => { | ||
cy.get(`#${buildItemCard(id)}`).should('exist'); | ||
}); | ||
}); | ||
|
||
// todo : check item permission for users | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// use simple id format for tests | ||
export const ID_FORMAT = '[a-z0-9-]*'; | ||
|
||
export const ERROR_CODE = 400; | ||
export const SUCCESS_CODE = 200; | ||
|
||
export const parseStringToRegExp = (string) => string.replaceAll('?', '\\?'); | ||
|
||
export const EMAIL_FORMAT = '[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.