diff --git a/playwright/ci-test/tests/00-authentication.setup.ts b/playwright/ci-test/tests/00-authentication.setup.ts new file mode 100644 index 00000000..a2468c33 --- /dev/null +++ b/playwright/ci-test/tests/00-authentication.setup.ts @@ -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}); + +}); \ No newline at end of file diff --git a/playwright/ci-test/tests/01-landing-page.spec.ts b/playwright/ci-test/tests/01-landing-page.spec.ts new file mode 100644 index 00000000..03f54453 --- /dev/null +++ b/playwright/ci-test/tests/01-landing-page.spec.ts @@ -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(); + +}); \ No newline at end of file diff --git a/playwright/ci-test/tests/02-plugins.spec.ts b/playwright/ci-test/tests/02-plugins.spec.ts new file mode 100644 index 00000000..46d2beab --- /dev/null +++ b/playwright/ci-test/tests/02-plugins.spec.ts @@ -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(); +}); \ No newline at end of file diff --git a/playwright/ci-test/tests/03-plugins-upload.spec.ts b/playwright/ci-test/tests/03-plugins-upload.spec.ts new file mode 100644 index 00000000..1d4e22e8 --- /dev/null +++ b/playwright/ci-test/tests/03-plugins-upload.spec.ts @@ -0,0 +1,158 @@ +import { test, expect } from '@playwright/test'; + +let url = '/'; + +test.use({ + storageState: 'auth.json' +}); + +test.describe('plugins upload', () => { + test.beforeEach(async ({ page }) => { + // Go to the starting url before each test. + await page.goto(url); + }); + + test('plugins upload', 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('link', { name: 'Coffee Plugin' })).toBeVisible(); + + await expect(page.getByRole('link', { name: ' Upload a plugin' })).toBeVisible(); + + await page.getByRole('link', { name: ' Upload a plugin' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('QGIS Python Plugins Repository'); + + await expect(page.locator('#maincolumn')).toContainText('Upload a plugin'); + + const fileChooserPromise = page.waitForEvent('filechooser'); + + await page.getByLabel('Plugin package:').click(); + + const fileChooser = await fileChooserPromise; + + await fileChooser.setFiles('tests/fixtures/valid_plugin.zip_'); + + //await page.getByLabel('Plugin package:').setInputFiles('valid_plugin.zip_'); + + await page.getByRole('button', { name: 'Upload' }).click(); + + await page.waitForLoadState('load'); + + await expect(page.getByText('× The Plugin has been')).toBeVisible(); + + await expect(page.locator('#maincolumn')).toContainText('The Plugin has been successfully created.'); + + await expect(page.locator('#maincolumn')).toContainText('Test Plugin'); + + await expect(page.getByRole('link', { name: ' Download latest' })).toBeVisible(); + + await expect(page.getByRole('blockquote')).toContainText('I am here for testing purpose'); + + await expect(page.getByRole('link', { name: 'About', exact: true })).toBeVisible(); + + await expect(page.locator('#plugin-about')).toContainText('I was built for testing purpose'); + + await page.getByRole('link', { name: 'Details' }).click(); + + await expect(page.getByText('Author', { exact: true })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Kartoza', exact: true })).toBeVisible(); + + await page.getByRole('link', { name: 'Versions' }).click(); + + await expect(page.getByRole('link', { name: '0.0.1' })).toBeVisible(); + + await page.getByRole('link', { name: 'Manage' }).click(); + + await expect(page.getByRole('link', { name: 'Edit' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Add version' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Tokens' })).toBeVisible(); + + await expect(page.getByRole('button', { name: 'Set featured' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Delete' })).toBeVisible(); + + await page.getByRole('button', { name: '×' }).click(); + + await page.getByRole('link', { name: 'My plugins' }).click(); + + await expect(page.locator('#list_commands')).toContainText('3 records found'); + + await expect(page.getByRole('link', { name: 'Coffee Plugin' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Pizza Plugin' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Test Plugin', exact: true })).toBeVisible(); + + await page.getByRole('link', { name: 'All' }).click(); + + await page.getByRole('link', { name: 'Stable' }).click(); + + await expect(page.locator('#list_commands')).toContainText('2 records found'); + + await page.getByRole('link', { name: 'New Plugins' }).click(); + + await expect(page.locator('#list_commands')).toContainText('1 records found'); + + await expect(page.getByRole('link', { name: 'Test Plugin', exact: true })).toBeVisible(); + + await page.getByRole('link', { name: 'My plugins' }).click(); + + }); + + test('test plugin delete', async ({ page }) => { + await page.goto(url); + + await page.getByRole('link', { name: 'Plugins', exact: true }).click(); + + await page.waitForURL('**/plugins/'); + + await expect(page.locator('#list_commands')).toContainText('2 records found'); + + await page.getByRole('link', { name: 'Test Plugin', exact: true }).click(); + + await expect(page.locator('#maincolumn')).toContainText('QGIS Python Plugins Repository'); + + await expect(page.getByRole('heading', { name: 'Test Plugin' })).toBeVisible(); + + await expect(page.getByRole('link', { name: ' Download latest' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Manage' })).toBeVisible(); + + await page.getByRole('link', { name: 'Manage' }).click(); + + await expect(page.getByRole('link', { name: 'Delete' })).toBeVisible(); + + await page.getByRole('link', { name: 'Delete' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Delete plugin:'); + + await expect(page.locator('#maincolumn')).toContainText('You asked to delete the plugin and all its versions. The plugin will be permanently deleted. This action cannot be undone. Please confirm.'); + + await page.getByRole('button', { name: 'Ok' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('× The Plugin has been successfully deleted.'); + + await expect(page.locator('#maincolumn')).toContainText('All plugins'); + + await expect(page.locator('#list_commands')).toContainText('1 records found'); + + await expect(page.getByRole('link', { name: 'Coffee Plugin' })).toBeVisible(); + }); + +}); \ No newline at end of file diff --git a/playwright/ci-test/tests/04-hub-styles.spec.ts b/playwright/ci-test/tests/04-hub-styles.spec.ts new file mode 100644 index 00000000..8375026b --- /dev/null +++ b/playwright/ci-test/tests/04-hub-styles.spec.ts @@ -0,0 +1,67 @@ +import { test, expect } from '@playwright/test'; + +let url = '/'; + +test.use({ + storageState: 'auth.json' +}); + +test('styles', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Styles' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('QGIS Style'); + + await expect(page.locator('#maincolumn')).toContainText('All Styles'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.locator('.frame-image-demo')).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Cube Creator | 17 November' })).toBeVisible(); + + await expect(page.getByRole('link', { name: ' Upload Style' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Approved' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Waiting Review' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Requiring Update' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Cube Creator' })).toBeVisible(); + + //await page.waitForURL('**/styles/?order_by=-upload_date&&is_gallery=true'); + + await page.getByRole('link', { name: 'Approved' }).click(); + + await expect(page.getByRole('link', { name: 'Cube' })).toBeVisible(); + + await page.getByRole('link', { name: 'Waiting Review' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + //await page.getByRole('link', { name: 'New Cube Style' }).click(); + + await expect(page.getByRole('link', { name: 'New Cube Style' })).toBeVisible(); + + await page.getByRole('link', { name: 'Requiring Update' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Requiring Update'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.getByRole('link', { name: 'Another Cube' })).toBeVisible(); + + await expect(page.locator('#collapse-related-plugins')).toContainText('Style Type'); + + //await page.getByRole('link', { name: 'Symbol 3D' }).click(); + + await expect(page.getByRole('link', { name: 'Cube' })).toBeVisible(); +}); diff --git a/playwright/ci-test/tests/05-hub-style-upload.spec.ts b/playwright/ci-test/tests/05-hub-style-upload.spec.ts new file mode 100644 index 00000000..9522501b --- /dev/null +++ b/playwright/ci-test/tests/05-hub-style-upload.spec.ts @@ -0,0 +1,131 @@ +import { test, expect } from '@playwright/test'; + +let url = '/'; + +test.use({ + storageState: 'auth.json' +}); + +test.describe('style uploads', () => { + test.beforeEach(async ({ page }) => { + // Go to the starting url before each test. + await page.goto(url); + }); + + test('test style upload', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Styles' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('QGIS Style'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await page.getByRole('link', { name: ' Upload Style' }).click(); + + const fileChooserPromise = page.waitForEvent('filechooser'); + + await page.getByLabel('Style file:').click(); + + const fileChooser = await fileChooserPromise; + + //await page.getByLabel('Style file:').setInputFiles('point.xml'); + + await fileChooser.setFiles('tests/fixtures/point.xml'); + + const fileChooserPromise2 = page.waitForEvent('filechooser'); + + await page.getByLabel('Thumbnail:').click(); + + const fileChooser2 = await fileChooserPromise2; + + //await page.getByLabel('Thumbnail:').setInputFiles('qgis-icon.png'); + await fileChooser2.setFiles('tests/fixtures/qgis_thumbnail.png'); + + await page.getByLabel('Description:').click(); + + await page.getByLabel('Description:').fill('This is a test file.'); + + await page.getByLabel('I confirm that I own these').check(); + + await page.getByRole('button', { name: 'Upload' }).click(); + + await page.waitForLoadState('load'); + + await expect(page.getByText('× The Style has been')).toBeVisible(); + + await expect(page.locator('#maincolumn')).toContainText('× The Style has been successfully created.'); + + await expect(page.getByRole('heading', { name: 'Custompoint in review' })).toBeVisible(); + + await expect(page.getByRole('img', { name: 'image' })).toBeVisible(); + + await expect(page.getByText('Custompoint', { exact: true })).toBeVisible(); + + await page.getByPlaceholder('Please provide clear feedback').click(); + + await page.getByPlaceholder('Please provide clear feedback').fill('All good.'); + + await page.getByRole('button', { name: 'Submit Review' }).click(); + + await expect(page.getByText('× The Style has been approved.')).toBeVisible(); + + await page.getByRole('link', { name: 'Approved' }).click(); + + await expect(page.getByRole('link', { name: 'Custompoint' })).toBeVisible(); + + await expect(page.getByRole('link', { name: 'Marker' })).toBeVisible(); + + await page.getByRole('link', { name: 'Marker' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Marker Styles'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await page.getByRole('link', { name: 'Approved' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Styles'); + + await expect(page.locator('#maincolumn')).toContainText('2 records found.'); + + }); + + test('test style delete', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Styles' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Styles'); + + await expect(page.locator('#maincolumn')).toContainText('2 records found.'); + + await page.getByRole('link', { name: 'Custompoint Admin' }).click(); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Delete Style: Custompoint'); + + await expect(page.locator('#maincolumn')).toContainText('Are you sure you want to permanently remove this Style?'); + + await expect(page.getByRole('button', { name: 'Delete' })).toBeVisible(); + + await page.getByRole('button', { name: 'Delete' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Styles'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + }); + +}); diff --git a/playwright/ci-test/tests/06-hub-projects.spec.ts b/playwright/ci-test/tests/06-hub-projects.spec.ts new file mode 100644 index 00000000..126c3b9a --- /dev/null +++ b/playwright/ci-test/tests/06-hub-projects.spec.ts @@ -0,0 +1,143 @@ +import { test, expect } from '@playwright/test'; + +let url = '/'; + +test.use({ + storageState: 'auth.json' +}); + +test.describe('projects', () => { + test.beforeEach(async ({ page }) => { + // Go to the starting url before each test. + await page.goto(url); + }); + + test('test projects upload', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Projects' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('QGIS GeoPackage'); + + await expect(page.locator('#maincolumn')).toContainText('All GeoPackages'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + await expect(page.getByRole('link', { name: ' Upload GeoPackage' })).toBeVisible(); + + await page.getByRole('link', { name: ' Upload GeoPackage' }).click(); + + const fileChooserPromise = page.waitForEvent('filechooser'); + + await page.getByLabel('GeoPackage file:').click(); + + //page.once('dialog', dialog => { + //console.log(`Dialog message: ${dialog.message()}`); + //dialog.dismiss().catch(() => { }); + //}); + + const fileChooser = await fileChooserPromise; + + await fileChooser.setFiles('tests/fixtures/spiky_polygons.gpkg'); + + //await page.getByLabel('GeoPackage file:').setInputFiles('spiky_polygons.gpkg'); + + const fileChooserPromise2 = page.waitForEvent('filechooser'); + + await page.getByLabel('Thumbnail:').click(); + + const fileChooser2 = await fileChooserPromise2; + + //await page.getByLabel('Thumbnail:').setInputFiles('qgis-icon.png'); + await fileChooser2.setFiles('tests/fixtures/thumbnail.png'); + + await page.getByLabel('Name:').click(); + + await page.getByLabel('Name:').fill('Test gpkg'); + + await page.getByLabel('Description:').click(); + + await page.getByLabel('Description:').fill('This is a test file.'); + + await page.getByLabel('I confirm that I own these').check(); + + await page.getByRole('button', { name: 'Upload' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('× GeoPackage was uploaded successfully.'); + + await expect(page.getByText('GeoPackage was uploaded')).toBeVisible(); + + await expect(page.locator('#maincolumn')).toContainText('Test gpkg in review'); + + await expect(page.getByRole('img', { name: 'image' })).toBeVisible(); + + await expect(page.getByText('Test gpkg', { exact: true })).toBeVisible(); + + await page.getByPlaceholder('Please provide clear feedback').click(); + + await page.getByPlaceholder('Please provide clear feedback').fill('All good.'); + + await page.getByRole('button', { name: 'Submit Review' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('× The GeoPackage has been approved.'); + + await expect(page.getByRole('heading', { name: 'Test gpkg' })).toBeVisible(); + + await page.getByRole('link', { name: 'Approved' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All GeoPackages'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.getByRole('link', { name: 'Test gpkg' })).toBeVisible(); + + await expect(page.getByRole('img', { name: 'Style icon' })).toBeVisible(); + + }); + + test('test projects delete', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Projects' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All GeoPackages'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.getByRole('link', { name: '' })).toBeVisible(); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.getByRole('link', { name: 'Test gpkg' })).toBeVisible(); + + await page.getByRole('link', { name: 'Test gpkg' }).click(); + + await expect(page.getByRole('heading', { name: 'Test gpkg' })).toBeVisible(); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Delete GeoPackage: Test gpkg'); + + await expect(page.locator('#maincolumn')).toContainText('Are you sure you want to permanently remove this GeoPackage?'); + + await page.getByRole('button', { name: 'Delete' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All GeoPackages'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + }); + +}); \ No newline at end of file diff --git a/playwright/ci-test/tests/07-hub-models.spec.ts b/playwright/ci-test/tests/07-hub-models.spec.ts new file mode 100644 index 00000000..eda97aa3 --- /dev/null +++ b/playwright/ci-test/tests/07-hub-models.spec.ts @@ -0,0 +1,127 @@ +import { test, expect } from '@playwright/test'; + +let url = '/'; + +test.use({ + storageState: 'auth.json' +}); + +test.describe('models', () => { + test.beforeEach(async ({ page }) => { + // Go to the starting url before each test. + await page.goto(url); + }); + + test('test models uploads', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Models', exact: true }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Models'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + await expect(page.getByRole('link', { name: ' Upload Model' })).toBeVisible(); + + await page.getByRole('link', { name: ' Upload Model' }).click(); + + const fileChooserPromise = page.waitForEvent('filechooser'); + + await page.getByLabel('Model file:').click(); + + const fileChooser = await fileChooserPromise; + + //await page.getByLabel('Model file:').setInputFiles('example.model3'); + await fileChooser.setFiles('tests/fixtures/example.model3'); + + const fileChooserPromise2 = page.waitForEvent('filechooser'); + + await page.getByLabel('Thumbnail:').click(); + + const fileChooser2 = await fileChooserPromise2; + + //await page.getByLabel('Thumbnail:').setInputFiles('qgis-icon.png'); + await fileChooser2.setFiles('tests/fixtures/thumbnail.png'); + + await page.getByLabel('Name:').click(); + + await page.getByLabel('Name:').fill('Test model'); + + await page.getByLabel('Description:').click(); + + await page.getByLabel('Description:').fill('This is a test file.'); + + await page.getByLabel('I confirm that I own these').check(); + + await page.getByRole('button', { name: 'Upload' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('× Model was uploaded successfully.'); + + await expect(page.getByText('Model was uploaded')).toBeVisible(); + + await expect(page.locator('#maincolumn')).toContainText('Test model in review'); + + await expect(page.getByRole('heading', { name: 'Test model in review' })).toBeVisible(); + + await page.getByPlaceholder('Please provide clear feedback').click(); + + await page.getByPlaceholder('Please provide clear feedback').fill('All good.'); + + await expect(page.getByRole('img', { name: 'image' })).toBeVisible(); + + await page.getByRole('button', { name: 'Submit Review' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('× The Model has been approved.'); + + await page.getByRole('link', { name: 'Approved' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Models'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.getByRole('link', { name: 'Test model' })).toBeVisible(); + + await expect(page.getByRole('img', { name: 'Style icon' })).toBeVisible(); + + }); + + test('test model delete', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'Models', exact: true }).click(); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Models'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.getByRole('link', { name: 'Test model' })).toBeVisible(); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Delete Model: Test model'); + + await expect(page.locator('#maincolumn')).toContainText('Are you sure you want to permanently remove this Model?'); + + await page.getByRole('button', { name: 'Delete' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Models'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + }); + +}); \ No newline at end of file diff --git a/playwright/ci-test/tests/08-hub-qgis-layer-definition-file.spec.ts b/playwright/ci-test/tests/08-hub-qgis-layer-definition-file.spec.ts new file mode 100644 index 00000000..1a33a248 --- /dev/null +++ b/playwright/ci-test/tests/08-hub-qgis-layer-definition-file.spec.ts @@ -0,0 +1,141 @@ +import { test, expect } from '@playwright/test'; + +let url = '/'; + +test.use({ + storageState: 'auth.json' +}); + +test.describe('qgis layer definition file', () => { + test.beforeEach(async ({ page }) => { + // Go to the starting url before each test. + await page.goto(url); + }); + + test('test qgis layer definition file upload', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'QGIS Layer Definition File' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('QGIS Layer Definition File'); + + await expect(page.locator('#maincolumn')).toContainText('All Layer Definition Files'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + await expect(page.getByRole('link', { name: ' Upload Layer Definition File' })).toBeVisible(); + + await page.getByRole('link', { name: ' Upload Layer Definition File' }).click(); + + await expect(page.getByRole('heading', { name: 'Upload Layer Definition File' })).toBeVisible(); + + const fileChooserPromise = page.waitForEvent('filechooser'); + + await page.getByLabel('Layer Definition file:').click(); + + const fileChooser = await fileChooserPromise; + + await fileChooser.setFiles('tests/fixtures/my-vapour-pressure.qlr'); + + const fileChooserPromise2 = page.waitForEvent('filechooser'); + + await page.getByLabel('Thumbnail:').click(); + + const fileChooser2 = await fileChooserPromise2; + + //await page.getByLabel('Thumbnail:').setInputFiles('qgis-icon.png'); + await fileChooser2.setFiles('tests/fixtures/qgis_thumbnail.png'); + + await page.getByLabel('Name:').click(); + + await page.getByLabel('Name:').fill('Test layer definition file'); + + await page.getByLabel('Description:').click(); + + await page.getByLabel('Description:').fill('This is a test.'); + + await page.getByLabel('I confirm that I own these').check(); + + await page.getByRole('button', { name: 'Upload' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Layer Definition File was uploaded successfully.'); + + await expect(page.locator('#maincolumn')).toContainText('Test layer definition file in review'); + + await expect(page.getByRole('img', { name: 'image' })).toBeVisible(); + + await expect(page.getByPlaceholder('Please provide clear feedback')).toBeVisible(); + + await page.getByPlaceholder('Please provide clear feedback').click(); + + await page.getByPlaceholder('Please provide clear feedback').fill('All good.'); + + await page.getByRole('button', { name: 'Submit Review' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('× The Layer Definition File has been approved.'); + + await page.getByRole('link', { name: 'Approved' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Layer Definition Files'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await expect(page.getByRole('link', { name: 'Test layer definition file' })).toBeVisible(); + + await expect(page.getByRole('img', { name: 'Style icon' })).toBeVisible(); + + await page.getByRole('link', { name: 'Waiting Review' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Waiting Review'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + await page.getByRole('link', { name: 'Requiring Update' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Requiring Update'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + await page.getByRole('link', { name: 'Approved' }).click(); + }); + + test('test qgis layer definition delete', async ({ page }) => { + await page.goto(url); + + await expect(page.locator('h2')).toContainText('QGIS plugins web portal'); + + await expect(page.getByRole('button', { name: 'Hub' })).toBeVisible(); + + await page.getByRole('button', { name: 'Hub' }).click(); + + await page.getByRole('menuitem', { name: 'QGIS Layer Definition File' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Layer Definition Files'); + + await expect(page.locator('#maincolumn')).toContainText('1 record found.'); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.getByRole('link', { name: 'Test layer definition file' })).toBeVisible(); + + await page.getByRole('link', { name: '' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('Delete Layer Definition File: Test layer definition file'); + + await expect(page.locator('#maincolumn')).toContainText('Are you sure you want to permanently remove this Layer Definition File?'); + + await page.getByRole('button', { name: 'Delete' }).click(); + + await expect(page.locator('#maincolumn')).toContainText('All Layer Definition Files'); + + await expect(page.locator('#maincolumn')).toContainText('No data.'); + + }); + +});