-
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.
feat: add, edit and delete memberships from settings
- Loading branch information
Showing
42 changed files
with
1,073 additions
and
533 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
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
50 changes: 0 additions & 50 deletions
50
cypress/integration/memberships/create/gridShareItem.spec.js
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
cypress/integration/memberships/create/listShareItem.spec.js
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
cypress/integration/memberships/createItemMembership.spec.js
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,32 @@ | ||
import { PERMISSION_LEVELS } from '../../../src/enums'; | ||
import { buildItemPath } from '../../../src/config/paths'; | ||
import { ITEM_SETTINGS_BUTTON_CLASS } from '../../../src/config/selectors'; | ||
import { SAMPLE_ITEMS } from '../../fixtures/items'; | ||
import { MEMBERS } from '../../fixtures/members'; | ||
|
||
const shareItem = ({ member, permission }) => { | ||
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click(); | ||
|
||
cy.fillShareForm({ member, permission }); | ||
}; | ||
|
||
describe('Create Membership', () => { | ||
it('share item from settings', () => { | ||
cy.setUpApi({ ...SAMPLE_ITEMS, members: Object.values(MEMBERS) }); | ||
|
||
// go to children item | ||
const { id } = SAMPLE_ITEMS.items[0]; | ||
cy.visit(buildItemPath(id)); | ||
|
||
// share | ||
const member = MEMBERS.ANNA; | ||
const permission = PERMISSION_LEVELS.READ; | ||
shareItem({ id, member, permission }); | ||
|
||
cy.wait('@shareItem').then(({ request: { url, body } }) => { | ||
expect(url).to.contain(id); | ||
expect(body?.permission).to.equal(permission); | ||
expect(body?.memberId).to.equal(member.id); | ||
}); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
cypress/integration/memberships/deleteItemMembership.spec.js
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,29 @@ | ||
import { buildItemPath } from '../../../src/config/paths'; | ||
import { | ||
buildItemMembershipRowDeleteButtonId, | ||
ITEM_SETTINGS_BUTTON_CLASS, | ||
} from '../../../src/config/selectors'; | ||
import { ITEMS_WITH_MEMBERSHIPS } from '../../fixtures/memberships'; | ||
|
||
const deleteItemMembership = (id) => { | ||
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click(); | ||
cy.get(`#${buildItemMembershipRowDeleteButtonId(id)}`).click(); | ||
}; | ||
|
||
describe('Delete Membership', () => { | ||
it('delete item membership', () => { | ||
cy.setUpApi({ ...ITEMS_WITH_MEMBERSHIPS }); | ||
|
||
// go to children item | ||
const { id, memberships } = ITEMS_WITH_MEMBERSHIPS.items[0]; | ||
cy.visit(buildItemPath(id)); | ||
|
||
// share | ||
const { id: mId } = memberships[1]; | ||
deleteItemMembership(mId); | ||
|
||
cy.wait('@deleteItemMembership').then(({ request: { url } }) => { | ||
expect(url).to.contain(mId); | ||
}); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
cypress/integration/memberships/editItemMembership.spec.js
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,40 @@ | ||
import { PERMISSION_LEVELS } from '../../../src/enums'; | ||
import { buildItemPath } from '../../../src/config/paths'; | ||
import { | ||
buildItemMembershipRowId, | ||
buildPermissionOptionId, | ||
ITEM_MEMBERSHIP_PERMISSION_SELECT_CLASS, | ||
ITEM_SETTINGS_BUTTON_CLASS, | ||
} from '../../../src/config/selectors'; | ||
import { ITEMS_WITH_MEMBERSHIPS } from '../../fixtures/memberships'; | ||
|
||
const editItemMembership = ({ id, permission }) => { | ||
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click(); | ||
const select = cy.get( | ||
`#${buildItemMembershipRowId( | ||
id, | ||
)} .${ITEM_MEMBERSHIP_PERMISSION_SELECT_CLASS}`, | ||
); | ||
select.click(); | ||
select.get(`#${buildPermissionOptionId(permission)}`).click(); | ||
}; | ||
|
||
describe('Edit Membership', () => { | ||
it('edit item membership', () => { | ||
cy.setUpApi({ ...ITEMS_WITH_MEMBERSHIPS }); | ||
|
||
// go to children item | ||
const { id, memberships } = ITEMS_WITH_MEMBERSHIPS.items[0]; | ||
cy.visit(buildItemPath(id)); | ||
|
||
// update membership | ||
const permission = PERMISSION_LEVELS.READ; | ||
const { id: mId } = memberships[1]; | ||
editItemMembership({ id: mId, permission }); | ||
|
||
cy.wait('@editItemMembership').then(({ request: { url, body } }) => { | ||
expect(url).to.contain(mId); | ||
expect(body?.permission).to.equal(permission); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.