mirror of
https://github.com/frappe/books.git
synced 2025-01-03 15:17:30 +00:00
test(ui): test instance setup
- fix auto complete choice on blur - fix button disabled
This commit is contained in:
parent
badae87edb
commit
64671e5625
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
|
/dbs
|
||||||
/dist
|
/dist
|
||||||
/notebook
|
/notebook
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
class="rounded-md flex justify-center items-center text-sm"
|
class="rounded-md flex justify-center items-center text-sm"
|
||||||
|
:disabled="disabled"
|
||||||
:class="_class"
|
:class="_class"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
>
|
>
|
||||||
|
@ -262,15 +262,15 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label && this.suggestions.length === 0) {
|
if (this.suggestions.length === 0) {
|
||||||
this.triggerChange(label);
|
this.triggerChange(label);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const suggestion = this.suggestions.find((s) => s.label === label);
|
||||||
label &&
|
if (suggestion) {
|
||||||
!this.suggestions.map(({ label }) => label).includes(label)
|
this.setSuggestion(suggestion);
|
||||||
) {
|
} else {
|
||||||
const suggestions = await this.getSuggestions(label);
|
const suggestions = await this.getSuggestions(label);
|
||||||
this.setSuggestion(suggestions[0]);
|
this.setSuggestion(suggestions[0]);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<h6
|
<h6
|
||||||
|
data-testid="company-name"
|
||||||
class="
|
class="
|
||||||
font-semibold
|
font-semibold
|
||||||
whitespace-nowrap
|
whitespace-nowrap
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
class="w-24"
|
class="w-24"
|
||||||
|
data-testid="submit-button"
|
||||||
:disabled="!areAllValuesFilled || loading"
|
:disabled="!areAllValuesFilled || loading"
|
||||||
@click="submit"
|
@click="submit"
|
||||||
>{{ t`Submit` }}</Button
|
>{{ t`Submit` }}</Button
|
||||||
|
@ -10,6 +10,7 @@ const appSourcePath = path.join(root, 'dist_electron', 'build', 'main.js');
|
|||||||
(async function run() {
|
(async function run() {
|
||||||
const electronApp = await _electron.launch({ args: [appSourcePath] });
|
const electronApp = await _electron.launch({ args: [appSourcePath] });
|
||||||
const window = await electronApp.firstWindow();
|
const window = await electronApp.firstWindow();
|
||||||
|
window.setDefaultTimeout(10_000);
|
||||||
|
|
||||||
test('load app', async (t) => {
|
test('load app', async (t) => {
|
||||||
t.equal(await window.title(), 'Frappe Books', 'title matches');
|
t.equal(await window.title(), 'Frappe Books', 'title matches');
|
||||||
@ -42,9 +43,43 @@ const appSourcePath = path.join(root, 'dist_electron', 'build', 'main.js');
|
|||||||
t.ok(await createNew.isVisible(), 'create new is visible');
|
t.ok(await createNew.isVisible(), 'create new is visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('fill setup form', async (t) => {
|
||||||
|
const filePath = path.join(root, 'dbs', 'books_uitest.db');
|
||||||
|
await electronApp.evaluate(({ dialog }, filePath) => {
|
||||||
|
dialog.showSaveDialog = () =>
|
||||||
|
Promise.resolve({ canceled: false, filePath });
|
||||||
|
}, filePath);
|
||||||
|
await window.getByTestId('create-new-file').click();
|
||||||
|
await window.getByTestId('submit-button').waitFor();
|
||||||
|
|
||||||
|
t.equal(
|
||||||
|
await window.getByTestId('submit-button').isDisabled(),
|
||||||
|
true,
|
||||||
|
'submit button is disabled before form fill'
|
||||||
|
);
|
||||||
|
|
||||||
|
await window.getByPlaceholder('Company Name').fill('Test Company');
|
||||||
|
await window.getByPlaceholder('John Doe').fill('Test Owner');
|
||||||
|
await window.getByPlaceholder('john@doe.com').fill('test@example.com');
|
||||||
|
await window.getByPlaceholder('Select Country').fill('India');
|
||||||
|
await window.getByPlaceholder('Select Country').blur();
|
||||||
|
await window.getByPlaceholder('Prime Bank').fill('Test Bank');
|
||||||
|
await window.getByPlaceholder('Prime Bank').blur();
|
||||||
|
|
||||||
|
t.equal(
|
||||||
|
await window.getByTestId('submit-button').isDisabled(),
|
||||||
|
false,
|
||||||
|
'submit button enabled after form fill'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('create new instance', async (t) => {
|
test('create new instance', async (t) => {
|
||||||
// await window.getByTestId('create-new-file').click();
|
await window.getByTestId('submit-button').click();
|
||||||
t.ok(true, '...');
|
t.equal(
|
||||||
|
await window.getByTestId('company-name').innerText(),
|
||||||
|
'Test Company',
|
||||||
|
'new instance created, company name found in sidebar'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('close app', async (t) => {
|
test('close app', async (t) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user