-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DXCDT-388: Enabling preservation of array replace markers in YAML (#760)
* Renaming load to loadAssetsFromLocal * Renaming load to loadAssetsFromAuth0 * integrating into export process * Adding config interpreter * Disabling keyword replacement in certain cases * Fixing directory load * More forgiving lookup logic if properties and/or addresses do not exist * Fixing directory load again * Adding case that would have previously tripped up process * Adding e2e tests for keyword preservation * Removing old tests, updating recordings, removing console. logs * Commenting-out test to fix later on * Fixing workdirectory for e2e tests * Adding eventual cases for auxillary files * Adding TODO * Adding preqrequisite checks * Fixing test * Standardizing definitions of resource identifiers * Removing incompatible id from email templates * Readding identifiers field for resource server * Fixing email templates identifier field * Reformulating arguments into object * Adding e2e case * Init * Removing console log * Adding more robust e2e test * Updating recordings * Fixing database directory handler, test * Initial work at preserving array keyword markers in YAML * Fixing unit test * Removing console log * Simplifying e2e test and re-recording * Working for string replace markers now too * Continuing * Continuing * Making test slightly more clear * Removing extraneous changes * Being flexible for both single and double quotes YAML array replacement * Renaming function, adding comment --------- Co-authored-by: Will Vedder <[email protected]>
- Loading branch information
Showing
9 changed files
with
225 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import constants from './constants'; | ||
import deploy from './deploy'; | ||
import Auth0 from './auth0'; | ||
import { keywordReplace, loadFileAndReplaceKeywords } from './utils'; | ||
import { | ||
keywordReplace, | ||
loadFileAndReplaceKeywords, | ||
wrapArrayReplaceMarkersInQuotes, | ||
} from './utils'; | ||
|
||
export default { | ||
constants, | ||
deploy, | ||
keywordReplace, | ||
loadFileAndReplaceKeywords, | ||
wrapArrayReplaceMarkersInQuotes, | ||
Auth0, | ||
}; | ||
|
||
export { constants, deploy, keywordReplace, loadFileAndReplaceKeywords, Auth0 }; | ||
export { | ||
constants, | ||
deploy, | ||
keywordReplace, | ||
loadFileAndReplaceKeywords, | ||
wrapArrayReplaceMarkersInQuotes, | ||
Auth0, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,7 +320,7 @@ describe('#end-to-end keyword replacement', function () { | |
|
||
const keywordMapping = { | ||
COMPANY_NAME: 'Travel0', | ||
//LANGUAGES: ['en', 'es'], //TODO: support array replacement for directory format | ||
LANGUAGES: ['en', 'es'], | ||
}; | ||
|
||
await deploy({ | ||
|
@@ -424,7 +424,7 @@ describe('keyword preservation', () => { | |
yaml.emailTemplates.find(({ template }) => template === 'welcome_email').resultUrl | ||
).to.equal('https://##DOMAIN##/welcome'); | ||
|
||
// expect(yaml.tenant.enabled_locales).to.equal('@@LANGUAGES@@'); TODO: enable @@ARRAY@@ keyword preservation in yaml formats | ||
expect(yaml.tenant.enabled_locales).to.equal('@@LANGUAGES@@'); | ||
|
||
const emailTemplateHTML = fs | ||
.readFileSync(path.join(workDirectory, 'emailTemplates', 'welcome_email.html')) | ||
|
@@ -458,20 +458,30 @@ describe('keyword preservation', () => { | |
fs.readFileSync(path.join(workDirectory, 'tenant.json')).toString() | ||
); | ||
|
||
expect(jsonWithoutPreservation.friendly_name).to.equal('This tenant name should be preserved'); | ||
expect(jsonWithoutPreservation.enabled_locales).to.deep.equal(['en', 'es']); | ||
expect(jsonWithoutPreservation.support_email).to.equal('[email protected]'); | ||
expect(jsonWithoutPreservation.support_url).to.equal('https://travel0.com/support'); | ||
expect(jsonWithoutPreservation.friendly_name).to.equal( | ||
config.AUTH0_KEYWORD_REPLACE_MAPPINGS.TENANT_NAME | ||
); | ||
expect(jsonWithoutPreservation.enabled_locales).to.deep.equal( | ||
config.AUTH0_KEYWORD_REPLACE_MAPPINGS.LANGUAGES | ||
); | ||
expect(jsonWithoutPreservation.support_email).to.equal( | ||
`support@${config.AUTH0_KEYWORD_REPLACE_MAPPINGS.DOMAIN}` | ||
); | ||
expect(jsonWithoutPreservation.support_url).to.equal( | ||
`https://${config.AUTH0_KEYWORD_REPLACE_MAPPINGS.DOMAIN}/support` | ||
); | ||
|
||
const emailTemplateJsonWithoutPreservation = JSON.parse( | ||
fs.readFileSync(path.join(workDirectory, 'emails', 'welcome_email.json')).toString() | ||
); | ||
|
||
expect(emailTemplateJsonWithoutPreservation.resultUrl).to.equal('https://travel0.com/welcome'); | ||
expect(emailTemplateJsonWithoutPreservation.resultUrl).to.equal( | ||
`https://${config.AUTH0_KEYWORD_REPLACE_MAPPINGS.DOMAIN}/welcome` | ||
); | ||
|
||
expect( | ||
fs.readFileSync(path.join(workDirectory, 'emails', 'welcome_email.html')).toString() | ||
).to.contain('This tenant name should be preserved'); | ||
).to.contain(config.AUTH0_KEYWORD_REPLACE_MAPPINGS.TENANT_NAME); | ||
|
||
emptyDirSync(workDirectory); | ||
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 | ||
|
127 changes: 66 additions & 61 deletions
127
test/e2e/recordings/should-preserve-keywords-for-yaml-format.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters