This commit is contained in:
@@ -108,3 +108,12 @@ export const EnlargedSellerContact = {
|
||||
return () => { document.documentElement.style.fontSize = original; };
|
||||
},
|
||||
};
|
||||
|
||||
export const ClearedSellerContacts = {
|
||||
args: { ...ListingDetail.args, sellerContactEmail: null, sellerContactPhone: null },
|
||||
play: async ({ canvasElement }) => {
|
||||
const seller = within(within(canvasElement).getByRole('region', { name: 'Sold by' }));
|
||||
await expect(seller.getByText('Pika Collectibles')).toBeVisible();
|
||||
await expect(seller.queryAllByRole('link')).toHaveLength(0);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,10 +5,13 @@ export default {
|
||||
title: 'Pages/AdminSettingsPage', component: AdminSettingsPage,
|
||||
beforeEach: () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
let stored = { general: { publicDescription: 'Independent collector.', publicContactEmail: 'collector@example.test' } };
|
||||
let stored = { general: { publicDescription: 'Independent collector.', publicContactEmail: 'collector@example.test', publicContactPhone: '555-0100' } };
|
||||
globalThis.fetch = async (url, options) => {
|
||||
if (!String(url).endsWith('/admin/settings')) return originalFetch(url, options);
|
||||
if (options?.method === 'PATCH') stored = JSON.parse(options.body);
|
||||
if (options?.method === 'PATCH') {
|
||||
const update = JSON.parse(options.body);
|
||||
stored = { ...stored, ...update, general: { ...stored.general, ...update.general } };
|
||||
}
|
||||
return new Response(JSON.stringify({ data: stored }), { headers: { 'content-type': 'application/json' } });
|
||||
};
|
||||
return () => { globalThis.fetch = originalFetch; };
|
||||
@@ -32,3 +35,24 @@ export const EditAndClearDescription = {
|
||||
await expect(field).toHaveValue('');
|
||||
},
|
||||
};
|
||||
|
||||
export const ClearPublicContacts = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const email = await canvas.findByLabelText('Public contact email (optional)');
|
||||
const phone = canvas.getByLabelText('Public contact phone (optional)');
|
||||
await expect(email).toHaveValue('collector@example.test');
|
||||
await expect(phone).toHaveValue('555-0100');
|
||||
await userEvent.clear(email);
|
||||
await userEvent.click(canvas.getByRole('button', { name: 'Save settings' }));
|
||||
await waitFor(() => expect(canvas.getByRole('status')).toHaveTextContent('Settings saved.'));
|
||||
await expect(email).toHaveValue('');
|
||||
await expect(phone).toHaveValue('555-0100');
|
||||
await userEvent.clear(phone);
|
||||
await userEvent.click(canvas.getByRole('button', { name: 'Save settings' }));
|
||||
await waitFor(() => expect(canvas.getByRole('status')).toHaveTextContent('Settings saved.'));
|
||||
await expect(email).toHaveValue('');
|
||||
await expect(phone).toHaveValue('');
|
||||
await expect(canvas.getByLabelText('Public seller description (optional)')).toHaveValue('Independent collector.');
|
||||
},
|
||||
};
|
||||
|
||||
@@ -37,8 +37,8 @@ async function save() {
|
||||
...settings,
|
||||
general: {
|
||||
...settings.general,
|
||||
publicContactEmail: settings.general.publicContactEmail || undefined,
|
||||
publicContactPhone: settings.general.publicContactPhone || undefined,
|
||||
publicContactEmail: settings.general.publicContactEmail ?? '',
|
||||
publicContactPhone: settings.general.publicContactPhone ?? '',
|
||||
},
|
||||
};
|
||||
Object.assign(settings, await updateAdminSettings(payload, csrfToken()));
|
||||
@@ -66,10 +66,11 @@ onMounted(load);
|
||||
<label class="fixture-label" for="settings-description">Public seller description (optional)</label>
|
||||
<p id="settings-description-help">Shown on public listing and product pages. Up to 2,000 characters. Clear to remove.</p>
|
||||
<textarea id="settings-description" v-model="settings.general.publicDescription" class="fixture-input" rows="5" maxlength="2000" aria-describedby="settings-description-help" />
|
||||
<label class="fixture-label" for="settings-email">Public contact email</label>
|
||||
<input id="settings-email" v-model="settings.general.publicContactEmail" class="fixture-input" type="email" />
|
||||
<label class="fixture-label" for="settings-phone">Public contact phone</label>
|
||||
<input id="settings-phone" v-model="settings.general.publicContactPhone" class="fixture-input" />
|
||||
<label class="fixture-label" for="settings-email">Public contact email (optional)</label>
|
||||
<input id="settings-email" v-model="settings.general.publicContactEmail" class="fixture-input" type="email" aria-describedby="settings-contact-help" />
|
||||
<label class="fixture-label" for="settings-phone">Public contact phone (optional)</label>
|
||||
<input id="settings-phone" v-model="settings.general.publicContactPhone" class="fixture-input" type="tel" maxlength="50" aria-describedby="settings-contact-help" />
|
||||
<p id="settings-contact-help">Shown on public listing and product pages. Clear a field and save to remove that contact method.</p>
|
||||
</fieldset>
|
||||
<fieldset class="showcase-panel">
|
||||
<legend>Inventory</legend>
|
||||
|
||||
Reference in New Issue
Block a user