-
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
1 parent
42658e8
commit 3b004d0
Showing
4 changed files
with
109 additions
and
3 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,104 @@ | ||
import { ITEMS_SETTINGS } from '../../../fixtures/items'; | ||
import { HOME_PATH } from '../../../../src/config/paths'; | ||
import { | ||
buildItemCard, | ||
buildItemsTableRowIdAttribute, | ||
PIN_ITEM_BUTTON_CLASS, | ||
} from '../../../../src/config/selectors'; | ||
import { TABLE_ITEM_RENDER_TIME } from '../../../support/constants'; | ||
import { ITEM_LAYOUT_MODES } from '../../../../src/enums'; | ||
|
||
const togglePinButton = (itemId) => { | ||
cy.wait(TABLE_ITEM_RENDER_TIME); | ||
cy.get( | ||
`${buildItemsTableRowIdAttribute(itemId)} .${PIN_ITEM_BUTTON_CLASS}`, | ||
).click(); | ||
}; | ||
|
||
const togglePinButtonCard = (itemId) => { | ||
cy.wait(TABLE_ITEM_RENDER_TIME); | ||
cy.get( | ||
`#${buildItemCard(itemId)} .${PIN_ITEM_BUTTON_CLASS}`, | ||
).click(); | ||
}; | ||
|
||
describe('Pinning Item', () => { | ||
|
||
describe('Successfully pinning item in List', () => { | ||
beforeEach(() => { | ||
cy.setUpApi(ITEMS_SETTINGS); | ||
cy.visit(HOME_PATH); | ||
}); | ||
|
||
it('Pin an item', () => { | ||
const item = ITEMS_SETTINGS.items[1]; | ||
|
||
togglePinButton(item.id); | ||
|
||
cy.wait(`@editItem`).then( | ||
({ | ||
request: { | ||
body : { settings } | ||
} | ||
}) => { | ||
expect(settings.isPinned).to.equals(true); | ||
}); | ||
}); | ||
|
||
it('Unpin Item', () => { | ||
const item = ITEMS_SETTINGS.items[0]; | ||
|
||
togglePinButton(item.id); | ||
|
||
cy.wait('@editItem').then( | ||
({ | ||
request: { | ||
body: { settings }, | ||
}, | ||
}) => { | ||
expect(settings.isPinned).to.equals(false); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
|
||
describe('Successfully pinning item in Grid', () => { | ||
beforeEach(() => { | ||
cy.setUpApi(ITEMS_SETTINGS); | ||
cy.visit(HOME_PATH); | ||
cy.switchMode(ITEM_LAYOUT_MODES.GRID); | ||
}); | ||
|
||
it('Pin an item', () => { | ||
const item = ITEMS_SETTINGS.items[1]; | ||
|
||
togglePinButtonCard(item.id); | ||
|
||
cy.wait(`@editItem`).then( | ||
({ | ||
request: { | ||
body : { settings } | ||
} | ||
}) => { | ||
expect(settings.isPinned).to.equals(true); | ||
}); | ||
}); | ||
|
||
it('Unpin Item', () => { | ||
const item = ITEMS_SETTINGS.items[0]; | ||
|
||
togglePinButtonCard(item.id); | ||
|
||
cy.wait('@editItem').then( | ||
({ | ||
request: { | ||
body: { settings }, | ||
}, | ||
}) => { | ||
expect(settings.isPinned).to.equals(false); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); |
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