Skip to content

Commit

Permalink
Fix script imports to correctly import a single script. Allow library…
Browse files Browse the repository at this point in the history
… scripts to be exported recursively. Make a few code refactoring changes as well.
  • Loading branch information
phalestrivir committed Aug 14, 2024
1 parent d23c322 commit 59159ac
Show file tree
Hide file tree
Showing 6 changed files with 13,999 additions and 13,786 deletions.
3 changes: 2 additions & 1 deletion src/ops/ConfigOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export async function exportFullConfiguration({
exportScripts,
{
options: {
includeLibraries: false,
deps: false,
includeDefault,
useStringArrays,
},
Expand Down Expand Up @@ -617,6 +617,7 @@ export async function importFullConfiguration({
scriptName: '',
importData: importData.realm[realm],
options: {
deps: false,
reUuid: reUuidScripts,
includeDefault,
},
Expand Down
28 changes: 23 additions & 5 deletions src/ops/ScriptOps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ describe('ScriptOps', () => {
lastModifiedDate: 0,
} as ScriptSkeleton,
};
const import1: { name: string; data: ScriptOps.ScriptExportInterface } = {
const import1: { id: string; name: string; data: ScriptOps.ScriptExportInterface } = {
id: '5b3e4dd2-8060-4029-9ec1-6867932ab939',
name: 'FrodoTestScript5',
data: {
meta: {
Expand Down Expand Up @@ -305,7 +306,8 @@ describe('ScriptOps', () => {
},
},
};
const import2: { name: string; data: ScriptOps.ScriptExportInterface } = {
const import2: { id: string; name: string; data: ScriptOps.ScriptExportInterface } = {
id: '01e1a3c0-038b-4c16-956a-6c9d89328cff',
name: 'Authentication Tree Decision Node Script',
data: {
meta: {
Expand Down Expand Up @@ -477,7 +479,7 @@ describe('ScriptOps', () => {
test('1: Export all scripts', async () => {
const response = await ScriptOps.exportScripts({
options: {
includeLibraries: false,
deps: false,
includeDefault: false,
useStringArrays: true,
},
Expand All @@ -491,7 +493,7 @@ describe('ScriptOps', () => {
test('2: Export all scripts, including default scripts', async () => {
const response = await ScriptOps.exportScripts({
options: {
includeLibraries: false,
deps: false,
includeDefault: true,
useStringArrays: true,
},
Expand All @@ -511,9 +513,11 @@ describe('ScriptOps', () => {
test(`1: Import all scripts`, async () => {
expect.assertions(1);
const outcome = await ScriptOps.importScripts({
scriptId: '',
scriptName: '',
importData: import1.data,
options: {
deps: true,
reUuid: false,
includeDefault: true,
},
Expand All @@ -525,19 +529,33 @@ describe('ScriptOps', () => {
test(`2: Import script by name`, async () => {
expect.assertions(1);
const result = await ScriptOps.importScripts({
scriptId: '',
scriptName: import1.name,
importData: import1.data,
state,
});
expect(result).toMatchSnapshot();
});

test(`3: Import no scripts when excluding default scripts and only default scripts given`, async () => {
test(`3: Import script by id`, async () => {
expect.assertions(1);
const result = await ScriptOps.importScripts({
scriptId: import1.id,
scriptName: '',
importData: import1.data,
state,
});
expect(result).toMatchSnapshot();
});

test(`4: Import no scripts when excluding default scripts and only default scripts given`, async () => {
expect.assertions(1);
const result = await ScriptOps.importScripts({
scriptId: '',
scriptName: '',
importData: import2.data,
options: {
deps: true,
reUuid: false,
includeDefault: false,
},
Expand Down
Loading

0 comments on commit 59159ac

Please sign in to comment.