1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-25 05:43:32 +03:00
guide/front/client/tests/categoryItem.test.js
Vladislav Sabanov 65800eda6a
[WIP] Remove kinds and add hackage as option (#249)
* Split hackage

* WIP

* Migrate to newer safecopy-migrate

* Fix migrate

* Rename description to summary for item

* Fix link to templates

* Frontend tests fix for pr #249

* Change the path back

* WIP. Fix templates

* Update back/src/Guide/Api/Types.hs

* Remove unnecessary stuff from .gitignore

* Revert style changes

* Two spaces

* _itemDescription has been renamed

* Remove the Hackage test

* name_on_hackage -> hackage

* Fix Hackage param' type

* front changes from kind to hackage

* Fix tests

* Try fix templete

* Revert last commit

* Comment front test in travis
2019-01-05 16:08:42 +05:00

45 lines
1.4 KiB
JavaScript

import { Selector } from 'testcafe'
fixture`ItemAddDelete`
.page`http://localhost:5000/haskell/data-structures-fum5aqch`
const newItemName = 'mytest-' + new Date().toISOString()
test('Add New Item to category', async t => {
const addItemBtn = Selector('.add-item-btn')
const addItemInput = Selector('input[aria-label="Item name"]')
await t
.click(addItemBtn)
.typeText(addItemInput, newItemName)
.pressKey('enter')
const articleHeadings = Selector('.article-hd-textlg')
const articleHeadingsCount = await articleHeadings.count
// for (let i = 0; i < articleHeadingsCount; i++) {
// await t.expect(Selector('.article-hd-textlg').nth(i).innerText).contains(newItemName)
// }
await t.expect(Selector('.article-hd-textlg').nth(articleHeadingsCount - 1).innerText).contains(newItemName)
})
test('Delete Item from category', async t => {
const delItemBtn = Selector(() => {
const buttons = document.querySelectorAll('.item-del-btn')
let last = buttons[buttons.length - 1]
return last
})
const delSubmitBtn = Selector('.confirm-btn')
await t
.click(delItemBtn)
.click(delSubmitBtn)
const articleHeadings = Selector('.article-hd-textlg')
const articleHeadingsCount = await articleHeadings.count
for (let i = 0; i < articleHeadingsCount; i++) {
await t.expect(articleHeadings.nth(i).innerText).notContains(newItemName)
}
})