-
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.
- Loading branch information
Showing
14 changed files
with
424 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { PERMISSION_LEVELS } from '../../src/enums'; | ||
import { DEFAULT_FOLDER_ITEM } from './items'; | ||
import { CURRENT_USER } from './members'; | ||
|
||
const recycleBinId = 'ecafbd2a-5688-11eb-ae93-1342ac130002'; | ||
|
||
const MEMBER_WITH_RECYCLE_BIN = { | ||
...CURRENT_USER, | ||
extra: { | ||
...CURRENT_USER.extra, | ||
recycleBin: { | ||
itemId: recycleBinId, | ||
}, | ||
}, | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const DATABASE_WITH_RECYCLE_BIN = { | ||
items: [], | ||
recycledItems: [ | ||
{ | ||
...DEFAULT_FOLDER_ITEM, | ||
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002', | ||
name: 'recycled_item_name1', | ||
path: `${recycleBinId}.ecafbd2a_5688_11eb_ae93_0242ac130002`, | ||
extra: {}, | ||
memberships: [ | ||
{ | ||
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002', | ||
permission: PERMISSION_LEVELS.ADMIN, | ||
memberId: MEMBER_WITH_RECYCLE_BIN.id, | ||
}, | ||
], | ||
}, | ||
{ | ||
...DEFAULT_FOLDER_ITEM, | ||
id: 'fdf09f5a-5688-11eb-ae93-0242ac130002', | ||
name: 'recycled_item_name2', | ||
path: `${recycleBinId}.fdf09f5a_5688_11eb_ae93_0242ac130002`, | ||
extra: {}, | ||
memberships: [ | ||
{ | ||
itemPath: 'fdf09f5a-5688-11eb-ae93-0242ac130002', | ||
permission: PERMISSION_LEVELS.ADMIN, | ||
memberId: MEMBER_WITH_RECYCLE_BIN.id, | ||
}, | ||
], | ||
}, | ||
], | ||
currentMember: MEMBER_WITH_RECYCLE_BIN, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { DEFAULT_ITEM_LAYOUT_MODE } from '../../../../src/config/constants'; | ||
import { ITEM_LAYOUT_MODES } from '../../../../src/enums'; | ||
import { buildItemPath, HOME_PATH } from '../../../../src/config/paths'; | ||
import { | ||
buildItemsTableRowId, | ||
CONFIRM_RECYCLE_BUTTON_ID, | ||
ITEM_DELETE_BUTTON_CLASS, | ||
} from '../../../../src/config/selectors'; | ||
import { SAMPLE_ITEMS } from '../../../fixtures/items'; | ||
import { TABLE_ITEM_RENDER_TIME } from '../../../support/constants'; | ||
|
||
const recycleItem = (id) => { | ||
cy.wait(TABLE_ITEM_RENDER_TIME); | ||
cy.get(`#${buildItemsTableRowId(id)} .${ITEM_DELETE_BUTTON_CLASS}`).click(); | ||
cy.get(`#${CONFIRM_RECYCLE_BUTTON_ID}`).click(); | ||
}; | ||
|
||
describe('Recycle Item in List', () => { | ||
it('recycle item on Home', () => { | ||
cy.setUpApi(SAMPLE_ITEMS); | ||
cy.visit(HOME_PATH); | ||
|
||
if (DEFAULT_ITEM_LAYOUT_MODE !== ITEM_LAYOUT_MODES.LIST) { | ||
cy.switchMode(ITEM_LAYOUT_MODES.LIST); | ||
} | ||
|
||
const { id } = SAMPLE_ITEMS.items[0]; | ||
|
||
// delete | ||
recycleItem(id); | ||
cy.wait('@recycleItem').then(({ request: { url } }) => { | ||
expect(url).to.contain(id); | ||
}); | ||
cy.wait('@getOwnItems'); | ||
}); | ||
|
||
it('recycle item inside parent', () => { | ||
cy.setUpApi(SAMPLE_ITEMS); | ||
const { id } = SAMPLE_ITEMS.items[0]; | ||
const { id: idToDelete } = SAMPLE_ITEMS.items[2]; | ||
|
||
// go to children item | ||
cy.visit(buildItemPath(id)); | ||
|
||
if (DEFAULT_ITEM_LAYOUT_MODE !== ITEM_LAYOUT_MODES.LIST) { | ||
cy.switchMode(ITEM_LAYOUT_MODES.LIST); | ||
} | ||
|
||
// delete | ||
recycleItem(idToDelete); | ||
cy.wait('@recycleItem').then(({ request: { url } }) => { | ||
expect(url).to.contain(idToDelete); | ||
}); | ||
}); | ||
|
||
describe('Error handling', () => { | ||
it('error while recycling item does not recycle in interface', () => { | ||
cy.setUpApi({ ...SAMPLE_ITEMS, recycleItemError: true }); | ||
const { id } = SAMPLE_ITEMS.items[0]; | ||
const { id: idToDelete } = SAMPLE_ITEMS.items[2]; | ||
|
||
// go to children item | ||
cy.visit(buildItemPath(id)); | ||
|
||
if (DEFAULT_ITEM_LAYOUT_MODE !== ITEM_LAYOUT_MODES.LIST) { | ||
cy.switchMode(ITEM_LAYOUT_MODES.LIST); | ||
} | ||
|
||
// delete | ||
recycleItem(idToDelete); | ||
|
||
cy.wait('@recycleItem').then(() => { | ||
// check item is still displayed | ||
cy.get(`#${buildItemsTableRowId(idToDelete)}`).should('exist'); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.