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-378: Keyword Replacement E2E Tests #735

Merged
merged 9 commits into from
Feb 8, 2023
113 changes: 113 additions & 0 deletions test/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,116 @@ describe('#end-to-end dump and deploy cycle', function () {
recordingDone();
});
});

describe('#end-to-end keyword replacement', function () {
it('should deploy yaml config with keyword replacements', async function () {
const { recordingDone } = await setupRecording(this.test?.title);

//Resetting tenant to baseline state
await deploy({
input_file: `${__dirname}/testdata/keyword-replacements/yaml/_reset.yaml`,
config: {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_INCLUDED_ONLY: ['tenant'],
},
});

const keywordMapping = {
COMPANY_NAME: 'Travel0',
LANGUAGES: ['en', 'es'],
};

await deploy({
input_file: `${__dirname}/testdata/keyword-replacements/yaml/tenant.yaml`,
config: {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_INCLUDED_ONLY: ['tenant'],
AUTH0_KEYWORD_REPLACE_MAPPINGS: keywordMapping,
},
});

const workDirectory = testNameToWorkingDirectory(this.test?.title);
await dump({
output_folder: workDirectory,
format: 'yaml',
config: {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_INCLUDED_ONLY: ['tenant'],
},
});

const files = getFiles(workDirectory, ['.yaml']);
expect(files).to.have.length(1);
expect(files[0]).to.equal(path.join(workDirectory, 'tenant.yaml'));

const yaml = yamlLoad(fs.readFileSync(files[0]));
expect(yaml.tenant.friendly_name).to.equal(`This is the ${keywordMapping.COMPANY_NAME} Tenant`);
expect(yaml.tenant.enabled_locales).to.deep.equal(keywordMapping.LANGUAGES);

recordingDone();
});

it('should deploy directory (JSON) config with keyword replacements', async function () {
const { recordingDone } = await setupRecording(this.test?.title);

//Resetting tenant to baseline state
await deploy({
input_file: `${__dirname}/testdata/keyword-replacements/directory`,
config: {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_INCLUDED_ONLY: ['tenant'],
},
});

const keywordMapping = {
COMPANY_NAME: 'Travel0',
//LANGUAGES: ['en', 'es'], //TODO: support array replacement for directory format
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was discovered during this work that the @@ array syntax does not work for directory formats. It does work for the YAML handler though. This will need to be addressed in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: Actually, this is a mistake with how I did the E2E test originally and has since been fixed.

};

await deploy({
input_file: `${__dirname}/testdata/keyword-replacements/directory`,
config: {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_INCLUDED_ONLY: ['tenant'],
AUTH0_KEYWORD_REPLACE_MAPPINGS: keywordMapping,
},
});

const workDirectory = testNameToWorkingDirectory(this.test?.title);
await dump({
output_folder: workDirectory,
format: 'directory',
config: {
AUTH0_DOMAIN,
AUTH0_CLIENT_ID,
AUTH0_CLIENT_SECRET,
AUTH0_ACCESS_TOKEN,
AUTH0_INCLUDED_ONLY: ['tenant'],
},
});

const files = getFiles(workDirectory, ['.json']);
expect(files).to.have.length(1);
expect(files[0]).to.equal(path.join(workDirectory, 'tenant.json'));

const json = JSON.parse(fs.readFileSync(files[0]).toString());
expect(json.friendly_name).to.equal(`This is the ${keywordMapping.COMPANY_NAME} Tenant`);

recordingDone();
});
});
Loading