Sending method, the owner's answers: nothing changes until another option is picked; the panel warns before the save
- a save that sends the method already shown, while nothing is stored, stores nothing: the site keeps sending exactly as before and keeps following what is filled in, until somebody picks ANOTHER option - the state block reads the form as it is edited and warns at once when "Own SMTP server" is picked with server, user name or password empty, or "Microsoft Graph" on a server without GRAPH_* (graphReady in the panel state); it reloads after every save - texts, doctor's info finding, docs, skills, changelog; reference e2e checks the warning Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
8c19391590
commit
dc3e594d38
+2
-1
@@ -752,7 +752,8 @@ describe('e-mail: transport, the mail service, Graph, the confirm route', () =>
|
||||
const open = await find({ methodChosen: false })
|
||||
expect(open.map((f) => f.severity)).toEqual(['info'])
|
||||
expect(open[0].message).toContain('the built-in service')
|
||||
expect(open[0].fix).toContain('save')
|
||||
expect(open[0].message).toContain('the way it did before the upgrade')
|
||||
expect(open[0].fix).toContain('nothing to do')
|
||||
expect(await find({ methodChosen: true })).toEqual([])
|
||||
// Postgres / SQLite whose 1.17.1 migration has not run
|
||||
const column = await find({ methodChosen: false, methodColumnMissing: true })
|
||||
|
||||
@@ -152,22 +152,50 @@ describe('upgrade, with no edit: the site shows the method it sends through toda
|
||||
})
|
||||
|
||||
describe('the choice: what is chosen is what is used', () => {
|
||||
test('the first save of the panel\'s form stores what the form shows; the answer shows it; the stored field of 1.17.0 follows', async () => {
|
||||
test('the owner\'s rule: saving without picking another option stores nothing and changes nothing; picking another one stores it', async () => {
|
||||
// an upgraded site on the service: the form is saved as it is, twice — nothing is chosen, mail goes as before
|
||||
await asStored({})
|
||||
for (const change of [{}, { smtpFromName: 'Kancelaria Example' }]) {
|
||||
const saved = await saveForm(change)
|
||||
expect(saved.status).toBe(200)
|
||||
expect(((await saved.json()) as { result: { emailMethod: string } }).result.emailMethod).toBe('relay')
|
||||
expect(await getMailMethod(payload)).toBeNull()
|
||||
}
|
||||
expect(await state()).toMatchObject({ methodChosen: false, transport: 'relay' })
|
||||
// …and it still follows what is filled in, as before (the old order): an SMTP server is filled in → SMTP
|
||||
await payload.updateGlobal({ slug: 'site-integrations' as never, data: SMTP as never })
|
||||
expect((await read()).emailMethod).toBe('smtp')
|
||||
expect(await getMailMethod(payload)).toBeNull()
|
||||
// a Graph site saved as it is stays a Graph site (the old order), with the variables
|
||||
for (const name of GRAPH_ENV) {vi.stubEnv(name, 'x')}
|
||||
await asStored({ emailTransport: 'graph' })
|
||||
await saveForm({})
|
||||
expect(await getMailMethod(payload)).toBeNull()
|
||||
expect(await read()).toMatchObject({ emailMethod: 'graph', emailTransport: 'graph' })
|
||||
for (const name of GRAPH_ENV) {vi.stubEnv(name, '')}
|
||||
// picking ANOTHER option stores it, and the answer shows it; the stored field of 1.17.0 follows
|
||||
await asStored({})
|
||||
const saved = await saveForm({ smtpFromName: 'Kancelaria Example' })
|
||||
expect(saved.status).toBe(200)
|
||||
expect(((await saved.json()) as { result: { emailMethod: string } }).result.emailMethod).toBe('relay')
|
||||
expect(await getMailMethod(payload)).toBe('relay')
|
||||
expect(await state()).toMatchObject({ methodChosen: true, transport: 'relay' })
|
||||
// a choice changed in the form
|
||||
const changed = await saveForm({ emailMethod: 'graph' })
|
||||
expect(((await changed.json()) as { result: { emailMethod: string; emailTransport: string } }).result).toMatchObject({ emailMethod: 'graph', emailTransport: 'graph' })
|
||||
expect(await getMailMethod(payload)).toBe('graph')
|
||||
expect((await read()).emailMethod).toBe('graph')
|
||||
// once chosen, a save that keeps it keeps it, and the method no longer follows what is filled in
|
||||
await saveForm({ emailMethod: 'relay' })
|
||||
expect(await getMailMethod(payload)).toBe('relay')
|
||||
await saveForm({ smtpFromName: 'Kancelaria Example' })
|
||||
expect(await getMailMethod(payload)).toBe('relay')
|
||||
await payload.updateGlobal({ slug: 'site-integrations' as never, data: SMTP as never })
|
||||
expect(await state()).toMatchObject({ methodChosen: true, transport: 'relay' })
|
||||
await saveForm({ emailMethod: 'smtp' })
|
||||
expect(await read()).toMatchObject({ emailMethod: 'smtp', emailTransport: 'smtp' })
|
||||
})
|
||||
|
||||
test('the state block is told whether Graph could send, for its warning before the save', async () => {
|
||||
await asStored({})
|
||||
expect((await state()).graphReady).toBe(false)
|
||||
for (const name of GRAPH_ENV) {vi.stubEnv(name, 'x')}
|
||||
expect((await state()).graphReady).toBe(true)
|
||||
})
|
||||
|
||||
test('"IWSN" chosen: the service carries the mail although an SMTP server is filled in and the GRAPH_* variables are set', async () => {
|
||||
await asStored(SMTP)
|
||||
await saveForm({ emailMethod: 'relay' })
|
||||
|
||||
Reference in New Issue
Block a user