Skip to content
Merged
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
3 changes: 3 additions & 0 deletions Resources/views/native-inputs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<select class="w-full px-3 py-2 mt-1 text-sm border border-light-gray rounded-lg"
id="native-fs-{{ $key }}"
name="custom_fields[{{ $key }}]"
{{-- Akaunting Form reads select.getAttribute('value'), not the selected option.
Seed Vue's model before it overwrites the server-rendered selection. --}}
value="{{ $value }}"
v-model="form['custom_fields[{{ $key }}]']"
@if($field['is_required']) required @endif>
<option value="">{{ trans('field-studio::general.native.choose') }}</option>
Expand Down
3 changes: 3 additions & 0 deletions tests/api-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ const { request } = require(process.env.FS_PLAYWRIGHT_PATH || 'playwright');
let version = resp.body.data.find(v => v.field_key === required.field_key).value_version;
resp = await call('patch', valuesPath, { values: { [required.field_key]: 'CC-45' }, versions: { [required.field_key]: version } });
check('PATCH partial update', resp.status === 200 && resp.body.data.find(v => v.field_key === required.field_key).value === 'CC-45', resp);
check('PATCH omitting saved production selection retains it',
resp.status === 200 && resp.body.data.find(v => v.field_key === select.field_key)?.value === 'Operations'
&& resp.body.data.find(v => v.field_key === select.field_key)?.is_set === true, resp);
resp = await call('patch', valuesPath, { values: { [required.field_key]: 'stale' }, versions: { [required.field_key]: version } });
check('409 on stale version', resp.status === 409, resp);

Expand Down
20 changes: 18 additions & 2 deletions tests/ui-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,31 @@ const { chromium } = require(process.env.FS_PLAYWRIGHT_PATH || 'playwright');
assert.ok(await native.count() === 1, 'Field must be injected into the native invoice form');
assert.equal((await page.locator('#field-studio-native h3').innerText()).trim(), texts.nativeHeading,
'Native invoice section must follow the active locale');
// The initial value must survive Vue Form hydration. Akaunting seeds
// selects via their value attribute, not by reading selected options.
assert.equal(await native.inputValue(), 'Comercial',
'Previously saved select value must remain visible in the native form');
pass('Native invoice edit loads an existing Field Studio select value');
await native.selectOption('Administração');
await screenshot('field-studio-native-invoice');
await page.getByRole('button', { name: /^(Save|Salvar)$/, exact: true }).first().click();
await page.waitForTimeout(900);
assert.ok(page.url().includes('/sales/invoices/' + invoice), 'Native invoice update did not complete');
// Reopening the invoice is essential: an empty Vue model used to
// silently clear this field during the next unrelated invoice save.
await page.goto(base + '/' + company + '/sales/invoices/' + invoice + '/edit',
{ waitUntil: 'domcontentloaded' });
await page.getByText(/Advanced|Avançado/i, { exact: true }).first().click();
const reopened = page.locator('select[name="custom_fields[' + key + ']"]');
assert.equal(await reopened.inputValue(), 'Administração',
'The native select must retain its saved value after reopening');
await page.getByRole('button', { name: /^(Save|Salvar)$/, exact: true }).first().click();
await page.waitForTimeout(900);
await page.goto(base + '/' + company + '/field-studio/records/invoice/' + invoice,
{ waitUntil: 'domcontentloaded' });
assert.equal(await page.locator('select[name="values[' + key + ']"]').inputValue(), 'Administração');
pass('Native Akaunting invoice save persists Field Studio value');
assert.equal(await page.locator('select[name="values[' + key + ']"]').inputValue(), 'Administração',
'Saving the invoice again must not delete an unchanged Field Studio selection');
pass('Native Akaunting invoice saves and subsequent edits preserve Field Studio values');

await page.goto(base + '/' + company + '/field-studio', { waitUntil: 'domcontentloaded' });
let archiveConfirmation;
Expand Down
Loading