Skip to content
Snippets Groups Projects
Commit a1b40e2a authored by ilyaukin's avatar ilyaukin Committed by André Angelantoni
Browse files

Resolve #3477410 "Patch tests"

parent 58e7bd61
No related branches found
No related tags found
3 merge requests!1086b2c5k4p:Handle tests we are not implementing,!986b2c5k4p:Handle tests we are not implementing,!6Resolve #3477410 "Patch tests"
...@@ -71,15 +71,15 @@ test.describe('Media tests.', () => { ...@@ -71,15 +71,15 @@ test.describe('Media tests.', () => {
// and NaturalHeight properties. // and NaturalHeight properties.
let isImageDownloaded = await imageLocator.evaluate((img) => img.naturalWidth > 0 && img.naturalHeight > 0); let isImageDownloaded = await imageLocator.evaluate((img) => img.naturalWidth > 0 && img.naturalHeight > 0);
// Extract the media id that was added by // Extract the edit and delete hrefs.
// automated_testing_kit_preprocess_image(). const rowLocator = page.locator('tr', { has: imageLocator });
const mid = await imageLocator.getAttribute('data-media-id'); const mediaEditUrl = await rowLocator.locator('a[href*="edit"]').first().getAttribute('href');
const mediaDeleteUrl = await rowLocator.locator('a[href*="delete"]').getAttribute('href');
// //
// Update the media. // Update the media.
// //
const mediaEditUrl = atkConfig.mediaEditUrl.replace('{mid}', mid); await page.goto(mediaEditUrl);
await page.goto(baseUrl + mediaEditUrl);
await page.getByRole('button', { name: 'Remove' }).click(); await page.getByRole('button', { name: 'Remove' }).click();
await page.setInputFiles('input[name="files[field_media_image_0]"]', image2Filepath); await page.setInputFiles('input[name="files[field_media_image_0]"]', image2Filepath);
await altField.fill(`${testId}: ${uniqueToken2}`); await altField.fill(`${testId}: ${uniqueToken2}`);
...@@ -101,8 +101,7 @@ test.describe('Media tests.', () => { ...@@ -101,8 +101,7 @@ test.describe('Media tests.', () => {
// //
// Delete the media entity. // Delete the media entity.
// //
const mediaDeleteUrl = atkConfig.mediaDeleteUrl.replace('{mid}', mid); await page.goto(mediaDeleteUrl);
await page.goto(baseUrl + mediaDeleteUrl);
await page.getByRole('button', { name: 'Delete' }).click(); await page.getByRole('button', { name: 'Delete' }).click();
}); });
}); });
...@@ -54,27 +54,15 @@ test.describe('Node tests.', () => { ...@@ -54,27 +54,15 @@ test.describe('Node tests.', () => {
// //
// Confirm content appears. // Confirm content appears.
// //
let divContainer = await page.textContent('.text-content'); let divContainer = await page.textContent('.node__content');
await expect(divContainer).toContain(bodyText); await expect(divContainer).toContain(bodyText);
// Extract the nid placed in the body class by this hook:
// automated_testing_kit.module:automated_testing_kit_preprocess_html().
// Wait for the page to load
await page.waitForLoadState('domcontentloaded');
const bodyClass = await page.evaluate(() => document.body.className);
const match = bodyClass.match(/node-nid-(\d+)/);
// Get the nid.
const nid = parseInt(match[1], 10);
// //
// Update the node. // Update the node.
// //
const nodeEditUrl = atkConfig.nodeEditUrl.replace('{nid}', nid);
bodyText = 'Ut eget ex vitae nibh dapibus vulputate ut id lacus.'; bodyText = 'Ut eget ex vitae nibh dapibus vulputate ut id lacus.';
await page.goto(baseUrl + nodeEditUrl); await page.getByRole('link', { name: 'Edit' }).click();
ckEditor = await page.locator('[aria-label="Editor editing area: main"]'); ckEditor = await page.locator('[aria-label="Editor editing area: main"]');
await ckEditor.fill(bodyText); await ckEditor.fill(bodyText);
// Timeouts necessary when running at full speed. // Timeouts necessary when running at full speed.
...@@ -85,14 +73,14 @@ test.describe('Node tests.', () => { ...@@ -85,14 +73,14 @@ test.describe('Node tests.', () => {
// //
// Confirm content has changed. // Confirm content has changed.
// //
divContainer = await page.locator('.text-content'); divContainer = await page.locator('.node__content');
const text = await divContainer.textContent(); const text = await divContainer.textContent();
await expect(text).toContain(bodyText); await expect(text).toContain(bodyText);
// //
// Delete the node. // Delete the node.
// //
await atkCommands.deleteNodeViaUiWithNid(page, context, nid); await atkCommands.deleteCurrentNodeViaUi(page);
}); });
// //
...@@ -131,7 +119,7 @@ test.describe('Node tests.', () => { ...@@ -131,7 +119,7 @@ test.describe('Node tests.', () => {
// //
// Confirm content appears. // Confirm content appears.
// //
let divContainer = await page.textContent('.text-content'); let divContainer = await page.textContent('.node__content');
await expect(divContainer).toContain(bodyText); await expect(divContainer).toContain(bodyText);
// Extract the nid placed in the body class by this hook: // Extract the nid placed in the body class by this hook:
...@@ -141,17 +129,12 @@ test.describe('Node tests.', () => { ...@@ -141,17 +129,12 @@ test.describe('Node tests.', () => {
const bodyClass = await page.evaluate(() => document.body.className); const bodyClass = await page.evaluate(() => document.body.className);
const match = bodyClass.match(/node-nid-(\d+)/); const match = bodyClass.match(/node-nid-(\d+)/);
// Get the nid.
const nid = parseInt(match[1], 10);
// //
// Update the node. // Update the node.
// //
const nodeEditUrl = atkConfig.nodeEditUrl.replace('{nid}', nid);
bodyText = 'Ut eget ex vitae nibh dapibus vulputate ut id lacus.'; bodyText = 'Ut eget ex vitae nibh dapibus vulputate ut id lacus.';
await page.goto(baseUrl + nodeEditUrl); await page.getByRole('link', { name: 'Edit' }).click();
ckEditor = await page.locator('[aria-label="Editor editing area: main"]'); ckEditor = await page.locator('[aria-label="Editor editing area: main"]');
await ckEditor.fill(bodyText); await ckEditor.fill(bodyText);
// Timeouts necessary when running at full speed. // Timeouts necessary when running at full speed.
...@@ -162,13 +145,13 @@ test.describe('Node tests.', () => { ...@@ -162,13 +145,13 @@ test.describe('Node tests.', () => {
// //
// Confirm content has changed. // Confirm content has changed.
// //
divContainer = await page.locator('.text-content'); divContainer = await page.locator('.node__content');
const text = await divContainer.textContent(); const text = await divContainer.textContent();
await expect(text).toContain(bodyText); await expect(text).toContain(bodyText);
// //
// Delete the node. // Delete the node.
// //
await atkCommands.deleteNodeViaUiWithNid(page, context, nid); await atkCommands.deleteCurrentNodeViaUi(page);
}); });
}); });
...@@ -59,8 +59,7 @@ test.describe('Entity tests.', () => { ...@@ -59,8 +59,7 @@ test.describe('Entity tests.', () => {
// Fetch tag id from the list. The new term should be at // Fetch tag id from the list. The new term should be at
// or near the top. // or near the top.
// //
await page.goto(`${baseUrl}admin/structure/taxonomy/manage/tags/overview`); await page.goto(`admin/structure/taxonomy/manage/tags/overview`);
const termLocator = await page.getByText(termName); // eslint-disable-line no-unused-vars
// Get the tid from the edit button. // Get the tid from the edit button.
const link = await page.locator("//a[contains(text(),'Edit') and starts-with(@href, '/taxonomy/term')]").first(); const link = await page.locator("//a[contains(text(),'Edit') and starts-with(@href, '/taxonomy/term')]").first();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
module.exports = { module.exports = {
createUserWithUserObject, createUserWithUserObject,
deleteCurrentNodeViaUi,
deleteNodeViaUiWithNid, deleteNodeViaUiWithNid,
deleteUserWithEmail, deleteUserWithEmail,
deleteUserWithUid, deleteUserWithUid,
...@@ -91,6 +92,16 @@ function createUserWithUserObject (user, roles = [], args = [], options = []) { ...@@ -91,6 +92,16 @@ function createUserWithUserObject (user, roles = [], args = [], options = []) {
}) })
} }
/**
* Delete currently opened node.
* @param page {object} Page object.
* @returns {Promise<void>}
*/
async function deleteCurrentNodeViaUi(page) {
await page.getByRole('link', { name: 'Delete' }).click();
await page.getByRole('button', { name: 'Delete' }).click();
}
/** /**
* Delete node via UI given a nid. * Delete node via UI given a nid.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment