Skip to content

Commit

Permalink
Tests - Move a minor tests from manual to playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Oct 3, 2024
1 parent 1371144 commit ea1cdf8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
42 changes: 42 additions & 0 deletions tests/end2end/playwright/media.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';

test.describe('Media', () => {
test('Tests media are deleted', async ({ page }) => {

var baseUrl = 'index.php/view/media/getMedia?repository=testsrepository&project=form_edition_all_field_type&path=';
// on the feature from the "form_edition_upload" layer
var response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/text_file_mandatory/lorem-2.txt');
await expect(response).toBeOK();

var response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/image_file_mandatory/random-2.jpg');
await expect(response).toBeOK();

var response = await page.request.get(baseUrl + '../media/specific_media_folder/random-4.jpg');
await expect(response).toBeOK();

// Open the attribute table
const url = '/index.php/view/map?repository=testsrepository&project=form_edition_all_field_type';
await gotoMap(url, page);

await page.locator('#button-attributeLayers').click();

let getFeatureRequestPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetFeature') === true);

await page.locator('#attribute-layer-list button[value="form_edition_upload"]').click();
await getFeatureRequestPromise;

await page.getByRole('row', { name: '2 text_file_mandatory' }).getByRole('button').nth(2);

var response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/text_file_mandatory/lorem-2.txt');
await expect(response).toBeFalsy();

var response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/image_file_mandatory/random-2.jpg');
await expect(response).toBeFalsy();

var response = await page.request.get(baseUrl + '../media/specific_media_folder/random-4.jpg');
await expect(response).toBeFalsy();

})
})
5 changes: 3 additions & 2 deletions tests/qgis-projects/tests/form_edition_all_field_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ Check that there is a folder `media` aside the `tests` folder, containing a sub-
* [ ] `text_file_mandatory` is working
* [ ] `image_file_mandatory` is working with the `media/` directory
* [ ] `image_file_specific_root_folder`, in a **new tab** is working with the `../media/specific_media_folder/`
* [ ] Delete the data line with the **trash** button
* [ ] Refresh the tab showing `image_file_specific_root_folder`, it must return a 404

[//]: # (* [ ] Delete the data line with the **trash** button)
[//]: # (* [ ] Refresh the tab showing `image_file_specific_root_folder`, it must return a 404)

0 comments on commit ea1cdf8

Please sign in to comment.