-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupsert.nut.ts
More file actions
88 lines (82 loc) · 2.97 KB
/
upsert.nut.ts
File metadata and controls
88 lines (82 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import { expect } from 'chai';
import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit';
import { Messages } from '@salesforce/core';
import ConnectedObjectUpsertResult from '../../../../src/commands/analytics/connected-objects/upsert.js';
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
Messages.importMessagesDirectory(dirname);
const messages = Messages.loadMessages('plugin-analytics-connected-objects', 'connected-objects.upsert');
describe('analytics connected-objects upsert NUTs', () => {
let session: TestSession;
let defaultUsername: string | undefined;
before(async () => {
session = await TestSession.create({
project: {
sourceDir: path.join('test', 'testProject'),
},
devhubAuthStrategy: 'AUTO',
scratchOrgs: [{ executable: 'sf', config: 'config/project-scratch-def.json', setDefault: true, wait: 10 }],
});
defaultUsername = session.orgs.get('default')?.username;
});
after(async () => {
await session?.clean();
});
it('should evaluate a single recipe and upsert the respective connected-objects', () => {
const name = 'Simple_Recipe';
const command = `analytics connected-objects upsert --recipe-names ${name} -o ${defaultUsername} --json`;
const result = execCmd<ConnectedObjectUpsertResult[]>(command, { ensureExitCode: 0, cli: 'sf' }).jsonOutput?.result;
expect(result).to.deep.equal([
{
connectorName: 'SFDC_LOCAL',
objectName: 'User',
isNew: true,
operation: 'Created',
fields: ['Id', 'Username'],
fieldsCount: 2,
},
]);
});
it('should evaluate multiple recipes and upsert the respective connected-objects (warn: 1 extra field found)', () => {
const name = 'Simple_Recipe,Complex_Recipe';
const command = `analytics connected-objects upsert --recipe-names ${name} -o ${defaultUsername} --json`;
const output = execCmd<ConnectedObjectUpsertResult[]>(command, { ensureExitCode: 0, cli: 'sf' }).jsonOutput;
expect(output).to.deep.equal({
status: 0,
result: [
{
connectorName: 'SFDC_LOCAL',
objectName: 'User',
isNew: false,
operation: 'Updated',
fields: [
'LastName',
'FirstName',
'CompanyName',
'Email',
'Phone',
'MobilePhone',
'UserRoleId',
'ProfileId',
'LanguageLocaleKey',
'LastLoginDate',
'CreatedDate',
'LastModifiedDate',
],
fieldsCount: 12,
},
{
connectorName: 'SFDC_LOCAL',
objectName: 'Profile',
isNew: true,
operation: 'Created',
fields: ['Id', 'Name'],
fieldsCount: 2,
},
],
warnings: [messages.getMessage('fields.not.found', ['User', 'SFDC_LOCAL', 'Extra__c'])],
});
});
});