2019-05-20 18:51:59 +02:00
|
|
|
import { Selector } from 'testcafe';
|
|
|
|
import testcafeconfig from './testcafeconfig';
|
|
|
|
import Page from "./page-model";
|
2019-06-20 13:46:58 +02:00
|
|
|
import { RequestLogger } from 'testcafe';
|
|
|
|
|
|
|
|
const logger = RequestLogger( /http:\/\/localhost:2342\/api\/v1\/photos*/ , {
|
|
|
|
logResponseHeaders: true,
|
|
|
|
logResponseBody: true
|
|
|
|
});
|
2019-05-20 18:51:59 +02:00
|
|
|
|
2019-05-21 17:00:46 +02:00
|
|
|
fixture`Search photos`
|
2019-06-20 13:46:58 +02:00
|
|
|
.page`${testcafeconfig.url}`
|
|
|
|
.requestHooks(logger);
|
2019-05-21 17:00:46 +02:00
|
|
|
|
2019-05-20 18:51:59 +02:00
|
|
|
const page = new Page();
|
|
|
|
|
|
|
|
test('Test search object', async t => {
|
2019-06-20 13:46:58 +02:00
|
|
|
await page.search('label:cat');
|
2019-06-27 17:01:12 +02:00
|
|
|
const request3 = await logger.requests[1].responseBody;
|
2019-05-20 18:51:59 +02:00
|
|
|
await t
|
2019-06-20 13:46:58 +02:00
|
|
|
.expect(logger.requests[0].response.statusCode).eql(200)
|
2019-05-21 17:00:46 +02:00
|
|
|
.expect(Selector('div.v-image__image').visible).ok();
|
|
|
|
}),
|
2019-05-20 18:51:59 +02:00
|
|
|
test('Test search color', async t => {
|
2020-01-06 00:16:16 +01:00
|
|
|
await page.search('color:red');
|
2019-06-27 17:01:12 +02:00
|
|
|
const request2 = await logger.requests[1].responseBody;
|
2019-05-20 18:51:59 +02:00
|
|
|
await t
|
2019-06-20 13:46:58 +02:00
|
|
|
.expect(logger.requests[1].response.statusCode).eql(200)
|
2019-05-21 17:00:46 +02:00
|
|
|
.expect(Selector('div.v-image__image').visible).ok();
|
|
|
|
});
|