test: migrate xpath selectors to text/regex locators

Replace xpath-based selectors in test.js with charlie's bare-text and
regex locators per the app-test migration guide. Fixes mocha-app CI
failures from xpath escape-hatch enforcement and exact-text mismatches
on Mastodon's banner and timeline copy.
This commit is contained in:
Elias Hackradt
2026-05-13 11:10:44 +02:00
parent 6feba78bf6
commit 89a6177023
+8 -8
View File
@@ -14,9 +14,9 @@ describe('Application life cycle test', function () {
}); });
async function checkRegistrationClosed() { async function checkRegistrationClosed() {
await goto(`https://${app.fqdn}`, 'xpath=//div[@class="sign-in-banner"]/descendant::button/span[contains(text(), "Create account")] | //div[@class="sign-in-banner"]/descendant::a/span[contains(text(), "Create account")]'); await goto(`https://${app.fqdn}`, 'Create account');
await click('xpath=//div[@class="sign-in-banner"]/descendant::button/span[contains(text(), "Create account")] | //div[@class="sign-in-banner"]/descendant::a/span[contains(text(), "Create account")]'); await click('Create account');
await waitFor('is currently not possible'); await waitFor(/is currently not possible/);
} }
async function login(addr, pass) { async function login(addr, pass) {
@@ -27,13 +27,13 @@ describe('Application life cycle test', function () {
} }
async function loginOidc() { async function loginOidc() {
await goto(`https://${app.fqdn}/auth/sign_in`, 'xpath=//a[contains(@class, "button") and text()="Cloudron"]'); await goto(`https://${app.fqdn}/auth/sign_in`, 'Cloudron');
await click('xpath=//a[contains(@class, "button") and text()="Cloudron"]'); await click('Cloudron');
await loginOIDC('xpath=//span[contains(., "Bookmarks")] | //strong[text()="Successfully authenticated from Cloudron account."]'); await loginOIDC(/Bookmarks|Successfully authenticated from Cloudron account\./);
} }
async function checkTimeline() { async function checkTimeline() {
await goto(`https://${app.fqdn}/home`, 'Your home timeline is empty'); await goto(`https://${app.fqdn}/home`, /Your home timeline is empty/);
} }
// No SSO // No SSO
@@ -53,7 +53,7 @@ describe('Application life cycle test', function () {
}); });
it('shows confirmation page', async function () { it('shows confirmation page', async function () {
await waitFor('xpath=//a[@href="/auth/confirmation/new"] | //form[@id="edit_user_1"]'); await waitFor('css=a[href="/auth/confirmation/new"], form#edit_user_1');
}); });
it('uninstall app (no sso)', cloudronCli.uninstall); it('uninstall app (no sso)', cloudronCli.uninstall);