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.', () => {
// and NaturalHeight properties.
let isImageDownloaded = await imageLocator.evaluate((img) => img.naturalWidth > 0 && img.naturalHeight > 0);
// Extract the media id that was added by
// automated_testing_kit_preprocess_image().
const mid = await imageLocator.getAttribute('data-media-id');
// Extract the edit and delete hrefs.
const rowLocator = page.locator('tr', { has: imageLocator });
const mediaEditUrl = await rowLocator.locator('a[href*="edit"]').first().getAttribute('href');
const mediaDeleteUrl = await rowLocator.locator('a[href*="delete"]').getAttribute('href');
//
// Update the media.
//
const mediaEditUrl = atkConfig.mediaEditUrl.replace('{mid}', mid);
await page.goto(baseUrl + mediaEditUrl);
await page.goto(mediaEditUrl);
await page.getByRole('button', { name: 'Remove' }).click();
await page.setInputFiles('input[name="files[field_media_image_0]"]', image2Filepath);
await altField.fill(`${testId}: ${uniqueToken2}`);
......@@ -101,8 +101,7 @@ test.describe('Media tests.', () => {
//
// Delete the media entity.
//
const mediaDeleteUrl = atkConfig.mediaDeleteUrl.replace('{mid}', mid);
await page.goto(baseUrl + mediaDeleteUrl);
await page.goto(mediaDeleteUrl);
await page.getByRole('button', { name: 'Delete' }).click();
});
});
......@@ -54,27 +54,15 @@ test.describe('Node tests.', () => {
//
// Confirm content appears.
//
let divContainer = await page.textContent('.text-content');
let divContainer = await page.textContent('.node__content');
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.
//
const nodeEditUrl = atkConfig.nodeEditUrl.replace('{nid}', nid);
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"]');
await ckEditor.fill(bodyText);
// Timeouts necessary when running at full speed.
......@@ -85,14 +73,14 @@ test.describe('Node tests.', () => {
//
// Confirm content has changed.
//
divContainer = await page.locator('.text-content');
divContainer = await page.locator('.node__content');
const text = await divContainer.textContent();
await expect(text).toContain(bodyText);
//
// Delete the node.
//
await atkCommands.deleteNodeViaUiWithNid(page, context, nid);
await atkCommands.deleteCurrentNodeViaUi(page);
});
//
......@@ -131,7 +119,7 @@ test.describe('Node tests.', () => {
//
// Confirm content appears.
//
let divContainer = await page.textContent('.text-content');
let divContainer = await page.textContent('.node__content');
await expect(divContainer).toContain(bodyText);
// Extract the nid placed in the body class by this hook:
......@@ -141,17 +129,12 @@ test.describe('Node tests.', () => {
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.
//
const nodeEditUrl = atkConfig.nodeEditUrl.replace('{nid}', nid);
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"]');
await ckEditor.fill(bodyText);
// Timeouts necessary when running at full speed.
......@@ -162,13 +145,13 @@ test.describe('Node tests.', () => {
//
// Confirm content has changed.
//
divContainer = await page.locator('.text-content');
divContainer = await page.locator('.node__content');
const text = await divContainer.textContent();
await expect(text).toContain(bodyText);
//
// Delete the node.
//
await atkCommands.deleteNodeViaUiWithNid(page, context, nid);
await atkCommands.deleteCurrentNodeViaUi(page);
});
});
......@@ -59,8 +59,7 @@ test.describe('Entity tests.', () => {
// Fetch tag id from the list. The new term should be at
// or near the top.
//
await page.goto(`${baseUrl}admin/structure/taxonomy/manage/tags/overview`);
const termLocator = await page.getByText(termName); // eslint-disable-line no-unused-vars
await page.goto(`admin/structure/taxonomy/manage/tags/overview`);
// Get the tid from the edit button.
const link = await page.locator("//a[contains(text(),'Edit') and starts-with(@href, '/taxonomy/term')]").first();
......
......@@ -11,6 +11,7 @@
module.exports = {
createUserWithUserObject,
deleteCurrentNodeViaUi,
deleteNodeViaUiWithNid,
deleteUserWithEmail,
deleteUserWithUid,
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment