Skip to content

Commit

Permalink
feat: update widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
pwltr committed Sep 4, 2023
1 parent d914ce7 commit a5c6bb7
Show file tree
Hide file tree
Showing 57 changed files with 2,956 additions and 1,895 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/e2e-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ jobs:
uses: mikehardy/buildcache-action@v2

- name: Setup Docker Colima 1
uses: douglascamata/setup-docker-macos-action@v1-alpha
# when https://github.com/douglascamata/setup-docker-macos-action/pull/19 is merged and tagged, move to new version:
uses: douglascamata/setup-docker-macos-action@ed0328701ed84842bf3a3941410e74f62392ab9c
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
id: docker1
continue-on-error: true

- name: Setup Docker Colima 2
if: steps.docker1.outcome != 'success'
uses: douglascamata/setup-docker-macos-action@v1-alpha
# when https://github.com/douglascamata/setup-docker-macos-action/pull/19 is merged and tagged, move to new version:
uses: douglascamata/setup-docker-macos-action@ed0328701ed84842bf3a3941410e74f62392ab9c
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
id: docker2
continue-on-error: true

Expand Down
1 change: 1 addition & 0 deletions __mocks__/@react-native-async-storage/async-storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@react-native-async-storage/async-storage/jest/async-storage-mock';
17 changes: 9 additions & 8 deletions __tests__/backups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ describe('Remote backups', () => {
});

