This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
/
filtering.e2e.ts
47 lines (34 loc) · 1.77 KB
/
filtering.e2e.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Selector } from "testcafe";
import { buildTranslations } from "../../../app/i18n/helpers";
import { getPageURL } from "../../../utils/e2e-utils";
import { goToNews } from "./common";
const itemsPerPage = 15;
const translations = buildTranslations();
fixture`News filtering`.page(getPageURL()).beforeEach(async (t) => await goToNews(t));
test("should display news feed", async (t) => {
await t.expect(Selector('[data-testid="NewsCard"]').exists).ok();
await t.expect(Selector('[data-testid="NewsCard"]').count).eql(itemsPerPage);
});
test("should filter news results", async (t) => {
// Filter technical category
const technical = translations.NEWS.CATEGORIES.TECHNICAL;
const eth = "network__option--1";
const query = "the block";
const queryInput = Selector('[data-testid="NewsOptions__search"]');
await t.typeText(queryInput, query, { replace: true });
await t.click(Selector(`[data-testid='NewsOptions__category-${technical}']`));
await t.click(Selector(`[data-testid=${eth}]`));
await t.click(Selector(`[data-testid=NewsOptions__submit]`));
await t.expect(Selector('[data-testid="NewsCard"]').exists).ok();
await t.expect(Selector('[data-testid="NewsCard__category"]').withText(technical).exists).ok();
await t.expect(Selector('[data-testid="NetworkIcon-ETH-mainnet"]').exists).ok();
await t.expect(Selector('[data-testid="NewsCard__content"]').withText(query).exists).ok();
});
test("should show no results screen", async (t) => {
// Filter technical category
const query = "fjdskfjdfsdjfkdsfjdsfsd";
const queryInput = Selector('[data-testid="NewsOptions__search"]');
await t.typeText(queryInput, query, { replace: true });
await t.click(Selector(`[data-testid=NewsOptions__submit]`));
await t.expect(Selector('[data-testid="News__empty-results"]').exists).ok();
});