Skip to content

Commit

Permalink
tests: add playwright CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osundwajeff committed Feb 21, 2024
1 parent 5717e70 commit 64ac220
Show file tree
Hide file tree
Showing 9 changed files with 1,005 additions and 0 deletions.
53 changes: 53 additions & 0 deletions playwright/ci-test/tests/00-authentication.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { test, expect } from '@playwright/test';

let url = '/';
const username = 'admin';
const password = 'admin';
const authFile = 'auth.json';

test('authentication-setup', async ({ page }) => {
await page.goto(url);

const initialURL = page.url();

await expect(page.locator('h2')).toContainText('QGIS plugins web portal');

await expect(page.getByRole('link', { name: 'Login' })).toBeVisible();

await page.getByRole('link', { name: 'Login' }).click();

await page.waitForURL('**/accounts/login/');

await expect(page.locator('#maincolumn')).toContainText('Login using your OSGEO id.');

await expect(page.locator('#maincolumn')).toContainText('Please note that you do not need a login to download a plugin.');

await expect(page.locator('#maincolumn')).toContainText('You can create a new OSGEO id on OSGEO web portal.');

await expect(page.getByRole('link', { name: 'OSGEO web portal.' })).toBeVisible();

await page.getByLabel('User name:').click();

await page.getByLabel('User name:').fill(username);

await page.getByLabel('Password:').click();

await page.getByLabel('Password:').fill(password);

await expect(page.getByRole('button', { name: 'login' })).toBeVisible();

await page.getByRole('button', { name: 'login' }).click();

const finalURL = page.url();

await expect(initialURL).toBe(finalURL);

await expect(page.getByRole('link', { name: 'Logout' })).toBeVisible();

await expect(page.locator('h2')).toContainText('QGIS plugins web portal');

await expect(page.getByRole('link', { name: '' })).toBeVisible();

await page.context().storageState({path: authFile});

});
80 changes: 80 additions & 0 deletions playwright/ci-test/tests/01-landing-page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { test, expect } from '@playwright/test';

let url = '/';

test.use({
storageState: 'auth.json'
});

