Skip to content
Snippets Groups Projects
Commit 2dcb3b42 authored by ilyaukin's avatar ilyaukin
Browse files

Fix feed test.

parent 53323570
No related branches found
No related tags found
1 merge request!31Fix feed test.
...@@ -21,27 +21,29 @@ import atkConfig from '../../../cypress.atk.config'; ...@@ -21,27 +21,29 @@ import atkConfig from '../../../cypress.atk.config';
import qaUserAccounts from '../../data/qaUsers.json'; import qaUserAccounts from '../../data/qaUsers.json';
describe('Feed Tests', () => { describe('Feed Tests', () => {
const ctx = {
feedTypeName: undefined,
}
// //
// Create a new feed definition, import fixture, validate that data is in the database. // Create a new feed definition, import fixture, validate that data is in the database.
// //
it('(ATK-PW-1180) Creates the feed type settings',{ tags: ['@ATK-PW-1180', '@feeds', 'alters-db'] }, () => { it('(ATK-PW-1180) Creates the feed type settings', { tags: ['@ATK-PW-1180', '@feeds', '@alters-db'] }, () => {
const testId = 'ATK-CY-1110'; const testId = 'ATK-CY-1180';
const uniqueToken = atkUtilities.createRandomString(6); const uniqueToken = atkUtilities.createRandomString(6);
const termName = `${testId}: ${uniqueToken}`; const feedTypeName = `${testId}: ${uniqueToken}`;
// Log in with the administrator account. // Log in with the administrator account.
// Assuming logInViaForm is adapted for cypress. // Assuming logInViaForm is adapted for cypress.
cy.logInViaForm(qaUserAccounts.admin); cy.logInViaForm(qaUserAccounts.admin);
cy.visit('https://drupalatk:8890/admin/structure'); cy.visit(atkConfig.feedTypeAddUrl);
// //
// Add a Feed type // Add a Feed type
// //
cy.contains('Feed types').click();
cy.contains('Add feed type').click();
// Fill in the fields. // Fill in the fields.
cy.contains('Name').type('Import with url'); cy.contains('Name').type(feedTypeName);
cy.contains('Description').type('Import feeds'); cy.contains('Description').type('Import feeds');
cy.contains('Explanation').type('ATK Feeds Test'); cy.contains('Explanation').type('ATK Feeds Test');
...@@ -65,33 +67,31 @@ describe('Feed Tests', () => { ...@@ -65,33 +67,31 @@ describe('Feed Tests', () => {
// Save the configured feed type. // Save the configured feed type.
cy.contains('Save and add mappings').click(); cy.contains('Save and add mappings').click();
ctx.feedTypeName = feedTypeName
// Create mapping for imports // Create mapping for imports
cy.get('#edit-add-target').first().select('Title (title)'); cy.get('#edit-add-target').first().select('Title (title)');
cy.get('select[data-drupal-selector="edit-mappings-0-map-value-select"]').select('Title'); cy.get('select[data-drupal-selector="edit-mappings-0-map-value-select"]').select('Title');
// Save mapping structure // Save mapping structure
cy.get('[data-drupal-selector="edit-actions-submit"]').click(); cy.get('[data-drupal-selector="edit-actions-submit"]').click();
}); });
}); it('(ATK-PW-1181) Passes and imports items', { tags: ['@ATK-PW-1181', '@feeds', 'alters-db'] }, () => {
// ctx.feedTypeName must exist to run this test.
cy.wrap(ctx.feedTypeName).should('not.be.undefined', { message: 'Feed type must exist for this test' })
describe('Add Feed Url', () => {
it('(ATK-PW-1181) passes and imports items', { tags: ['@ATK-PW-1181', '@feeds', 'alters-db'] }, () => {
// Login via admin account. // Login via admin account.
cy.logInViaForm(qaUserAccounts.admin); cy.logInViaForm(qaUserAccounts.admin);
cy.visit('/admin/content');
// //
// Add a new feed into the existing feed type. // Add a new feed into the existing feed type.
// //
cy.get('button[aria-label="Tabs display toggle"]').click(); cy.visit(atkConfig.feedAddUrl)
cy.contains('Feeds').click();
cy.contains('Add feed').click();
// Find the existing feed type. // Find the existing feed type.
// Select the feed that you have created. // Select the feed that you have created.
cy.contains('Import with url').click(); cy.contains('a:visible', ctx.feedTypeName).click();
cy.contains('Title').type('nytimes rss business'); cy.contains('Title').type('nytimes rss business');
// //
...@@ -101,5 +101,37 @@ describe('Add Feed Url', () => { ...@@ -101,5 +101,37 @@ describe('Add Feed Url', () => {
// Save and export the feed. // Save and export the feed.
cy.contains('Save and import').click(); cy.contains('Save and import').click();
cy.contains('nytimes rss business has been created.')
// Validate that content items are created.
cy.visit('admin/content')
cy.contains('tr', 'Anonymous')
}); });
after(() => {
//
// Clean up.
//
cy.visit('admin/content/feed')
cy.contains('tr', ctx.feedTypeName).then(($el) => {
if ($el.length) {
const deleteItemsUrl = $el.find('a:contains("Delete items")').attr('href')
const deleteUrl = $el.find('[aria-label^="Delete nytimes"]').attr('href')
cy.visit(deleteItemsUrl)
cy.get('#edit-submit').click({ force: true })
cy.get('h2[id^="status"]') // Wait to finish delete
cy.visit(deleteUrl)
cy.get('#edit-submit').click({ force: true })
}
})
cy.visit('admin/structure/feeds')
cy.contains('tr', ctx.feedTypeName).then(($el) => {
if ($el.length) {
const deleteUrl = $el.find('[aria-label^="Delete ATK"]').attr('href')
cy.visit(deleteUrl)
cy.get('#edit-submit').click({ force: true })
}
})
})
}); });
\ No newline at end of file
...@@ -28,6 +28,8 @@ module.exports = { ...@@ -28,6 +28,8 @@ module.exports = {
termViewUrl: 'taxonomy/term/{tid}', termViewUrl: 'taxonomy/term/{tid}',
xmlSitemapUrl: 'admin/config/search/xmlsitemap', xmlSitemapUrl: 'admin/config/search/xmlsitemap',
blockAddUrl: 'block/add?theme=ucop', blockAddUrl: 'block/add?theme=ucop',
feedTypeAddUrl: 'admin/structure/feeds/add',
feedAddUrl: 'feed/add',
email: { email: {
// Configure email testing using Reroute Email but with Enable rerouting OFF, // Configure email testing using Reroute Email but with Enable rerouting OFF,
// the module will be enabled, right before the test execution, and get back // the module will be enabled, right before the test execution, and get back
......
...@@ -28,6 +28,8 @@ module.exports = { ...@@ -28,6 +28,8 @@ module.exports = {
termViewUrl: 'taxonomy/term/{tid}', termViewUrl: 'taxonomy/term/{tid}',
xmlSitemapUrl: 'admin/config/search/xmlsitemap', xmlSitemapUrl: 'admin/config/search/xmlsitemap',
blockAddUrl: 'block/add?theme=ucop', blockAddUrl: 'block/add?theme=ucop',
feedTypeAddUrl: 'admin/structure/feeds/add',
feedAddUrl: 'feed/add',
authDir: 'tests/support', authDir: 'tests/support',
dataDir: 'tests/data', dataDir: 'tests/data',
supportDir: 'tests/support', supportDir: 'tests/support',
......
...@@ -26,67 +26,103 @@ import atkConfig from '../../playwright.atk.config' ...@@ -26,67 +26,103 @@ import atkConfig from '../../playwright.atk.config'
// Accounts module is enabled. // Accounts module is enabled.
import qaUserAccounts from '../data/qaUsers.json' import qaUserAccounts from '../data/qaUsers.json'
// test.describe('Feeds.', () => {
// Create a new feed definition, import fixture, validate that data is in the database. // Remember names for clean up.
// let feedTypeName = undefined
test('(ATK-PW-1180) Feeds Test using Playwright. Tags : @ATK-PW-1180, @feeds, alters-db', async ({ page }) => {
await page.goto('/');
await page.getByRole('link', { name: 'Log in' }).click();
await page.getByLabel('Username').click();
await page.getByLabel('Username').fill('admin');
await page.getByLabel('Password').click();
await page.getByLabel('Password').fill('admin');
await page.getByRole('button', { name: 'Log in' }).click();
// //
// Add a Feed type // Create a new feed definition, import fixture, validate that data is in the database.
// //
await page.getByRole('link', { name: 'Structure' }).click(); test('(ATK-PW-1180) Feeds Test using Playwright. Tags : @ATK-PW-1180, @feeds, @alters-db', async ({ page, context }) => {
await page.getByRole('link', { name: 'Feed types' }).click(); await page.goto('/');
await page.getByRole('link', { name: '+Add feed type' }).click(); await atkCommands.logInViaForm(page, context, qaUserAccounts.admin);
//
// Add a Feed type
//
await page.goto(atkConfig.feedTypeAddUrl);
// Fill in the fields // Make a unique feed name.
await page.getByLabel('Name', { exact: true }).click(); feedTypeName = 'Import with url ' + atkUtilities.createRandomString(10)
await page.getByLabel('Name', { exact: true }).fill('Import with url');
await page.getByLabel('Description').click();
await page.getByLabel('Description').fill('Import feeds');
await page.getByLabel('Explanation or submission').click();
await page.getByLabel('Explanation or submission').fill('Atk feeds test');
// Save the configured feed type // Fill in the fields
await page.getByRole('button', { name: 'Save and add mappings' }).click(); await page.getByLabel('Name', { exact: true }).click();
await page.getByLabel('Name', { exact: true }).fill(feedTypeName);
await page.getByLabel('Description').click();
await page.getByLabel('Description').fill('Import feeds');
await page.getByLabel('Explanation or submission').click();
await page.getByLabel('Explanation or submission').fill('Atk feeds test');
// // Save the configured feed type
// Create mapping for imports await page.getByRole('button', { name: 'Save and add mappings' }).click();
// await page.waitForEvent('domcontentloaded')
await page.getByLabel('Add a target').selectOption('title');
await page.getByRole('button', { name: 'Save' }).click();
await page.locator('#edit-mappings-0-map-value-select').selectOption('title');
await page.getByRole('button', { name: 'Save' }).click();
await page.getByLabel('Add a target').selectOption('body');
await page.getByRole('button', { name: 'Save' }).click();
await page.locator('#edit-mappings-1-map-value-select').selectOption('feed_description');
await page.getByRole('button', { name: 'Save' }).click();
await page.getByLabel('Add a target').selectOption('feeds_item');
await page.getByRole('button', { name: 'Save' }).click();
// //
// Add a new feed into the existing feed type. // Create mapping for imports
// //
await page.getByRole('link', { name: 'Content', exact: true }).click(); await page.getByLabel('Add a target').selectOption('title');
await page.getByRole('link', { name: 'Feeds' }).click(); await page.locator('[data-drupal-selector="edit-mappings-0-map-value-select"]').selectOption('title');
await page.getByRole('link', { name: '+Add feed' }).click(); await page.getByLabel('Add a target').selectOption('body');
await page.locator('[data-drupal-selector="edit-mappings-1-map-value-select"]').selectOption('feed_description');
await page.locator('[data-drupal-selector="edit-mappings-1-map-summary-select"]').selectOption('feed_title');
await page.getByLabel('Add a target').selectOption('feeds_item');
await page.locator('[data-drupal-selector="edit-mappings-2-map-url-select"]').selectOption('url');
await page.locator('[data-drupal-selector="edit-mappings-2-map-guid-select"]').selectOption('guid');
await page.getByRole('button', { name: 'Save' }).click();
// Find the existing feed type. //
// Select the feed that you have created. // Add a new feed into the existing feed type.
await page.getByRole('link', { name: 'Import with url' }).click(); //
await page.getByLabel('Title').click(); await page.goto(atkConfig.feedAddUrl);
await page.getByLabel('Title').fill('nytimes rss business');
// // Find the existing feed type.
// Insert path to Import file or the data file URL. // Select the feed that you have created.
// await page.getByRole('link', { name: feedTypeName }).click();
await page.getByLabel('Feed URL').click(); await page.getByLabel('Title').click();
await page.getByLabel('Feed URL').fill('https://rss.nytimes.com/services/xml/rss/nyt/Business.xml'); await page.getByLabel('Title').fill('nytimes rss business');
// Save and export the feed.
await page.getByRole('button', { name: 'Save and import' }).click(); //
}); // Insert path to Import file or the data file URL.
//
await page.getByLabel('Feed URL').click();
await page.getByLabel('Feed URL').fill('https://rss.nytimes.com/services/xml/rss/nyt/Business.xml');
// Save and export the feed.
await page.getByRole('button', { name: 'Save and import' }).click();
await page.getByText('nytimes rss business has been created.').waitFor()
// Validate that at least one article is created. (Author should be "Anonymous")
await page.goto('admin/content')
expect(await page.locator('tr', { hasText: 'Anonymous' }).count()).toBeGreaterThan(0)
});
test.afterEach(async ({ page }) => {
//
// Clean up the created entities.
//
// Delete feed items and delete a feed.
await page.goto('admin/content/feed')
const rowLocator = page.locator('tr', { hasText: feedTypeName })
// Skip if the feed doesn't exist.
if (await rowLocator.count()) {
await rowLocator.locator('.dropbutton__toggle').click()
await rowLocator.getByText('Delete items').click()
await page.getByRole('button', { name: 'Delete items' }).click()
await rowLocator.waitFor() // Should we navigate back to the feed row.
await rowLocator.locator('.dropbutton__toggle').click()
await rowLocator.getByText('Delete', { exact: true }).click()
await page.getByRole('button', { name: 'Delete' }).click()
}
// Delete feed type.
await page.goto('admin/structure/feeds')
// Skip if the feed type doesn't exist.
if (await rowLocator.count()) {
await rowLocator.locator('.dropbutton__toggle').click()
await rowLocator.getByText('Delete').click()
await page.getByRole('button', { name: 'Delete' }).click()
}
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment