Skip to content

Commit

Permalink
fix: type detection of EmailServicesFunction metadata type (scollad…
Browse files Browse the repository at this point in the history
  • Loading branch information
scolladon authored Apr 17, 2024
1 parent de4cc73 commit 8ac5518
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 34 deletions.
69 changes: 35 additions & 34 deletions .github/linters/.cspell.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
{
"ignorePaths": [
"**/CHANGELOG.md",
"**/node_modules/**",
"**/.git/**",
"**/megalinter.yml",
"**/yarn.lock",
"**/.yarnrc.yml",
"**/megalinter.yml",
"**/node_modules/**",
"**/src/metadata/**",
"**/src/service/typeHandlerFactory.ts"
"**/src/service/typeHandlerFactory.ts",
"**/yarn.lock"
],
"language": "en",
"noConfigSearch": true,
"version": "0.2",
"words": [
"\u00c0gain",
"Afile",
"CODECOV",
"CODEOWNERS",
"Cherfaoui",
"Colladon",
"Commitlint",
"depcheckrc",
"FORCEIGNORE",
"FORCEINCLUDE",
"FULLNAME",
"Flexi",
"gitdir",
"hardlinks",
"Iframe",
"knip",
"METAFILE",
"Mehdi",
"Nimn",
"Omni",
"Parens",
"SFDX",
"STATICRESOURCE",
"Scontrol",
"Sebastien",
"Sfdx",
"Translationline",
"Unpackaged",
"Wavehandler",
"amannn",
"anotherignore",
"apexskier",
Expand All @@ -51,43 +25,60 @@
"behaviour",
"benchmarkjs",
"brqh",
"Cherfaoui",
"codeclimate",
"codecov",
"CODECOV",
"CODEOWNERS",
"Colladon",
"commandsstop",
"commitlint",
"Commitlint",
"contentassets",
"customindex",
"datacategorygroup",
"datacategorygroups",
"depcheck",
"depcheckrc",
"destructiveignore",
"destructiveinclude",
"depcheck",
"emailservices",
"EMAILSERVICESFUNCTION",
"eslintcache",
"firstsha",
"Flexi",
"flexipage",
"flexipages",
"flowtest",
"flowtests",
"flowtype",
"forceignore",
"FORCEIGNORE",
"forceinclude",
"FORCEINCLUDE",
"friendlyname",
"FULLNAME",
"geodata",
"gitdir",
"hardlinks",
"iframe",
"Iframe",
"ignorewarnings",
"iife",
"indx",
"Infile",
"knip",
"lcov",
"linebreak",
"lintstagedrc",
"loglevel",
"lwcc",
"mdapi",
"megalinter",
"Mehdi",
"mehdisfdc",
"metafile",
"METAFILE",
"mjyhjbm",
"mkdirs",
"mocharc",
Expand All @@ -96,6 +87,7 @@
"mutingpermissionset",
"mutingpermissionsets",
"myexperiencebundle",
"Nimn",
"nonblock",
"notblank",
"notexist",
Expand All @@ -107,8 +99,10 @@
"oauthcustomscopes",
"oclif",
"omni",
"Omni",
"omnistudio",
"oxsecurity",
"Parens",
"pastsha",
"permissionset",
"permissionsetgroup",
Expand All @@ -127,12 +121,17 @@
"samlssoconfig",
"samlssoconfigs",
"scolladon",
"Scontrol",
"scontrols",
"Sebastien",
"sfdx",
"Sfdx",
"SFDX",
"sgdignore",
"sgdinclude",
"sgdincludedestructive",
"shellcheck",
"STATICRESOURCE",
"staticresources",
"stefanzweifel",
"struc",
Expand All @@ -141,14 +140,17 @@
"testkit",
"testlevel",
"testtest",
"Translationline",
"trivyignore",
"tsbuildinfo",
"unmanaged",
"unmocked",
"unpackaged",
"Unpackaged",
"venv",
"wagoid",
"wapp",
"Wavehandler",
"wcomp",
"wdash",
"wdpr",
Expand All @@ -158,7 +160,6 @@
"wireit",
"wlens",
"xmlbuilder",
"yarnrc",
"\u00c0gain"
"yarnrc"
]
}
25 changes: 25 additions & 0 deletions __tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ describe('MetadataRepositoryImpl', () => {
suffix: 'resource',
xmlName: 'StaticResource',
},
{
directoryName: 'emailservices',
inFolder: false,
metaFile: false,
suffix: 'xml',
xmlName: 'EmailServicesFunction',
},
])
})
describe('has', () => {
Expand Down Expand Up @@ -198,6 +205,16 @@ describe('MetadataRepositoryImpl', () => {
expect.objectContaining({ directoryName: 'moderation' })
)
})

it('matches `xml` files inside `emailservices` folder', () => {
// Act
const result = sut.get('force-app/emailservices/testService.xml')

// Assert
expect(result).toStrictEqual(
expect.objectContaining({ directoryName: 'emailservices' })
)
})
})

describe('when matching on extension', () => {
Expand Down Expand Up @@ -267,6 +284,14 @@ describe('MetadataRepositoryImpl', () => {
})

describe('when it should not match on extension', () => {
it('does not match `xml` files outside `emailservices` folder', () => {
// Act
const result = sut.get('manifest/specificTestClasses.xml')

// Assert
expect(result).toBeUndefined()
})

it('matches on folder', () => {
// Act
const result = sut.get(
Expand Down
1 change: 1 addition & 0 deletions src/constant/metadataConstants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

export const CUSTOM_APPLICATION_TYPE = 'applications'
export const EMAILSERVICESFUNCTION_SUFFIX = 'emailservices'
export const FIELD_DIRECTORY_NAME = 'fields'
export const FLOW_XML_NAME = 'Flow'
export const INFOLDER_SUFFIX = `Folder`
Expand Down
2 changes: 2 additions & 0 deletions src/metadata/MetadataRepositoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { parse } from 'path'
import { DOT, PATH_SEP } from '../constant/fsConstants'
import {
CUSTOM_APPLICATION_TYPE,
EMAILSERVICESFUNCTION_SUFFIX,
METAFILE_SUFFIX,
OBJECT_TRANSLATION_TYPE,
OBJECT_TYPE,
Expand Down Expand Up @@ -101,6 +102,7 @@ export class MetadataRepositoryImpl implements MetadataRepository {
private static EXTENSION_MATCHING_EXCEPTION = [
CUSTOM_APPLICATION_TYPE,
RESTRICTION_RULE_TYPE,
EMAILSERVICESFUNCTION_SUFFIX,
]

private static COMPOSED_TYPES = [
Expand Down

0 comments on commit 8ac5518

Please sign in to comment.