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

DXCDT-377: E2E test cases for keyword presevation #753

Merged
merged 24 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2eb7e09
Renaming load to loadAssetsFromLocal
willvedd Feb 21, 2023
74d55d1
Renaming load to loadAssetsFromAuth0
willvedd Feb 21, 2023
93aae5a
Merge branch 'master' into DXCDT-375-rename-load-to-loadAssetsFromLocal
willvedd Feb 21, 2023
95b4bed
Merge branch 'master' into DXCDT-375-rename-load-to-loadAssetsFromLocal
willvedd Feb 21, 2023
3c82769
Merge branch 'DXCDT-375-rename-load-to-loadAssetsFromLocal' into DXCD…
willvedd Feb 21, 2023
90f8758
integrating into export process
willvedd Feb 22, 2023
4bea2cd
Adding config interpreter
willvedd Feb 22, 2023
8fc8498
Disabling keyword replacement in certain cases
willvedd Feb 22, 2023
e8c7b98
Resolving conflicts with master
willvedd Feb 22, 2023
df66ab0
Fixing directory load
willvedd Feb 22, 2023
4db97a1
More forgiving lookup logic if properties and/or addresses do not exist
willvedd Feb 22, 2023
f1f6a40
Fixing directory load again
willvedd Feb 22, 2023
6149064
Merge branch 'DXCDT-383-integrate-preserve-keywords-function-into-exp…
willvedd Feb 22, 2023
f5c7596
Adding case that would have previously tripped up process
willvedd Feb 22, 2023
a6153f0
Adding e2e tests for keyword preservation
willvedd Feb 22, 2023
ce3eba0
Removing old tests, updating recordings, removing console. logs
willvedd Feb 22, 2023
39ab7a7
Commenting-out test to fix later on
willvedd Feb 22, 2023
1b9a065
Fixing workdirectory for e2e tests
willvedd Feb 22, 2023
2212901
Adding eventual cases for auxillary files
willvedd Feb 22, 2023
32a7da8
Adding TODO
willvedd Feb 22, 2023
0d6ae19
Merge branch 'master' into DXCDT-377-keyword-preservation-e2e
sergiught Feb 23, 2023
6220010
Update test/e2e/testdata/should-preserve-keywords/yaml/tenant.yaml
sergiught Feb 23, 2023
6e0d599
Update test/e2e/recordings/should-preserve-keywords-for-directory-for…
sergiught Feb 23, 2023
d88f410
Update test/e2e/recordings/should-preserve-keywords-for-yaml-format.json
sergiught Feb 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion test/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect } from 'chai';
import path from 'path';
import fs from 'fs';
import { copySync } from 'fs-extra';
import { getFiles, existsMustBeDir } from '../../src/utils';
import { load as yamlLoad } from 'js-yaml';
import { setupRecording, testNameToWorkingDirectory } from './e2e-utils';
import { dump, deploy } from '../../src';
import exp from 'constants';
import { AssetTypes } from '../../src/types';

const shouldUseRecordings = process.env['AUTH0_HTTP_RECORDINGS'] === 'lockdown';
Expand Down Expand Up @@ -358,3 +358,84 @@ describe('#end-to-end keyword replacement', function () {
recordingDone();
});
});

describe('keyword preservation', () => {
const config = {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_PRESERVE_KEYWORDS: true,
AUTH0_INCLUDED_ONLY: ['tenant', 'emailTemplates'] as AssetTypes[],
AUTH0_KEYWORD_REPLACE_MAPPINGS: {
TENANT_NAME: 'This tenant name should be preserved',
DOMAIN: 'travel0.com',
LANGUAGES: ['en', 'es'],
},
};

it('should preserve keywords for yaml format', async function () {
const workDirectory = testNameToWorkingDirectory(this.test?.title);

const { recordingDone } = await setupRecording(this.test?.title);

await deploy({
input_file: `${__dirname}/testdata/should-preserve-keywords/yaml/tenant.yaml`,
config,
});

copySync(`${__dirname}/testdata/should-preserve-keywords/yaml`, workDirectory); //It is necessary to copy directory contents to work directory to prevent overwriting of Git-committed files

await dump({
output_folder: workDirectory,
format: 'yaml',
config,
});

const yaml = yamlLoad(fs.readFileSync(path.join(workDirectory, 'tenant.yaml')));
expect(yaml.tenant.friendly_name).to.equal('##TENANT_NAME##');
expect(yaml.tenant.support_email).to.equal('support@##DOMAIN##');
expect(yaml.tenant.support_url).to.equal('https://##DOMAIN##/support');
// expect(yaml.tenant.enabled_locales).to.equal('@@LANGUAGES@@'); TODO: enable @@ARRAY@@ keyword preservation in yaml formats

// const emailTemplateHTML = fs
// .readFileSync(path.join(workDirectory, 'emailTemplates', 'welcome_email.html'))
// .toString();
// expect(emailTemplateHTML).to.contain('##TENANT##'); TODO: enable keyword preservation in auxillary template files
Comment on lines +399 to +404
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the similar test below will be added in the coming days when the relevant fix has been added.


recordingDone();
});

it('should preserve keywords for directory format', async function () {
const workDirectory = testNameToWorkingDirectory(this.test?.title);

const { recordingDone } = await setupRecording(this.test?.title);

await deploy({
input_file: `${__dirname}/testdata/should-preserve-keywords/directory`,
config,
});

copySync(`${__dirname}/testdata/should-preserve-keywords/directory`, workDirectory); //It is necessary to copy directory contents to work directory to prevent overwriting of Git-committed files

await dump({
output_folder: workDirectory,
format: 'directory',
config,
});

const json = JSON.parse(fs.readFileSync(path.join(workDirectory, 'tenant.json')).toString());

expect(json.friendly_name).to.equal('##TENANT_NAME##');
expect(json.enabled_locales).to.equal('@@LANGUAGES@@');
expect(json.support_email).to.equal('support@##DOMAIN##');
expect(json.support_url).to.equal('https://##DOMAIN##/support');

// const emailTemplateHTML = fs
// .readFileSync(path.join(workDirectory, 'emailTemplates', 'welcome_email.html'))
// .toString();
// expect(emailTemplateHTML).to.contain('##TENANT##'); TODO: enable keyword preservation in auxillary template files

recordingDone();
});
});
Loading