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
feat: display shared items #28
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this tested? Source? I always worry about these regexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can suppose that André has his own schemas and regexes already. Ideally I would like to use those, but for now I need simple checks for tests. And yes note that it is only used in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahgentil, do you have schemas to share?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this PR and create an issue to include schemas in the project.