test('landing page', async ({ page }) => {
await page.goto(url);

await expect(page.locator('h2')).toContainText('QGIS plugins web portal');

await expect(page.locator('#maincolumn')).toContainText('There is a collection of plugins ready to be used, available to download. These plugins can also be installed directly from the QGIS Plugin Manager within the QGIS application.');

await expect(page.getByRole('link', { name: 'available to download' })).toBeVisible();

await expect(page.locator('#maincolumn')).toContainText('Notes for plugin users');

await expect(page.getByRole('link', { name: 'Developer mailing-list' })).toBeVisible();

await expect(page.locator('#maincolumn')).toContainText('Resources for plugin authors');

await expect(page.getByRole('link', { name: 'pyQGIS cookbook' })).toBeVisible();

await expect(page.getByRole('link', { name: 'QGIS Python API' })).toBeVisible();

await expect(page.getByRole('link', { name: 'QGIS C++ API' })).toBeVisible();

await expect(page.getByRole('link', { name: 'publish your plugins' })).toBeVisible();

await expect(page.getByRole('link', { name: 'QGIS Home' })).toBeVisible();

await expect(page.getByRole('link', { name: 'About plugins' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Plugins', exact: true })).toBeVisible();

await expect(page.getByRole('link', { name: 'Planet' })).toBeVisible();

await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Logout' })).toBeVisible();

await expect(page.getByRole('heading', { name: 'Popular plugins' })).toBeVisible();

const pluginTags = page.getByRole('button', { name: ' Plugin Tags ' });

await expect(pluginTags).toBeVisible();

await pluginTags.click();

await expect(page.locator('#tagcloudModal').getByText('Plugin Tags')).toBeVisible();

await page.getByText('×').click();

await expect(page.locator('section').filter({ hasText: 'Sustaining Members' })).toBeVisible();

await expect(page.locator('header')).toContainText('Sustaining Members');

await expect(page.locator('#twitter').getByRole('link')).toBeVisible();

await expect(page.locator('#facebook').getByRole('link')).toBeVisible();

await expect(page.locator('#github').getByRole('link')).toBeVisible();

await expect(page.getByRole('link', { name: 'Creative Commons Attribution-' })).toBeVisible();

await expect(page.getByRole('link', { name: 'The Noun Project collection' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Alessandro Pasotti' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Kartoza iconKartoza' })).toBeVisible();

await expect(page.getByRole('contentinfo')).toBeVisible();

await expect(page.getByPlaceholder('Search')).toBeEmpty();

await expect(page.getByText('QGIS QGIS Home About plugins')).toBeVisible();

});
105 changes: 105 additions & 0 deletions playwright/ci-test/tests/02-plugins.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { test, expect } from '@playwright/test';

let url = '/';

test.use({
storageState: 'auth.json'
});

test('plugins', async ({ page }) => {
await page.goto(url);

await expect(page.locator('h2')).toContainText('QGIS plugins web portal');

await expect(page.getByRole('link', { name: 'Plugins', exact: true })).toBeVisible();

await page.getByRole('link', { name: 'Plugins', exact: true }).click();

await expect(page.locator('#maincolumn')).toContainText('QGIS Python Plugins Repository');

await expect(page.locator('#maincolumn')).toContainText('All plugins');

await expect(page.locator('#list_commands')).toContainText('1 records found');

await expect(page.getByRole('cell', { name: 'Name' })).toBeVisible();

await expect(page.getByRole('cell', { name: 'Approved' })).toBeVisible();

await expect(page.getByRole('img', { name: 'Approved' })).toBeVisible();

await expect(page.getByTitle('Featured')).toBeVisible();

await expect(page.getByRole('link', { name: 'Downloads', exact: true })).toBeVisible();

await expect(page.getByRole('link', { name: 'Author' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Latest Plugin Version' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Created on' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Stars (votes)' })).toBeVisible();

await expect(page.getByRole('cell', { name: 'Stable' })).toBeVisible();

await expect(page.getByRole('cell', { name: 'Exp.' })).toBeVisible();

await expect(page.getByRole('cell', { name: 'Manage' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Plugin icon' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Coffee Plugin' })).toBeVisible();

await expect(page.getByRole('link', { name: '1.3' })).toBeVisible();

await expect(page.getByRole('link', { name: '1.4' })).toBeVisible();

await expect(page.getByRole('link', { name: '' })).toBeVisible();

await expect(page.getByRole('link', { name: ' Upload a plugin' })).toBeVisible();

await expect(page.getByRole('link', { name: 'My plugins' })).toBeVisible();

await expect(page.locator('#collapse-related-plugins')).toContainText('Plugins');

await expect(page.getByRole('link', { name: 'Unapproved' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Feedback received' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Feedback pending' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Deprecated' })).toBeVisible();

await expect(page.getByText('Featured')).toBeVisible();

await expect(page.getByRole('link', { name: 'All' })).toBeVisible();

await expect(page.getByRole('link', { name: 'New Plugins' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Updated Plugins' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Experimental' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Popular' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Most voted' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Top downloads' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Most rated' })).toBeVisible();

await expect(page.getByRole('link', { name: 'QGIS Server plugins' })).toBeVisible();

await expect(page.locator('#maincolumn')).toContainText('× Deprecated plugins are printed in red.');

await expect(page.locator('section').filter({ hasText: 'Sustaining Members' })).toBeVisible();

await expect(page.locator('header')).toContainText('Sustaining Members');

await expect(page.getByRole('contentinfo')).toBeVisible();

await expect(page.locator('#twitter').getByRole('link')).toBeVisible();

await expect(page.locator('#facebook').getByRole('link')).toBeVisible();

await expect(page.locator('#github').getByRole('link')).toBeVisible();
});
Loading

0 comments on commit 64ac220

Please sign in to comment.