Added playwright tests. (#6212)

* Added playwright tests.

* Added clear authorship color.

* Ported enter ts.

* Ported more tests.

* Commented helper tests.

* Fixed admin tests.

* Fixed.

* Fixed admin pages not there.

* Fixed waiting.

* Upload playwright report.

* Remove saucelabs

* Fixed waiting.

* Fixed upload artifact.

* Also install deps.

* Added retry mechanism.

* Added timeout for restart etherpad server.

* Fixed tests.

* Added frontend playwright tests.
This commit is contained in:
SamTV12345 2024-03-10 23:18:50 +01:00 committed by GitHub
parent db46ffb63b
commit c2699e4528
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1568 additions and 1285 deletions

View file

@ -0,0 +1,59 @@
import {expect, test} from "@playwright/test";
import {loginToAdmin, restartEtherpad, saveSettings} from "../helper/adminhelper";
test.beforeEach(async ({ page })=>{
await loginToAdmin(page, 'admin', 'changeme1');
})
test.describe('admin settings',()=> {
test('Are Settings visible, populated, does save work', async ({page}) => {
await page.goto('http://localhost:9001/admin/settings');
await page.waitForSelector('.settings');
const settings = page.locator('.settings');
await expect(settings).not.toBeEmpty();
const settingsVal = await settings.inputValue()
const settingsLength = settingsVal.length
await settings.fill(`/* test */\n${settingsVal}`)
const newValue = await settings.inputValue()
expect(newValue).toContain('/* test */')
expect(newValue.length).toEqual(settingsLength+11)
await saveSettings(page)
// Check if the changes were actually saved
await page.reload()
await page.waitForSelector('.settings');
await expect(settings).not.toBeEmpty();
const newSettings = page.locator('.settings');
const newSettingsVal = await newSettings.inputValue()
expect(newSettingsVal).toContain('/* test */')
// Change back to old settings
await newSettings.fill(settingsVal)
await saveSettings(page)
await page.reload()
await page.waitForSelector('.settings');
await expect(settings).not.toBeEmpty();
const oldSettings = page.locator('.settings');
const oldSettingsVal = await oldSettings.inputValue()
expect(oldSettingsVal).toEqual(settingsVal)
expect(oldSettingsVal.length).toEqual(settingsLength)
})
test('restart works', async function ({page}) {
await page.goto('http://localhost:9001/admin/settings');
await page.waitForSelector('.settings')
await restartEtherpad(page)
await page.waitForSelector('.settings')
const settings = page.locator('.settings');
await expect(settings).not.toBeEmpty();
await page.waitForSelector('.menu')
});
})

View file

@ -0,0 +1,39 @@
import {expect, test} from "@playwright/test";
import {loginToAdmin} from "../helper/adminhelper";
test.beforeEach(async ({ page })=>{
await loginToAdmin(page, 'admin', 'changeme1');
await page.goto('http://localhost:9001/admin/help')
})
test('Shows troubleshooting page manager', async ({page}) => {
await page.goto('http://localhost:9001/admin/help')
await page.waitForSelector('.menu')
const menu = page.locator('.menu');
await expect(menu.locator('li')).toHaveCount(4);
})
test('Shows a version number', async function ({page}) {
await page.goto('http://localhost:9001/admin/help')
await page.waitForSelector('.menu')
const helper = page.locator('.help-block').locator('div').nth(1)
const version = (await helper.textContent())!.split('.');
expect(version.length).toBe(3)
});
test('Lists installed parts', async function ({page}) {
await page.goto('http://localhost:9001/admin/help')
await page.waitForSelector('.menu')
await page.waitForSelector('.innerwrapper ul')
const parts = page.locator('.innerwrapper ul').nth(1);
expect(await parts.textContent()).toContain('ep_etherpad-lite/adminsettings');
});
test('Lists installed hooks', async function ({page}) {
await page.goto('http://localhost:9001/admin/help')
await page.waitForSelector('.menu')
await page.waitForSelector('.innerwrapper ul')
const helper = page.locator('.innerwrapper ul').nth(2);
expect(await helper.textContent()).toContain('express');
});

View file

@ -0,0 +1,111 @@
import {expect, test} from "@playwright/test";
import {loginToAdmin} from "../helper/adminhelper";
test.beforeEach(async ({ page })=>{
await loginToAdmin(page, 'admin', 'changeme1');
await page.goto('http://localhost:9001/admin/plugins')
})
test.describe('Plugins page', ()=> {
test('List some plugins', async ({page}) => {
await page.waitForSelector('.search-field');
const pluginTable = page.locator('table tbody').nth(1);
await expect(pluginTable).not.toBeEmpty()
const plugins = await pluginTable.locator('tr').count()
expect(plugins).toBeGreaterThan(10)
})
test('Searches for a plugin', async ({page}) => {
await page.waitForSelector('.search-field');
await page.click('.search-field')
await page.keyboard.type('ep_font_color3')
await page.keyboard.press('Enter')
const pluginTable = page.locator('table tbody').nth(1);
await expect(pluginTable.locator('tr')).toHaveCount(1)
await expect(pluginTable.locator('tr').first()).toContainText('ep_font_color3')
})
test('Attempt to Install and Uninstall a plugin', async ({page}) => {
await page.waitForSelector('.search-field');
const pluginTable = page.locator('table tbody').nth(1);
await expect(pluginTable).not.toBeEmpty({
timeout: 15000
})
const plugins = await pluginTable.locator('tr').count()
expect(plugins).toBeGreaterThan(10)
// Now everything is loaded, lets install a plugin
await page.click('.search-field')
await page.keyboard.type('ep_font_color3')
await page.keyboard.press('Enter')
await expect(pluginTable.locator('tr')).toHaveCount(1)
const pluginRow = pluginTable.locator('tr').first()
await expect(pluginRow).toContainText('ep_font_color3')
// Select Installation button
await pluginRow.locator('td').nth(4).locator('button').first().click()
await page.waitForTimeout(100)
await page.waitForSelector('table tbody')
const installedPlugins = page.locator('table tbody').first()
const installedPluginsRows = installedPlugins.locator('tr')
await expect(installedPluginsRows).toHaveCount(2, {
timeout: 15000
})
const installedPluginRow = installedPluginsRows.nth(1)
await expect(installedPluginRow).toContainText('ep_font_color3')
await installedPluginRow.locator('td').nth(2).locator('button').first().click()
// Wait for the uninstallation to complete
await expect(installedPluginsRows).toHaveCount(1, {
timeout: 15000
})
})
})
/*
it('Attempt to Update a plugin', async function () {
this.timeout(280000);
await helper.waitForPromise(() => helper.admin$('.results').children().length > 50, 20000);
if (helper.admin$('.ep_align').length === 0) this.skip();
await helper.waitForPromise(
() => helper.admin$('.ep_align .version').text().split('.').length >= 2);
const minorVersionBefore =
parseInt(helper.admin$('.ep_align .version').text().split('.')[1]);
if (!minorVersionBefore) {
throw new Error('Unable to get minor number of plugin, is the plugin installed?');
}
if (minorVersionBefore !== 2) this.skip();
helper.waitForPromise(
() => helper.admin$('.ep_align .do-update').length === 1);
await timeout(500); // HACK! Please submit better fix..
const $doUpdateButton = helper.admin$('.ep_align .do-update');
$doUpdateButton.trigger('click');
// ensure its showing as Updating
await helper.waitForPromise(
() => helper.admin$('.ep_align .message').text() === 'Updating');
// Ensure it's a higher minor version IE 0.3.x as 0.2.x was installed
// Coverage for https://github.com/ether/etherpad-lite/issues/4536
await helper.waitForPromise(() => parseInt(helper.admin$('.ep_align .version')
.text()
.split('.')[1]) > minorVersionBefore, 60000, 1000);
// allow 50 seconds, check every 1 second.
});
*/