0a43ea286e
This commit replaces the previous WDIO instance with a more formal and straightforward process using the [pageobjects](https://martinfowler.com/bliki/PageObject.html). In this form, every major component has its own test suite, and a test is a sequence of exercises of those components. A test then becomes something as straightforward as: ``` await LoginPage.open(); await LoginPage.login("ken@goauthentik.io", "eat10bugs"); expect(await UserLibraryPage.pageHeader).toHaveText("My Applications"); await UserLibraryPage.goToAdmin(); expect(await AdminOverviewPage.pageHeader).toHaveText("Welcome, "); await AdminOverviewPage.openApplicationsListPage(); expect(await ApplicationsListPage.pageHeader).toHaveText("Applications"); ApplicationsListPage.startCreateApplicationWizard(); await ApplicationWizard.app.name.setValue(`Test application ${newId}`); await ApplicationWizard.nextButton.click(); await (await ApplicationWizard.getProviderType("ldapprovider")).click(); await ApplicationWizard.nextButton.click(); await ApplicationWizard.ldap.setBindFlow("default-authentication-flow"); await ApplicationWizard.nextButton.click(); await expect(await ApplicationWizard.commitMessage).toHaveText( "Your application has been saved" ); ``` Whether or not there's another layer of DSL in there or not, this is a pretty nice idiom for maintaining tests.
23 lines
516 B
TypeScript
23 lines
516 B
TypeScript
import { $ } from "@wdio/globals";
|
|
import Page from "./page.js";
|
|
|
|
/**
|
|
* sub page containing specific selectors and methods for a specific page
|
|
*/
|
|
class UserLibraryPage extends Page {
|
|
/**
|
|
* define selectors using getter methods
|
|
*/
|
|
|
|
public get pageHeader() {
|
|
return $('>>>h1[aria-level="1"]');
|
|
}
|
|
|
|
public async goToAdmin() {
|
|
await $('>>>a[href="/if/admin"]').click();
|
|
await $(">>>ak-admin-overview").waitForDisplayed();
|
|
}
|
|
}
|
|
|
|
export default new UserLibraryPage();
|