diff --git a/tests/wdio/Makefile b/tests/wdio/Makefile index cffa80d18..172269f8b 100644 --- a/tests/wdio/Makefile +++ b/tests/wdio/Makefile @@ -8,7 +8,7 @@ help: ## Show this help ROOT := $(shell git rev-parse --show-toplevel 2> /dev/null) WDIO = npm run wdio -SPEC = $(WDIO) -- --spec ./test/specs +SPEC = $(WDIO) -- --logLevel warn --spec ./test/specs LOCAL_BLUEPRINTS=$(ROOT)/blueprints/local @@ -35,3 +35,7 @@ test-good-login: node_modules admin-user ## Test that we can log into the serve test-bad-login: node_modules admin-user ## Test that bad usernames and passwords create appropriate error messages $(SPEC)/bad-logins.ts + + +test-application-wizard-ldap: node_modules admin-user + $(SPEC)/new-wizard-ldap-application.ts diff --git a/tests/wdio/test/pageobjects/application-wizard.page.ts b/tests/wdio/test/pageobjects/application-wizard.page.ts index 691bd9e39..552753737 100644 --- a/tests/wdio/test/pageobjects/application-wizard.page.ts +++ b/tests/wdio/test/pageobjects/application-wizard.page.ts @@ -17,7 +17,7 @@ class ApplicationWizardView extends AdminPage { app = ApplicationForm; get wizardTitle() { - return $(">>>ak-application-wizard-commit-application h1.pf-c-title"); + return $(">>>ak-wizard-frame .pf-c-wizard__header h1.pf-c-title"); } get providerList() { diff --git a/tests/wdio/test/specs/new-wizard-ldap-application.ts b/tests/wdio/test/specs/new-wizard-ldap-application.ts index d0b06e094..8fc821dd6 100644 --- a/tests/wdio/test/specs/new-wizard-ldap-application.ts +++ b/tests/wdio/test/specs/new-wizard-ldap-application.ts @@ -1,12 +1,11 @@ import { login } from "../utils/login.js"; import { randomId } from "../utils/index.js"; import ApplicationsListPage from "../pageobjects/applications-list.page.js"; -import ApplicationsWizardView from "../pageobjects/applications-wizard.page.js"; -import ApplicationForm from "../pageobjects/application-form.view.js"; +import ApplicationWizardView from "../pageobjects/application-wizard.page.js"; import { expect } from "@wdio/globals"; -describe("Log into Authentik", () => { - it("should login with valid credentials and reach the UserLibrary", () => { +describe("Configure LDAP Application with Wizard", () => { + it("Should configure a simple LDAP Application", async () => { const newPrefix = randomId(); await login(); @@ -14,9 +13,23 @@ describe("Log into Authentik", () => { expect(await ApplicationsListPage.pageHeader).toHaveText("Applications"); await ApplicationsListPage.startWizardButton.click(); - await ApplicationsWizardView.wizardTitle.toBeVisible(); - expect(await ApplicationsWizardView.wizardTitle).toHaveText("Create Application"); + await ApplicationWizardView.wizardTitle.waitForDisplayed(); + expect(await ApplicationWizardView.wizardTitle).toHaveText("New Application"); - await ApplicationForm.name.setValue(`New LDAP Application - ${newPrefix}`); - + await ApplicationWizardView.app.name.setValue(`New LDAP Application - ${newPrefix}`); + await ApplicationWizardView.nextButton.click(); + await ApplicationWizardView.pause() + + await ApplicationWizardView.providerList.waitForDisplayed(); + await ApplicationWizardView.providerList.$('>>>input[value=ldapprovider]').click(); + await ApplicationWizardView.nextButton.click(); + await ApplicationWizardView.pause() + + await ApplicationWizardView.ldap.setBindFlow('default-authentication-flow'); + await ApplicationWizardView.nextButton.click(); + await ApplicationWizardView.pause() + + await ApplicationWizardView.commitMessage.waitForDisplayed(); + expect(await ApplicationWizardView.commitMessage).toHaveText("Your application has been saved"); + }) }); diff --git a/tests/wdio/test/utils/index.ts b/tests/wdio/test/utils/index.ts new file mode 100644 index 000000000..73e10a876 --- /dev/null +++ b/tests/wdio/test/utils/index.ts @@ -0,0 +1,15 @@ +export function randomId() { + let dt = new Date().getTime(); + return "xxxxxxxx".replace(/x/g, (c) => { + const r = (dt + Math.random() * 16) % 16 | 0; + dt = Math.floor(dt / 16); + return (c == "x" ? r : (r & 0x3) | 0x8).toString(16); + }); +} + +export function convertToSlug(text: string) { + return text + .toLowerCase() + .replace(/ /g, "-") + .replace(/[^\w-]+/g, ""); +}