Skip to content
Snippets Groups Projects

Update PW-1111 in atk_node.spec.js

1 file
+ 13
28
Compare changes
  • Side-by-side
  • Inline
@@ -139,7 +139,7 @@ test.describe('Node tests.', () => {
//
// Create an article with an image, confirm it, update it, confirm update then delete it via the UI.
//
test('(ATK-PW-1111) Create, update, delete an article via the UI. @ATK-PW-1111 @node @smoke @alters-db', async ({ page, context }) => {
test('(ATK-PW-1111) Create, update, delete an article via the UI. @ATK-PW-1111 @node @smoke @alters-db', async ({ page, context }) => {
const testId = 'ATK-PW-1111';
const image1Filepath = 'tests/data/NewspaperArticle.jpg';
const uniqueToken1 = atkUtilities.createRandomString(6);
@@ -148,42 +148,30 @@ test.describe('Node tests.', () => {
// Log in with the administrator account.
// You should change this to an account other than the administrator,
// which has all rights.
await atkCommands.logInViaForm(page, context, qaUserAccounts.admin);
await atkCommands.logInViaForm(page, context, qaUsers.admin);
//
// Add an article.
//
await page.goto(baseUrl + atkConfig.articleAddUrl);
const editorPage = new EditorPage(page);
// Fill in as many fields as you need here.
const titleTextField = await page.locator('input[name="title[0][value]"]');
await titleTextField.fill(`${testId}: A Title`);
let ckEditor = await page.locator('[aria-label="Editor editing area: main"]');
await editorPage.fillTitle(`${testId}: A Title`);
// Upload image.
await page.setInputFiles('#edit-field-image-0-upload', image1Filepath);
const altField = page.locator('input[name="field_image[0][alt]"]');
await altField.fill(`${testId}: ${uniqueToken1}`);
await editorPage.uploadImage(image1Filepath, `${testId}: ${uniqueToken1}`);
// Fill body.
await ckEditor.fill(bodyText);
await page.getByRole('button', { name: 'Save' }).click();
await editorPage.fillText(bodyText);
await editorPage.save();
//
// Confirm content appears.
//
let divContainer = await page.textContent('.text-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);
const contentPage = new ContentPage(page);
await contentPage.expectText(bodyText);
const nid = await contentPage.getNid();
//
// Update the node.
@@ -193,19 +181,16 @@ test.describe('Node tests.', () => {
bodyText = 'Ut eget ex vitae nibh dapibus vulputate ut id lacus.';
await page.goto(baseUrl + nodeEditUrl);
ckEditor = await page.locator('[aria-label="Editor editing area: main"]');
await ckEditor.fill(bodyText);
await editorPage.fillText(bodyText);
// Timeouts necessary when running at full speed.
await page.waitForTimeout(1000);
await page.getByRole('button', { name: 'Save' }).click();
await editorPage.save();
await page.waitForTimeout(1000);
//
// Confirm content has changed.
//
divContainer = await page.locator('.text-content');
const text = await divContainer.textContent();
await expect(text).toContain(bodyText);
await contentPage.expectText(bodyText);
//
// Delete the node.
Loading