From b5321af973dd6c535ae3f72554073425a25ab4e9 Mon Sep 17 00:00:00 2001 From: Thierry Parlier Date: Fri, 13 Oct 2023 22:07:24 +0400 Subject: [PATCH] Create a test for a new created play before be able to submit it --- .../template/_templates/play.cy_ts.tmpl | 27 +++++++++++++++++++ lib/services/template/play_content.js | 8 ++++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 lib/services/template/_templates/play.cy_ts.tmpl diff --git a/lib/services/template/_templates/play.cy_ts.tmpl b/lib/services/template/_templates/play.cy_ts.tmpl new file mode 100644 index 0000000..42f4052 --- /dev/null +++ b/lib/services/template/_templates/play.cy_ts.tmpl @@ -0,0 +1,27 @@ +/// + + +describe('Test %PLAY_TITLE_NAME_SANITIZED% play', () => { + beforeEach(() => { + cy.visit('/plays/%PLAY_URL%/'); + }); + + it('Header component should render properly', () => { + cy.header(); + }); + + it('Play page should contains author name', () => { + cy.contains('%PLAY_GITHUB%'); + }); + + + it('We should be able to see the details of the play', () => { + cy.get('.play-details').should('be.visible'); + }); + + + it('We should be able to see the actions', () => { + cy.get('.header-actions').should('be.visible'); + }); + +}); diff --git a/lib/services/template/play_content.js b/lib/services/template/play_content.js index b835658..17dc526 100644 --- a/lib/services/template/play_content.js +++ b/lib/services/template/play_content.js @@ -14,6 +14,7 @@ const TEMPLATE_DIRECTORY = "_templates"; const TEMPLATE_MAP = { common: ["Readme_md"], + cy: ['play.cy_ts'], js: ["component_js"], ts: ["component_tsx"], css: ["styles_css"], @@ -33,10 +34,13 @@ const createPlayDirectory = (play) => { return play_directory; }; + const processTemplates = (data, play_path) => { - processTemplate(data, "common", play_path); + data.url = `${toSlug(data.github.toLowerCase())}/${data.slug}`; + processTemplate(data, 'common', play_path); + processTemplate(data, 'cy', 'cypress/e2e'); processTemplate(data, data.language, play_path); - processTemplate(data, data.style || "css", play_path); + processTemplate(data, data.style || 'css', play_path); }; const replaceTemplateVar = (play_data, filePath) => {