// e2e/todo-driver.js
/** 通过 UI、用 Quiesco 实现。只有这个类知道 test id。 */
class UiTodoDriver {
/** @param {import('@quiesco/core').Driver} app */
constructor(app) {
this.app = app;
}
async seed(todos) {
// 不经过 UI 准备数据
await this.app.backdoor('seedTodos', todos);
}
async addTodo(title, notes) {
await this.app.tap('add-todo');
await this.app.type('title-input', title);
if (notes !== undefined) await this.app.type('notes-input', notes);
await this.app.tap('save-todo');
await this.app.expectVisible('todo-list-screen');
}
async todoTitles() {
return (await this.app.query('todo-title')).map((e) => e.text);
}
}
module.exports = { UiTodoDriver };