-
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
7c21d18
commit 316802a
Showing
12 changed files
with
171 additions
and
229 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 |
---|---|---|
@@ -1,29 +1,47 @@ | ||
import { SAMPLE_PUBLIC_ITEMS } from "./items"; | ||
|
||
export const VALIDATED_ITEM = { | ||
...SAMPLE_PUBLIC_ITEMS.items[0], | ||
updatedAt: new Date('2019-07-27T07:45:00Z') | ||
} | ||
|
||
export const SAMPLE_STATUSES = [ | ||
{ | ||
id: 'status-id1', | ||
name: 'name1', | ||
name: 'success', | ||
}, | ||
{ | ||
id: 'status-id2', | ||
name: ' name2', | ||
name: 'pending', | ||
}, | ||
]; | ||
|
||
export const ITEM_VALIDATION_AND_REVIEW = [ | ||
export const ITEM_VALIDATION_AND_REVIEW = { | ||
itemValidationId: '6cbe87b9-0098-412f-a1ab-93e140ae1659', | ||
reviewStatusId: '', | ||
reviewReason: '', | ||
createdAt: new Date('2023-07-27T07:45:00Z'), | ||
}; | ||
|
||
export const ITEM_VALIDATION_GROUPS = [ | ||
{ | ||
validationStatusId: 'id', | ||
reviewStatusId: 'id', | ||
validationResult: 'result', | ||
reviewResult: 'review-result', | ||
validationUpdatedAt: 'ts', | ||
reviewUpdatedAt: 'ts', | ||
id: 'id1', | ||
itemId: 'item-id1', | ||
itemValidationId: '6cbe87b9-0098-412f-a1ab-93e140ae1659', | ||
processId: 'process-id1', | ||
statusId: 'status-id1', | ||
result: '', | ||
updatedAt: '', | ||
createdAt: '', | ||
}, | ||
{ | ||
validationStatusId: 'id2', | ||
reviewStatusId: 'id', | ||
validationResult: 'result', | ||
reviewResult: 'review-result', | ||
validationUpdatedAt: 'ts', | ||
reviewUpdatedAt: 'ts', | ||
}, | ||
id: 'id1', | ||
itemId: 'item-id1', | ||
itemValidationId: '6cbe87b9-0098-412f-a1ab-93e140ae1659', | ||
processId: 'process-id2', | ||
statusId: 'status-id1', | ||
result: '', | ||
updatedAt: '', | ||
createdAt: '', | ||
} | ||
]; |
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,81 @@ | ||
import { | ||
buildPublishButtonId, | ||
ITEM_PUBLISH_BUTTON_ID, | ||
ITEM_UNPUBLISH_BUTTON_ID, | ||
ITEM_VALIDATION_BUTTON_ID, | ||
} from '../../../../src/config/selectors'; | ||
import { buildItemPath } from '../../../../src/config/paths'; | ||
import { | ||
PUBLISHED_ITEM, | ||
SAMPLE_ITEMS, | ||
SAMPLE_PUBLIC_ITEMS, | ||
} from '../../../fixtures/items'; | ||
import { DEFAULT_TAGS, ITEM_PUBLISHED_TAG } from '../../../fixtures/itemTags'; | ||
import { VALIDATED_ITEM } from '../../../fixtures/validations'; | ||
|
||
const openPublishItemTab = (id) => { | ||
cy.get(`#${buildPublishButtonId(id)}`).click(); | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const publishItem = () => { | ||
cy.get(`#${ITEM_PUBLISH_BUTTON_ID}`).click(); | ||
}; | ||
|
||
describe('Public Item', () => { | ||
it('Validate item', () => { | ||
cy.setUpApi({ ...SAMPLE_PUBLIC_ITEMS, tags: DEFAULT_TAGS }); | ||
const item = SAMPLE_ITEMS.items[0]; | ||
cy.visit(buildItemPath(item.id)); | ||
openPublishItemTab(item.id); | ||
|
||
// click validate item button | ||
cy.get(`#${ITEM_VALIDATION_BUTTON_ID}`).click(); | ||
|
||
cy.wait('@postItemValidation').then((data) => { | ||
const { | ||
request: { url }, | ||
} = data; | ||
expect(url.split('/')).contains(item.id); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Published Item', () => { | ||
const item = PUBLISHED_ITEM; | ||
beforeEach(() => { | ||
cy.setUpApi({ items: [item], tags: DEFAULT_TAGS }); | ||
cy.visit(buildItemPath(item.id)); | ||
openPublishItemTab(item.id); | ||
}); | ||
it('Show published state on button', () => { | ||
// click validate item button | ||
cy.get(`#${ITEM_PUBLISH_BUTTON_ID} > span`).children().children().should('exist'); | ||
}); | ||
it('Unpublish item', () => { | ||
cy.get(`#${ITEM_UNPUBLISH_BUTTON_ID}`).click(); | ||
cy.wait('@deleteItemTag').then(({ request: { url } }) => { | ||
// should contain published tag id | ||
expect(url).to.contain(item.tags[1].id); | ||
}); | ||
}) | ||
}); | ||
|
||
describe('Validated Item', () => { | ||
it('Publish item', () => { | ||
cy.setUpApi({ items: [VALIDATED_ITEM], tags: DEFAULT_TAGS }); | ||
const item = VALIDATED_ITEM; | ||
cy.visit(buildItemPath(item.id)); | ||
openPublishItemTab(item.id); | ||
|
||
// click validate item button | ||
cy.get(`#${ITEM_PUBLISH_BUTTON_ID}`).click(); | ||
|
||
cy.wait('@postItemTag').then((data) => { | ||
const { | ||
request: { body }, | ||
} = data; | ||
expect(body?.tagId).to.equal(ITEM_PUBLISHED_TAG.id); | ||
}); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.