Skip to content

Commit

Permalink
DXCDT-378: Keyword Replacement E2E Tests (#735)
Browse files Browse the repository at this point in the history
* Adding keyword replacement test for yaml and recordings

* Adding keyword replacement test for directory and recordings

* Update test/e2e/testdata/keyword-replacements/yaml/tenant.yaml

Co-authored-by: Sergiu Ghitea <[email protected]>

* Update test/e2e/testdata/keyword-replacements/yaml/_reset.yaml

Co-authored-by: Sergiu Ghitea <[email protected]>

* Update test/e2e/testdata/keyword-replacements/directory/tenant.json

Co-authored-by: Sergiu Ghitea <[email protected]>

* Update test/e2e/recordings/should-deploy-directory-(JSON)-config-with-keyword-replacements.json

Co-authored-by: Sergiu Ghitea <[email protected]>

* Update test/e2e/recordings/should-deploy-yaml-config-with-keyword-replacements.json

Co-authored-by: Sergiu Ghitea <[email protected]>

* Update test/e2e/testdata/keyword-replacements/directory/_reset.json

Co-authored-by: Sergiu Ghitea <[email protected]>

---------

Co-authored-by: Will Vedder <[email protected]>
Co-authored-by: Sergiu Ghitea <[email protected]>
  • Loading branch information
3 people authored Feb 8, 2023
1 parent 0221678 commit eb38eff
Show file tree
Hide file tree
Showing 7 changed files with 849 additions and 0 deletions.
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
};

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

0 comments on commit eb38eff

Please sign in to comment.