Skip to content

Commit 9389071

Browse files
committed
added test for removing trademarks.
1 parent f450774 commit 9389071

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

test/helpers/selenium-helper.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SeleniumHelper {
2323
'elementIsVisible',
2424
'findByText',
2525
'findByXpath',
26+
'notExistsByXpath',
2627
'getDriver',
2728
'getSauceDriver',
2829
'getLogs',
@@ -103,6 +104,11 @@ class SeleniumHelper {
103104
return this.findByXpath(`//body//${scope || '*'}//*[contains(text(), '${text}')]`);
104105
}
105106

107+
notExistsByXpath (xpath) {
108+
return this.driver.findElements(By.xpath(xpath))
109+
.then(elements => elements.length == 0 || elements.every(i => !i.isDisplayed()));
110+
}
111+
106112
loadUri (uri) {
107113
const WINDOW_WIDTH = 1024;
108114
const WINDOW_HEIGHT = 768;
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import path from 'path';
2+
import SeleniumHelper from '../helpers/selenium-helper';
3+
4+
const {
5+
clickText,
6+
clickXpath,
7+
findByText,
8+
findByXpath,
9+
notExistsByXpath,
10+
getDriver,
11+
getLogs,
12+
loadUri,
13+
rightClickText,
14+
scope
15+
} = new SeleniumHelper();
16+
17+
const uri = path.resolve(__dirname, '../../build/index.html');
18+
19+
let driver;
20+
21+
const trademarkNames = [
22+
'Cat',
23+
'Cat-Flying',
24+
'Gobo',
25+
'Pico',
26+
'Pico Walking',
27+
'Nano',
28+
'Tera',
29+
'Giga',
30+
'Giga Walking'
31+
];
32+
33+
describe('Removed trademarks (ex: Scratch Cat)', () => {
34+
beforeAll(() => {
35+
driver = getDriver();
36+
});
37+
38+
afterAll(async () => {
39+
await driver.quit();
40+
});
41+
42+
43+
test('Removed trademark sprites', async () => {
44+
await loadUri(uri);
45+
await clickXpath('//button[@aria-label="Choose a Sprite"]');
46+
const searchElement = await findByXpath("//input[@placeholder='Search']");
47+
48+
for (let name of trademarkNames) {
49+
searchElement.clear();
50+
await searchElement.sendKeys(name);
51+
await new Promise(resolve => setTimeout(resolve, 500));
52+
expect(await notExistsByXpath(`//*[span[text()="${name}"]]`)).toBeTruthy();
53+
}
54+
55+
const logs = await getLogs();
56+
await expect(logs).toEqual([]);
57+
});
58+
59+
test('Removed trademark costumes', async () => {
60+
await loadUri(uri);
61+
await clickText('Costumes');
62+
await clickXpath('//button[@aria-label="Choose a Costume"]');
63+
const searchElement = await findByXpath("//input[@placeholder='Search']");
64+
65+
for (let name of trademarkNames) {
66+
searchElement.clear();
67+
const costumePrefix = `${name}-`;
68+
await searchElement.sendKeys(costumePrefix);
69+
await new Promise(resolve => setTimeout(resolve, 500));
70+
expect(await notExistsByXpath(`//*[span[contains(text(), "${costumePrefix}")]]`)).toBeTruthy();
71+
}
72+
73+
const logs = await getLogs();
74+
await expect(logs).toEqual([]);
75+
});
76+
77+
});

0 commit comments

Comments
 (0)