Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data-export] Add query templates #161

Merged
merged 13 commits into from
Sep 27, 2023
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## General

- Add customizable query templates to query export page (idea and co-develop with [Samuel Krissi](https://github.com/samuelkrissi))
- Explore-api page restyling
- Ability to define csv-file separator [feature 144](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/144) (issue by [Reinier van den Assum](https://github.com/foxysolutions))
- Reduce the chances to hit limit on EntityDefinition query for large orgs [issue 138](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/138) (issue by [AjitRajendran](https://github.com/AjitRajendran))
Expand Down Expand Up @@ -72,7 +73,7 @@

## General

- Add checkbox in flow builder to give the possibility to the user to scroll on the flow (by [Samuel Krissi](https://github.com/samuelkrissi) )
- Add checkbox in flow builder to give the possibility to the user to scroll on the flow (by [Samuel Krissi](https://github.com/samuelkrissi))

![image](https://user-images.githubusercontent.com/96471586/226161542-cbedec0a-8988-4559-9152-d067ea6f9cb6.png)

Expand Down
68 changes: 34 additions & 34 deletions addon/data-export-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

export async function dataExportTest(test) {
console.log("TEST data-export");
let { assertEquals, assert, loadPage, anonApex } = test;
let {assertEquals, assert, loadPage, anonApex} = test;

localStorage.removeItem("insextQueryHistory");
localStorage.removeItem("insextSavedQueryHistory");

let { model, sfConn } = await loadPage("data-export.html");
let {model, sfConn} = await loadPage("data-export.html");
let vm = model;
let queryInput = model.queryInput;
function queryAutocompleteEvent() {
Expand Down Expand Up @@ -37,8 +37,8 @@ export async function dataExportTest(test) {
return list.map(el => el.value);
}

assertEquals("select Id from Account", queryInput.value);
queryInput.selectionStart = queryInput.selectionEnd = "select Id from Account".length; // When the cursor is placed after object name, we will try to autocomplete that once the global describe loads, and we will not try to load object field describes, so we can test loading those separately
assertEquals("SELECT Id FROM Account", queryInput.value);
queryInput.selectionStart = queryInput.selectionEnd = "SELECT Id FROM Account".length; // When the cursor is placed after object name, we will try to autocomplete that once the global describe loads, and we will not try to load object field describes, so we can test loading those separately
vm.queryAutocompleteHandler();

// Load global describe and user info
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function dataExportTest(test) {
assertEquals("select Id, shipp from Account", queryInput.value);
assertEquals("Account fields suggestions:", vm.autocompleteResults.title);
assertEquals(["ShippingAddress", "ShippingCity", "ShippingCountry", "ShippingGeocodeAccuracy", "ShippingLatitude", "ShippingLongitude", "ShippingPostalCode", "ShippingState", "ShippingStreet"], getValues(vm.autocompleteResults.results));
vm.queryAutocompleteHandler({ ctrlSpace: true });
vm.queryAutocompleteHandler({ctrlSpace: true});
assertEquals("select Id, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, ShippingLatitude, ShippingLongitude, ShippingGeocodeAccuracy, ShippingAddress from Account", queryInput.value);

// Autocomplete relationship field in SELECT
Expand Down Expand Up @@ -140,7 +140,7 @@ export async function dataExportTest(test) {
// Autocomplete datetime value
setQuery("select Id from Account where LastModifiedDate < TOD", "", " and IsDeleted = false");
assertEquals("Account.LastModifiedDate values:", vm.autocompleteResults.title);
assertEquals(["TODAY","N_DAYS_AGO:n"], getValues(vm.autocompleteResults.results));
assertEquals(["TODAY", "N_DAYS_AGO:n"], getValues(vm.autocompleteResults.results));
vm.autocompleteClick(vm.autocompleteResults.results[0]);
assertEquals("select Id from Account where LastModifiedDate < TODAY and IsDeleted = false", queryInput.value);

Expand Down Expand Up @@ -187,7 +187,7 @@ export async function dataExportTest(test) {
await waitForSpinner();
assertEquals("Profile.Name values (Press Ctrl+Space to load suggestions):", vm.autocompleteResults.title);
assertEquals([], getValues(vm.autocompleteResults.results));
vm.queryAutocompleteHandler({ ctrlSpace: true });
vm.queryAutocompleteHandler({ctrlSpace: true});
assertEquals("Loading Profile.Name values...", vm.autocompleteResults.title);
assertEquals([], getValues(vm.autocompleteResults.results));
await waitForSpinner();
Expand All @@ -200,7 +200,7 @@ export async function dataExportTest(test) {
setQuery("select Id from Account where Id = foo", "", ""); // LIKE query not supported by Id field
assertEquals("Account.Id values (Press Ctrl+Space to load suggestions):", vm.autocompleteResults.title);
assertEquals([], getValues(vm.autocompleteResults.results));
vm.queryAutocompleteHandler({ ctrlSpace: true });
vm.queryAutocompleteHandler({ctrlSpace: true});
assertEquals("Loading Account.Id values...", vm.autocompleteResults.title);
assertEquals([], getValues(vm.autocompleteResults.results));
await waitForSpinner();
Expand Down Expand Up @@ -283,11 +283,11 @@ export async function dataExportTest(test) {
assertEquals("Exported 4 record(s)", vm.exportStatus);
assertEquals([
["_", "Name", "Checkbox__c", "Number__c"],
[{ type: "Inspector_Test__c" }, "test1", false, 100.01],
[{ type: "Inspector_Test__c" }, "test2", true, 200.02],
[{ type: "Inspector_Test__c" }, "test3", false, 300.03],
[{ type: "Inspector_Test__c" }, "test4", true, 400.04]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? { type: cell.attributes.type } : cell)));
[{type: "Inspector_Test__c"}, "test1", false, 100.01],
[{type: "Inspector_Test__c"}, "test2", true, 200.02],
[{type: "Inspector_Test__c"}, "test3", false, 300.03],
[{type: "Inspector_Test__c"}, "test4", true, 400.04]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? {type: cell.attributes.type} : cell)));
assertEquals(null, vm.exportError);
assertEquals([true, true, true, true, true], vm.exportedData.rowVisibilities);
assertEquals([true, true, true, true], vm.exportedData.colVisibilities);
Expand All @@ -311,11 +311,11 @@ export async function dataExportTest(test) {
assertEquals("Exported 4 record(s)", vm.exportStatus);
assertEquals([
["_", "Name", "Checkbox__c", "Number__c"],
[{ type: "Inspector_Test__c" }, "test1", false, 100.01],
[{ type: "Inspector_Test__c" }, "test2", true, 200.02],
[{ type: "Inspector_Test__c" }, "test3", false, 300.03],
[{ type: "Inspector_Test__c" }, "test4", true, 400.04]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? { type: cell.attributes.type } : cell)));
[{type: "Inspector_Test__c"}, "test1", false, 100.01],
[{type: "Inspector_Test__c"}, "test2", true, 200.02],
[{type: "Inspector_Test__c"}, "test3", false, 300.03],
[{type: "Inspector_Test__c"}, "test4", true, 400.04]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? {type: cell.attributes.type} : cell)));
assertEquals(null, vm.exportError);
assertEquals([true, false, true, false, true], vm.exportedData.rowVisibilities);
assertEquals([true, true, true, true], vm.exportedData.colVisibilities);
Expand All @@ -326,11 +326,11 @@ export async function dataExportTest(test) {
assertEquals("Exported 4 record(s)", vm.exportStatus);
assertEquals([
["_", "Name", "Checkbox__c", "Number__c"],
[{ type: "Inspector_Test__c" }, "test1", false, 100.01],
[{ type: "Inspector_Test__c" }, "test2", true, 200.02],
[{ type: "Inspector_Test__c" }, "test3", false, 300.03],
[{ type: "Inspector_Test__c" }, "test4", true, 400.04]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? { type: cell.attributes.type } : cell)));
[{type: "Inspector_Test__c"}, "test1", false, 100.01],
[{type: "Inspector_Test__c"}, "test2", true, 200.02],
[{type: "Inspector_Test__c"}, "test3", false, 300.03],
[{type: "Inspector_Test__c"}, "test4", true, 400.04]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? {type: cell.attributes.type} : cell)));
assertEquals(null, vm.exportError);
assertEquals([true, true, true, true, true], vm.exportedData.rowVisibilities);
assertEquals([true, true, true, true], vm.exportedData.colVisibilities);
Expand All @@ -353,11 +353,11 @@ export async function dataExportTest(test) {
assertEquals("Exported 4 record(s)", vm.exportStatus);
assertEquals([
["_", "Name", "Lookup__r", "Lookup__r.Name"],
[{ type: "Inspector_Test__c" }, "test1", null, null],
[{ type: "Inspector_Test__c" }, "test2", { type: "Inspector_Test__c" }, "test1"],
[{ type: "Inspector_Test__c" }, "test3", null, null],
[{ type: "Inspector_Test__c" }, "test4", { type: "Inspector_Test__c" }, "test3"]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? { type: cell.attributes.type } : cell)));
[{type: "Inspector_Test__c"}, "test1", null, null],
[{type: "Inspector_Test__c"}, "test2", {type: "Inspector_Test__c"}, "test1"],
[{type: "Inspector_Test__c"}, "test3", null, null],
[{type: "Inspector_Test__c"}, "test4", {type: "Inspector_Test__c"}, "test3"]
], vm.exportedData.table.map(row => row.map(cell => cell && cell.attributes ? {type: cell.attributes.type} : cell)));
assertEquals(null, vm.exportError);
assertEquals([true, true, true, true, true], vm.exportedData.rowVisibilities);
assertEquals([true, true, true, true], vm.exportedData.colVisibilities);
Expand Down Expand Up @@ -521,12 +521,12 @@ export async function dataExportTest(test) {

// Query history
assertEquals([
{ query: "select Name from ApexClass", useToolingApi: true },
{ query: "select Id from Inspector_Test__c", useToolingApi: false },
{ query: "select count() from Inspector_Test__c", useToolingApi: false },
{ query: "select Id from Inspector_Test__c where name = 'no such name'", useToolingApi: false },
{ query: "select Name, Lookup__r.Name from Inspector_Test__c order by Name", useToolingApi: false },
{ query: "select Name, Checkbox__c, Number__c from Inspector_Test__c order by Name", useToolingApi: false }
{query: "select Name from ApexClass", useToolingApi: true},
{query: "select Id from Inspector_Test__c", useToolingApi: false},
{query: "select count() from Inspector_Test__c", useToolingApi: false},
{query: "select Id from Inspector_Test__c where name = 'no such name'", useToolingApi: false},
{query: "select Name, Lookup__r.Name from Inspector_Test__c order by Name", useToolingApi: false},
{query: "select Name, Checkbox__c, Number__c from Inspector_Test__c order by Name", useToolingApi: false}
], vm.queryHistory.list);
vm.selectedHistoryEntry = vm.queryHistory.list[2];
vm.selectHistoryEntry();
Expand Down
2 changes: 1 addition & 1 deletion addon/data-export.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ select,
input[type=search],
input[type=save],
input[type=default] {
width: 10rem;
width: 8.5rem;
font-family: inherit;
padding: 5px 13px;
border: 1px solid #DDDBDA;
Expand Down
Loading