git ssb

1+

Daan Patchwork / manyverse



Commit 10a134bfe71f070a1be3e870774055062d4e5973

dx: add e2e tests for dht invites

Andre Staltz committed on 9/20/2018, 10:33:29 PM
Parent: a56d419ca9247333f4feb40c7a963347719718f0

Files changed

e2e/index.jschanged
e2e/connections.jsadded
e2e/index.jsView
@@ -44,8 +44,9 @@
4444 });
4545
4646 test('...', function(t) {
4747 require('./central.js')(driver, t);
48+ require('./connections.js')(driver, t);
4849 require('./compose.js')(driver, t);
4950 require('./drawer.js')(driver, t);
5051 require('./feed.js')(driver, t);
5152 require('./thread.js')(driver, t);
e2e/connections.jsView
@@ -1,0 +1,93 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+const test = require('tape');
21+
22+module.exports = function(driver, t) {
23+ t.test('Connections tab can create DHT invites', async function(t) {
24+ const connectionsTabButton = await driver.elementByAndroidUIAutomator(
25+ 'new UiSelector().descriptionContains("Connections Tab Button")',
26+ );
27+ t.ok(connectionsTabButton, 'I see the Connections Tab button');
28+ await connectionsTabButton.tap();
29+ t.pass('I tap it');
30+
31+ t.ok(
32+ await driver.elementByAndroidUIAutomator(
33+ 'new UiSelector().text("Connections")',
34+ ),
35+ 'I see the Connections header in the Central screen',
36+ );
37+ t.ok(
38+ await driver.elementByAndroidUIAutomator(
39+ 'new UiSelector().textContains("No connections")',
40+ ),
41+ 'I see Connections tab body with no connections',
42+ );
43+
44+ const fab = await driver.elementByAndroidUIAutomator(
45+ 'new UiSelector().descriptionContains("Floating Action Button")',
46+ 6000,
47+ );
48+ t.ok(fab, 'I see the Floating Action Button');
49+ await fab.tap();
50+ t.pass('I tap it');
51+
52+ const createInviteButton = await driver.elementByAndroidUIAutomator(
53+ 'new UiSelector().textContains("Create invite")',
54+ 6000,
55+ );
56+ t.ok(createInviteButton, 'I see the Create Invite Button');
57+ await createInviteButton.tap();
58+ t.pass('I tap it');
59+
60+ const inviteCode = await driver.elementByAndroidUIAutomator(
61+ 'new UiSelector().descriptionContains("Invite Code")',
62+ 6000,
63+ );
64+ const inviteCodeText = await inviteCode.text();
65+ t.ok(inviteCodeText.length > 70, 'I see the Invite Code');
66+
67+ await driver.back();
68+ t.pass('I press the (hardware) back button');
69+
70+ t.ok(
71+ await driver.elementByAndroidUIAutomator(
72+ 'new UiSelector().textContains("Internet P2P: waiting for friend")',
73+ ),
74+ 'I see Connections tab body with a staged connection',
75+ );
76+
77+ t.ok(
78+ await driver.elementByAndroidUIAutomator(
79+ `new UiSelector().textContains("${inviteCodeText.substr(4, 10)}")`,
80+ ),
81+ 'I see that the staged connection refers to the invite code',
82+ );
83+
84+ const publicTabButton = await driver.elementByAndroidUIAutomator(
85+ 'new UiSelector().descriptionContains("Public Tab Button")',
86+ );
87+ t.ok(publicTabButton, 'I see Public Tab button');
88+ await publicTabButton.tap();
89+ t.pass('I tap it');
90+
91+ t.end();
92+ });
93+};

Built with git-ssb-web