it('Backups and restores widgets', async () => {
setFeedWidget('url', {
name: 'name',
setFeedWidget({
url: 'url',
type: 'type',
icon: 'icon',
field: {
name: 'name',
main: 'main',
files: {},
},
fields: [
{
name: 'name',
main: 'main',
files: {},
},
],
});
updateWidgets({ onboardedWidgets: true });

Expand Down
15 changes: 7 additions & 8 deletions e2e/backup.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ d('Backup', () => {

// add price widget
await element(by.id('WidgetsAdd')).tap();
await element(by.id('ContinueWidgets')).tap();
await element(by.id('ContinueWidgets')).tap();
await element(by.id('ContinueWidgets-0')).tap();
await element(by.id('ContinueWidgets-1')).tap();
await element(by.id('PriceWidget')).tap();
// for unknown reason await waitFor(element(by.id('HourglassSpinner'))).not.toBeVisible();
// doesn't work here, so instead we just wait until we can tap SaveWidget
// doesn't work here, so instead we just wait until we can tap WidgetSave
// 5 min timeout
for (let i = 0; i < 300; i++) {
await sleep(1000);
try {
await element(by.id('SaveWidget')).tap();
await element(by.id('WidgetSave')).tap();
break;
} catch (e) {}
}
Expand All @@ -112,18 +112,17 @@ d('Backup', () => {
await element(by.id('WidgetsAdd')).tap();
await element(by.id('HeadlinesWidget')).tap();
// for unknown reason await waitFor(element(by.id('HourglassSpinner'))).not.toBeVisible();
// doesn't work here, so instead we just wait until we can tap SaveWidget
// doesn't work here, so instead we just wait until we can tap WidgetSave
// 5 min timeout
for (let i = 0; i < 300; i++) {
await sleep(1000);
try {
await element(by.id('SaveWidget')).tap();
await element(by.id('WidgetSave')).tap();
break;
} catch (e) {}
}

await sleep(1000); // animation
await element(by.id('WidgetsTitle')).swipe('down');

// get seed
await element(by.id('Settings')).tap();
Expand Down Expand Up @@ -188,7 +187,7 @@ d('Backup', () => {
await element(by.id('NavigationClose')).tap();

// check widgets
await element(by.id('WidgetsTitle')).swipe('up');
await element(by.id('WalletsScrollView')).scroll(300, 'down', NaN, 0.85);
await expect(element(by.id('PriceWidget'))).toBeVisible();
await expect(element(by.id('HeadlinesWidget'))).toBeVisible();

Expand Down
70 changes: 70 additions & 0 deletions e2e/widgets.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
checkComplete,
markComplete,
completeOnboarding,
launchAndWait,
} from './helpers';

d = checkComplete('widgets-1') ? describe.skip : describe;

d('Widgets', () => {
beforeAll(async () => {
await completeOnboarding();
});

beforeEach(async () => {
await launchAndWait();
});

// General
// - can add a widget
// - can edit a widget
// - can delete a widget

it('Can add/edit/remove a widget', async () => {
if (checkComplete('widgets-1')) {
return;
}

// add price widget
await element(by.id('WidgetsAdd')).tap();
await element(by.id('ContinueWidgets-0')).tap();
await element(by.id('ContinueWidgets-1')).tap();
await element(by.id('PriceWidget')).tap();
await waitFor(element(by.id('WidgetEdit')))
.toBeVisible()
.withTimeout(20000);
await expect(element(by.text('Default'))).toBeVisible();
await element(by.id('WidgetEdit')).tap();
await element(by.id('WidgetEditField-BTC/EUR')).tap();
await element(by.id('WidgetEditScrollView')).scrollTo('bottom');
await element(by.id('PriceWidgetSetting-1W')).tap();
await element(by.id('WidgetEditSource')).tap();
await element(by.id('WidgetEditPreview')).tap();
await element(by.id('WidgetSave')).tap();
await element(by.id('WalletsScrollView')).scroll(200, 'down', NaN, 0.85);
await expect(element(by.id('PriceWidget'))).toBeVisible();
await expect(element(by.id('PriceWidgetRow-BTC/EUR'))).toBeVisible();
await expect(element(by.id('PriceWidgetSource'))).toBeVisible();

// edit price widget
await element(by.id('WidgetsEdit')).tap();
await element(by.id('WidgetActionEdit')).tap();
await expect(element(by.text('Custom'))).toBeVisible();
await element(by.id('WidgetEdit')).tap();
await element(by.id('WidgetEditReset')).tap();
await element(by.id('WidgetEditPreview')).tap();
await element(by.id('WidgetSave')).tap();
await expect(element(by.id('PriceWidget'))).toBeVisible();
await expect(element(by.id('PriceWidgetRow-BTC/EUR'))).not.toBeVisible();
await expect(element(by.id('PriceWidgetSource'))).not.toBeVisible();

// delete price widget
await element(by.id('WidgetsEdit')).tap();
await element(by.id('WidgetActionDelete')).tap();
await element(by.text('Yes, Delete')).tap();
await expect(element(by.id('PriceWidget'))).not.toBeVisible();

markComplete('widgets-1');
});
});
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import './shim';
import { polyfill as polyfillFetch } from 'react-native-polyfill-globals/src/fetch';
import { polyfill as polyfillEncoding } from 'react-native-polyfill-globals/src/encoding';
import { polyfill as polyfillReadableStream } from 'react-native-polyfill-globals/src/readable-stream';
import './src/utils/ignoreLogs';
import { AppRegistry, Text, TextInput } from 'react-native';
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';

import Root from './src/Root';
import { name as appName } from './app.json';

// Polyfill fetch streaming on iOS (Android is not supported yet)
// https://github.com/react-native-community/fetch/issues/13
polyfillEncoding();
polyfillReadableStream();
polyfillFetch();

// TEMP: disable font scaling globally
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ PODS:
- React-perflogger (= 0.71.7)
- ReactNativeCameraKit (14.0.0-beta2):
- React-Core
- RNCAsyncStorage (1.19.3):
- React-Core
- RNCClipboard (1.11.2):
- React-Core
- RNDeviceInfo (10.6.0):
Expand Down Expand Up @@ -616,6 +618,7 @@ DEPENDENCIES:
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- ReactNativeCameraKit (from `../node_modules/react-native-camera-kit`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
- RNExitApp (from `../node_modules/react-native-exit-app`)
Expand Down Expand Up @@ -762,6 +765,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
ReactNativeCameraKit:
:path: "../node_modules/react-native-camera-kit"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNCClipboard:
:path: "../node_modules/@react-native-clipboard/clipboard"
RNDeviceInfo:
Expand Down Expand Up @@ -869,6 +874,7 @@ SPEC CHECKSUMS:
React-runtimeexecutor: c5c89f8f543842dd864b63ded1b0bbb9c9445328
ReactCommon: dbfbe2f7f3c5ce4ce44f43f2fd0d5950d1eb67c5
ReactNativeCameraKit: 32e04877e57e0eeab26e45817e3fd532e7d302fb
RNCAsyncStorage: c913ede1fa163a71cea118ed4670bbaaa4b511bb
RNCClipboard: 3f0451a8100393908bea5c5c5b16f96d45f30bfc
RNDeviceInfo: 475a4c447168d0ad4c807e48ef5e0963a0f4eb1b
RNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3
Expand Down
Loading

0 comments on commit a5c6bb7

Please sign in to comment.