diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d420b083..e2324c8ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: [ develop ] pull_request: - branches: [ develop, master ] + branches: [ develop, main ] workflow_dispatch: env: @@ -16,7 +16,6 @@ env: DB_PASSWORD: cmfive_test DB_DATABASE: cmfive_test PLAYWRIGHT_MODULES: "admin channel form tag report task timelog" - BOILERPLATE_IMAGE: ghcr.io/2pisoftware/cmfive:develop jobs: # Lint @@ -53,12 +52,26 @@ jobs: with: path: core + # Set Boilerplate variables by determing which image and branch to use + - name: Set Boilerplate Vars + id: boilerplate_vars + run: | + if [ "${{ github.ref }}" == "refs/heads/main" ] || [ "${{ github.event.pull_request.base.ref }}" == "main" ]; then + # Base branch or current branch of core is main + echo "BOILERPLATE_IMAGE=ghcr.io/2pisoftware/cmfive:latest" >> $GITHUB_ENV + echo "BOILERPLATE_BRANCH=master" >> $GITHUB_ENV + else + # Base branch or current branch of core is another branch + echo "BOILERPLATE_IMAGE=ghcr.io/2pisoftware/cmfive:develop" >> $GITHUB_ENV + echo "BOILERPLATE_BRANCH=develop" >> $GITHUB_ENV + fi + # Checkout the boilerplate - name: Checkout Boilerplate uses: actions/checkout@v4 with: repository: '2pisoftware/cmfive-boilerplate' - ref: 'develop' + ref: ${{ env.BOILERPLATE_BRANCH }} path: boilerplate # Pre-requisites Prepare Cmfive Environment @@ -121,7 +134,7 @@ jobs: -e DB_USERNAME=$DB_USERNAME \ -e DB_PASSWORD=$DB_PASSWORD \ -e DB_DATABASE=$DB_DATABASE \ - -e CMFIVE_CORE_BRANCH=$CORE_BRANCH \ + -e INSTALL_CORE_BRANCH=$CORE_BRANCH \ -e ENVIRONMENT=development \ --network=cmfive \ $BOILERPLATE_IMAGE diff --git a/system/modules/admin/actions/templates/edit.php b/system/modules/admin/actions/templates/edit.php index e13fcd430..f068706e5 100755 --- a/system/modules/admin/actions/templates/edit.php +++ b/system/modules/admin/actions/templates/edit.php @@ -50,7 +50,7 @@ function edit_GET(Web $w) "id|name" => "description", "value" => $t->description, "label" => "Description", - ]))->setOptions(["placeholder" => "Please provide a brief description of the template"]) //["", "textarea", "description", $t->description] + ]))->setOptions(["placeholder" => "Please provide a brief description of the template"]) ], ]; @@ -63,15 +63,15 @@ function edit_GET(Web $w) "id|name" => "template_title", "value" => $t->template_title, "maxlength" => 100 - ])) //["", "textarea", "template_title", $t->template_title, 100, 1, false] + ])) ] ]; $newForm["Template Body"] = [ [ (new \Html\Cmfive\CodeMirrorEditor([ "id|name" => "template_body", - "value" => $t->template_body, - ])) //->addToConfig(['extensions' => ['basicSetup'], 'parent' => 'template_body']) //["", "textarea", "template_body", $t->template_body, 60, 100, "codemirror"] + "value" => htmlspecialchars($t->template_body), + ])) ] ]; diff --git a/system/modules/admin/tests/acceptance/playwright/admin.test.ts b/system/modules/admin/tests/acceptance/playwright/admin.test.ts index 8d8de15f8..d232e5528 100644 --- a/system/modules/admin/tests/acceptance/playwright/admin.test.ts +++ b/system/modules/admin/tests/acceptance/playwright/admin.test.ts @@ -175,6 +175,41 @@ test("Test that Cmfive Admin handles templates", async ({ page }) => { await expect(templateTestPage.getByText("Test Company")).toBeVisible(); }); +test("Test that Cmfive Admin handles bad templates", async ({ page }) => { + test.setTimeout(GLOBAL_TIMEOUT); + + await CmfiveHelper.login(page, "admin", "admin"); + + const template = CmfiveHelper.randomID("template_"); + const templateID = await AdminHelper.createTemplate(page, template, "Admin", "Templates", [ + "", + "", + "", + " ", + " ", + " ", + " ", + "
", + " ", + " ", + " Test Company
", + " 123 Test St, Test Town, NSW 1234
", + " test@example.com
", + " ACN: 123456789
", + " ABN: 12345678901
", + "
", + ]); + + await AdminHelper.viewTemplate(page, template, templateID); + await page.getByRole("link", {name: "Template"}).click(); + + await expect(await page.locator('.cm-line')).toHaveCount(22); +}); + test("Test that Cmfive Admin can create/run/rollback migrations", async ({ page }) => { test.setTimeout(GLOBAL_TIMEOUT); CmfiveHelper.acceptDialog(page); diff --git a/system/modules/admin/tests/acceptance/playwright/admin.utils.ts b/system/modules/admin/tests/acceptance/playwright/admin.utils.ts index 275df3a52..d8d635b95 100644 --- a/system/modules/admin/tests/acceptance/playwright/admin.utils.ts +++ b/system/modules/admin/tests/acceptance/playwright/admin.utils.ts @@ -277,6 +277,16 @@ export class AdminHelper { return page.url().split("/admin-templates/edit/")[1].split("#")[0]; } + static async viewTemplate(page: Page, templateTitle: string, templateID: string): Promise + { + if (page.url() != HOST + "/admin-templates/edit/" + templateID + "#details") { + if(page.url() != HOST + "/admin-templates") + await CmfiveHelper.clickCmfiveNavbar(page, "Admin", "Templates"); + + await CmfiveHelper.getRowByText(page, templateTitle).getByRole("button", {name: "Edit"}).click(); + } + } + static async demoTemplate(page: Page, templateTitle: string, templateID: string): Promise { if(page.url() != HOST + "/admin-templates/edit/" + templateID + "#details") {