Skip to content

Commit e7060cf

Browse files
refactor: move test files, local project
1 parent 45c20e4 commit e7060cf

File tree

8 files changed

+66
-47
lines changed

8 files changed

+66
-47
lines changed

test/commands/api/request/graphql.nut.ts renamed to test/commands/api/request/graphql/graphql.nut.ts

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,9 @@ describe('api:request:graphql NUT', () => {
2424
setDefault: true,
2525
},
2626
],
27-
project: { gitClone: 'https://github.com/trailheadapps/dreamhouse-lwc' },
27+
project: { sourceDir: join('test', 'test-files', 'data-project') },
2828
devhubAuthStrategy: 'AUTO',
2929
});
30-
fs.writeFileSync(
31-
join(testSession.project.dir, 'standard.txt'),
32-
`query accounts {
33-
uiapi {
34-
query {
35-
Account {
36-
edges {
37-
node {
38-
Id
39-
Name {
40-
value
41-
}
42-
}
43-
}
44-
}
45-
}
46-
}
47-
}
48-
`
49-
);
50-
51-
fs.writeFileSync(
52-
join(testSession.project.dir, 'noResults.txt'),
53-
`query Address {
54-
uiapi {
55-
query {
56-
Address {
57-
edges {
58-
node {
59-
Id
60-
}
61-
}
62-
}
63-
}
64-
}
65-
}
66-
`
67-
);
6830
});
6931

7032
after(async () => {
@@ -73,7 +35,8 @@ describe('api:request:graphql NUT', () => {
7335

7436
describe('std out', () => {
7537
it('get result in json format', () => {
76-
const result = execCmd('api request graphql --body standard.txt').shellOutput.stdout;
38+
const result = execCmd(`api request graphql --body ${join(testSession.project.dir, 'standard.txt')}`).shellOutput
39+
.stdout;
7740
// eslint-disable-next-line no-console
7841
console.log('res', util.inspect(result));
7942

@@ -88,7 +51,8 @@ describe('api:request:graphql NUT', () => {
8851
});
8952

9053
it('get no results correctly', () => {
91-
const result = execCmd('api request graphql --body noResults.txt').shellOutput.stdout;
54+
const result = execCmd(`api request graphql --body ${join(testSession.project.dir, 'noResults.txt')}`).shellOutput
55+
.stdout;
9256
// eslint-disable-next-line no-console
9357
console.log('res', util.inspect(result));
9458
// make sure we got a JSON object back
@@ -103,7 +67,8 @@ describe('api:request:graphql NUT', () => {
10367

10468
describe('stream-to-file', () => {
10569
it('get result in json format', () => {
106-
execCmd('api request graphql --body standard.txt --stream-to-file out.txt').shellOutput.stdout;
70+
execCmd(`api request graphql --body ${join(testSession.project.dir, 'standard.txt')} --stream-to-file out.txt`)
71+
.shellOutput.stdout;
10772
// make sure we got a JSON object back
10873
const parsed = JSON.parse(fs.readFileSync(join(testSession.project.dir, 'out.txt'), 'utf8')) as Record<
10974
string,
@@ -117,7 +82,8 @@ describe('api:request:graphql NUT', () => {
11782
});
11883

11984
it('get no results correctly', () => {
120-
execCmd('api request graphql --body noResults.txt --stream-to-file empty.txt').shellOutput.stdout;
85+
execCmd(`api request graphql --body ${join(testSession.project.dir, 'noResults.txt')} --stream-to-file empty.txt`)
86+
.shellOutput.stdout;
12187

12288
// make sure we got a JSON object back
12389
const parsed = JSON.parse(fs.readFileSync(join(testSession.project.dir, 'empty.txt'), 'utf8')) as Record<

test/commands/api/request/graphql.test.ts renamed to test/commands/api/request/graphql/graphql.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import stripAnsi from 'strip-ansi';
1212
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
1313
import { sleep } from '@salesforce/kit';
1414
import nock = require('nock');
15-
import Graphql from '../../../../src/commands/api/request/graphql.js';
15+
import Graphql from '../../../../../src/commands/api/request/graphql.js';
1616

1717
describe('graphql', () => {
1818
const $$ = new TestContext();
@@ -75,7 +75,7 @@ describe('graphql', () => {
7575
it('should run and return graphql query', async () => {
7676
nock(testOrg.instanceUrl).post('/services/data/v42.0/graphql').reply(200, serverResponse);
7777

78-
await Graphql.run(['--target-org', 'test@hub.com', '--body', 'query.txt']);
78+
await Graphql.run(['--target-org', 'test@hub.com', '--body', 'standard.txt']);
7979

8080
const output = stripAnsi(stdoutSpy.args.flat().join(''));
8181

@@ -85,7 +85,7 @@ describe('graphql', () => {
8585
it('should redirect to file', async () => {
8686
nock(testOrg.instanceUrl).post('/services/data/v42.0/graphql').reply(200, serverResponse);
8787

88-
await Graphql.run(['--target-org', 'test@hub.com', '--body', 'query.txt', '--stream-to-file', 'myOutput1.txt']);
88+
await Graphql.run(['--target-org', 'test@hub.com', '--body', 'standard.txt', '--stream-to-file', 'myOutput1.txt']);
8989

9090
// gives it a second to resolve promises and close streams before we start asserting
9191
await sleep(1000);

test/commands/api/request/rest.test.ts renamed to test/commands/api/request/rest/rest.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import stripAnsi from 'strip-ansi';
1313
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
1414
import { sleep } from '@salesforce/kit';
1515
import nock = require('nock');
16-
import { Rest } from '../../../../src/commands/api/request/rest.js';
16+
import { Rest } from '../../../../../src/commands/api/request/rest.js';
1717

1818
describe('rest', () => {
1919
const $$ = new TestContext();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"orgName": "peter.hale company",
3+
"edition": "Developer",
4+
"features": ["EnableSetPasswordInApi", "ContactsToMultipleAccounts"],
5+
"settings": {
6+
"lightningExperienceSettings": {
7+
"enableS1DesktopEnabled": true
8+
},
9+
"mobileSettings": {
10+
"enableS1EncryptedStoragePref2": false
11+
}
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
query Address {
2+
uiapi {
3+
query {
4+
Address {
5+
edges {
6+
node {
7+
Id
8+
}
9+
}
10+
}
11+
}
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"packageDirectories": [
3+
{
4+
"path": "force-app",
5+
"default": true
6+
}
7+
],
8+
"namespace": "",
9+
"sfdcLoginUrl": "https://login.salesforce.com",
10+
"sourceApiVersion": "51.0"
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
query accounts {
2+
uiapi {
3+
query {
4+
Account {
5+
edges {
6+
node {
7+
Id
8+
Name {
9+
value
10+
}
11+
}
12+
}
13+
}
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)