Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/android-appium.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Android Appium

on:
pull_request:
push:
branches:
- develop
- master
paths:
- '.github/workflows/android-appium.yml'
- 'android/**'
- 'gulpfile.js'
- 'html/**'
- 'package.json'
- 'package-lock.json'
- 'src/**'
- 'test/**'
- 'webpack*'

concurrency:
group: floccus-android-appium-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
android-appium:
runs-on: ubuntu-latest
timeout-minutes: 60

strategy:
matrix:
node-version: [20.x]
java-version: [21]

steps:
- uses: actions/checkout@v4

- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Set up Java ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java-version }}
cache: gradle

- name: Install dependencies
run: npm ci

- name: Build web assets and sync Capacitor
run: npm run build

- name: Build Android debug APK
run: |
cd android
chmod +x gradlew
./gradlew assembleDebug

- name: Install Appium and Android driver
run: |
npm install -g appium
appium driver install uiautomator2

- name: Enable KVM access
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Run Android Appium smoke tests
uses: ReactiveCircus/android-emulator-runner@v2
env:
CI: true
FLOCCUS_TEST: '^(?=.*fake test root Account)(?=.*(should create local bookmarks on the server|should create empty local folders on the server|should update the server on local changes|should update the server on local removals)).*$'
FLOCCUS_TEST_SEED: ${{ github.sha }}
with:
api-level: 35
arch: x86_64
profile: pixel_7
target: google_apis
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
script: |
adb install -r android/app/build/outputs/apk/debug/app-debug.apk
appium --log-no-colors --allow-insecure uiautomator2:chromedriver_autodownload > appium.log 2>&1 &
until curl -sf http://127.0.0.1:4723/status > /dev/null; do echo 'Waiting for Appium to start'; sleep 1; done
npm run test:appium

- name: Upload Appium log
if: always()
uses: actions/upload-artifact@v4
with:
name: android-appium-log
path: appium.log
if-no-files-found: ignore
retention-days: 7
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"watch": "NODE_OPTIONS=--max-old-space-size=4096 gulp watch",
"watch-win": "SET NODE_OPTIONS=--max-old-space-size=4096 & gulp watch",
"test": "node --unhandled-rejections=strict test/selenium-runner.js",
"test:appium": "node --unhandled-rejections=strict test/appium-runner.js",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix",
"typecheck": "tsc --noEmit",
Expand Down
26 changes: 26 additions & 0 deletions src/lib/native/NativeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ import Logger from '../Logger'
import { i18n } from './I18n'

export default class NativeAccount extends Account {
static getDefaultRootId(id:string): number {
const digits = String(id).replace(/\D/g, '')
const parsed = parseInt(digits.slice(-12) || Date.now().toString(), 10)
return Number.isNaN(parsed) ? Date.now() : parsed
}

async ensureLocalRoot(): Promise<void> {
const accountData = this.getData()
if (accountData.localRoot === 'tabs') {
return
}

const tree = new NativeTree(this.storage)
await tree.load()

const rootId = accountData.localRoot || NativeAccount.getDefaultRootId(this.id)
await tree.ensureRoot(rootId)
this.localTree = tree

if (String(accountData.localRoot) !== String(rootId) || accountData.rootPath !== '') {
await this.setData({ localRoot: String(rootId), rootPath: '' })
}
}

static async get(id:string):Promise<Account> {
const storage = new NativeAccountStorage(id)
const data = await storage.getAccountData(null)
Expand Down Expand Up @@ -46,10 +70,12 @@ export default class NativeAccount extends Account {

async init(): Promise<void> {
console.log('initializing account ' + this.id)
await this.ensureLocalRoot()
await this.storage.initMappings()
await this.storage.initCache()
const nativeTree = new NativeTree(this.storage)
await nativeTree.load()
await nativeTree.ensureRoot(this.getData().localRoot)
this.localTree = nativeTree
}

Expand Down
20 changes: 20 additions & 0 deletions src/lib/native/NativeTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ export default class NativeTree extends CachingAdapter implements BulkImportReso
}, 500)
}

async ensureRoot(rootId:string|number):Promise<void> {
const previousRootId = this.bookmarksCache.id
this.bookmarksCache.id = rootId
this.bookmarksCache.isRoot = true
this.bookmarksCache.parentId = undefined
this.bookmarksCache.children.forEach(child => {
if (String(child.parentId) === String(previousRootId)) {
child.parentId = rootId
}
})

const parsedRootId = parseInt(String(rootId), 10)
if (!Number.isNaN(parsedRootId)) {
this.highestId = Math.max(this.highestId, parsedRootId)
}

this.bookmarksCache.createIndex()
await this.save()
}

async getBookmarksTree(): Promise<Folder<typeof ItemLocation.LOCAL>> {
const tree = await super.getBookmarksTree()
tree.createIndex()
Expand Down
6 changes: 6 additions & 0 deletions src/ui/NativeRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Vue.use(Router)
export const routes = {
HOME: 'HOME',
TREE: 'TREE',
TEST: 'TEST',
ACCOUNT_OPTIONS: 'ACCOUNT_OPTIONS',
NEW_ACCOUNT: 'NEW_ACCOUNT',
ADD_BOOKMARK: 'ADD_BOOKMARK',
Expand All @@ -29,6 +30,11 @@ export const router = new Router({
name: routes.HOME,
component: Home,
},
{
path: '/test',
name: routes.TEST,
component: () => import(/* webpackPrefetch: true */ './views/native/TestRunner.vue')
},
{
path: '/tree/:accountId',
name: routes.TREE,
Expand Down
Loading
Loading