1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-25 05:43:32 +03:00
guide/front/client/tests/Index.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

54 lines
1.9 KiB
JavaScript

import { Selector, ClientFunction } from 'testcafe'
import VueSelector from 'testcafe-vue-selectors'
const baseUrl = `http://localhost:5000`
const getLocation = ClientFunction(() => document.location.href)
// !!! Testcafe-vue-selectors currently dont support vue cumponents loaded by vue-loader
fixture`Index`
.page(baseUrl)
test('Navigate to category page', async t => {
await t
.click('.category-title')
.expect(getLocation()).contains(`${baseUrl}/haskell/data-structures-fum5aqch`)
})
test('Test search input', async inputSearch => {
const searchInput = Selector('input[aria-label="Search"]')
await inputSearch
.typeText(searchInput, 'Haskell')
.expect(searchInput.value).eql('Haskell')
.pressKey('enter')
.expect(getLocation()).eql(`${baseUrl}/haskell/search/results?query=Haskell`)
})
test('Add category', async t => {
const categoryGroups = Selector('.category-group')
const groupsCount = await categoryGroups.count
if (!categoryGroups || !groupsCount) {
return
}
for (let i = 0; i < groupsCount; i++) {
let currentGroup = categoryGroups.nth(i)
let categoryGroupName = await currentGroup.child('.category-group-name').innerText
let groupInput = Selector('input[aria-label="Group"]').value;
let addButton = currentGroup.child('.add-category-btn')
let newCategoryName = 'mytest-' + new Date().toISOString()
await t.click(addButton)
await t.expect(groupInput).eql(categoryGroupName)
await t
.typeText('input[aria-label="Category name"]', newCategoryName)
.click('.add-category-submit-btn')
// Cause after adding category it opens in new tab we need to navigate back, because TestCafe doest support opening new tabs
// https://github.com/DevExpress/testcafe/issues/2293
await t.navigateTo(`${baseUrl}`)
await t.expect(currentGroup.find(node => node.innerText === newCategoryName).exists)
}
})