From af6e461b72e3ce474c04e30eec48d147b8e405f0 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 3 Oct 2024 17:42:08 +0200 Subject: [PATCH] Tests - Move a minor tests from manual to playwright --- tests/end2end/playwright/media.spec.js | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/end2end/playwright/media.spec.js diff --git a/tests/end2end/playwright/media.spec.js b/tests/end2end/playwright/media.spec.js new file mode 100644 index 0000000000..5c13293cdc --- /dev/null +++ b/tests/end2end/playwright/media.spec.js @@ -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).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).toBeFalsy(); +// +// var response = await page.request.get(baseUrl + '../media/specific_media_folder/random-4.jpg'); +// await expect(response).toBeFalsy(); + + }) +})