diff --git a/src/context/directory/handlers/pages.ts b/src/context/directory/handlers/pages.ts index a37688702..a34698058 100644 --- a/src/context/directory/handlers/pages.ts +++ b/src/context/directory/handlers/pages.ts @@ -35,7 +35,7 @@ function parse(context: DirectoryContext): ParsedPages { log.warn(`Skipping pages file ${html} as missing the corresponding '.json' file`); return []; } - if (!html && key === 'error_page') { + if (!html && ['error_page', 'login'].includes(key)) { //Error pages don't require an HTML template, it is valid to redirect errors to URL return { ...loadJSON(meta, context.mappings), diff --git a/test/context/directory/pages.test.js b/test/context/directory/pages.test.js index ee2510e11..c827ef286 100644 --- a/test/context/directory/pages.test.js +++ b/test/context/directory/pages.test.js @@ -44,25 +44,34 @@ describe('#directory context pages', () => { expect(context.assets.pages).to.deep.equal(pagesTarget); }); - it('should process pages even without error_page HTML file', async () => { + it('should process login and error pages without HTML files', async () => { const repoDir = path.join(testDataDir, 'directory', 'pages4'); - const noErrorPageHtml = (() => { - const newPages = { ...pages }; - delete newPages['error_page.html']; - return newPages; - })(); - createDir(repoDir, { [constants.PAGES_DIRECTORY]: noErrorPageHtml }); + + const pagesNoHtml = { + 'login.json': '{ "name": "login", "enabled": false }', + 'error_page.json': + '{ "name": "error_page", "url": "https://example.com/error", "show_log_link": false }', + }; + + createDir(repoDir, { [constants.PAGES_DIRECTORY]: pagesNoHtml }); const config = { AUTH0_INPUT_FILE: repoDir }; const context = new Context(config, mockMgmtClient()); await context.load(); - expect(context.assets.pages.find((page) => page.name === 'error_page')).to.deep.equal({ - html: '', - name: 'error_page', - show_log_link: false, - url: 'https://example.com/error', - }); + expect(context.assets.pages).to.deep.equal([ + { + html: '', + name: 'error_page', + show_log_link: false, + url: 'https://example.com/error', + }, + { + html: '', + name: 'login', + enabled: false, + }, + ]); }); it('should ignore unknown file', async () => {