Skip to content

Commit

Permalink
MWPW-138701: CAAS tests on page load (#367)
Browse files Browse the repository at this point in the history
* NALA tests for CAAS

* selector

* updated test

* fixing linting errors

* more linting errors

* fix linting 3

* fix linting 4

* fix linting 5

* fixed spacing issue

---------

Co-authored-by: Gayane Mirijanyan <[email protected]>
Co-authored-by: Gayane Mirijanyan <[email protected]>
  • Loading branch information
3 people authored Jun 12, 2024
1 parent a9bb65a commit 2bd1951
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
16 changes: 16 additions & 0 deletions features/milo/caas.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
FeatureName: 'CAAS Feature',
features: [
{
tcid: '0',
name: '@Card Collection',
path: '/drafts/nala/features/caas/caascollection',
data: {
cardsPerPage: 4,
caasTitle: 'Consonant Card Collection Title',
paginator: '1 - 4 of 8 results',
},
tags: '@caas @smoke @regression @milo',
},
],
};
10 changes: 10 additions & 0 deletions selectors/milo/caas.feature.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default class Caas {
constructor(page) {
this.page = page;

// caas locators
this.caasCards = this.page.locator('.consonant-Card');
this.caasTitle = this.page.locator('.consonant-FiltersInfo-title');
this.caasPaginator = this.page.locator('.consonant-Pagination-summary');
}
}
43 changes: 43 additions & 0 deletions tests/milo/caas.feature.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect, test } from '@playwright/test';
import { features } from '../../features/milo/caas.spec.js';
import Caas from '../../selectors/milo/caas.feature.page.js';

let caas;
let consoleErrors = [];

test.describe('Milo CAAS Feature test suite', () => {
test.beforeEach(async ({ page }) => {
caas = new Caas(page);

page.on('console', (exception) => {
if (exception.type() === 'error') {
consoleErrors.push(exception.text());
}
});
});

test.afterEach(async () => {
consoleErrors = [];
});

// Test 0 : Card Collection
test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[0].path}`);
const { data } = features[0];

await test.step('step-1: Go to CAAS collection test page', async () => {
await page.goto(`${baseURL}${features[0].path}`);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(`${baseURL}${features[0].path}`);
});

await test.step('step-2: Verify CAAS collection content/specs', async () => {
// verify number of cards in the collection
await expect(await caas.caasCards).toHaveCount(data.cardsPerPage);

Check failure on line 36 in tests/milo/caas.feature.test.js

View workflow job for this annotation

GitHub Actions / Running tests (ubuntu-latest)

[milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @Card Collection

1) [milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @card Collection,@caas @smoke @regression @milo › step-2: Verify CAAS collection content/specs Error: Timed out 5000ms waiting for expect(locator).toHaveCount(expected) Locator: locator('.consonant-Card') Expected: 4 Received: 0 Call log: - expect.toHaveCount with timeout 5000ms - waiting for locator('.consonant-Card') - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" 34 | await test.step('step-2: Verify CAAS collection content/specs', async () => { 35 | // verify number of cards in the collection > 36 | await expect(await caas.caasCards).toHaveCount(data.cardsPerPage); | ^ 37 | 38 | // verify caas title and paginator 39 | await expect(await caas.caasTitle).toContainText(data.caasTitle); at /home/runner/work/nala/nala/tests/milo/caas.feature.test.js:36:42

Check failure on line 36 in tests/milo/caas.feature.test.js

View workflow job for this annotation

GitHub Actions / Running tests (ubuntu-latest)

[milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @Card Collection

1) [milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @card Collection,@caas @smoke @regression @milo › step-2: Verify CAAS collection content/specs Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toHaveCount(expected) Locator: locator('.consonant-Card') Expected: 4 Received: 0 Call log: - expect.toHaveCount with timeout 5000ms - waiting for locator('.consonant-Card') - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" 34 | await test.step('step-2: Verify CAAS collection content/specs', async () => { 35 | // verify number of cards in the collection > 36 | await expect(await caas.caasCards).toHaveCount(data.cardsPerPage); | ^ 37 | 38 | // verify caas title and paginator 39 | await expect(await caas.caasTitle).toContainText(data.caasTitle); at /home/runner/work/nala/nala/tests/milo/caas.feature.test.js:36:42

Check failure on line 36 in tests/milo/caas.feature.test.js

View workflow job for this annotation

GitHub Actions / Running tests (macos-latest)

[milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @Card Collection

1) [milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @card Collection,@caas @smoke @regression @milo › step-2: Verify CAAS collection content/specs Error: Timed out 5000ms waiting for expect(locator).toHaveCount(expected) Locator: locator('.consonant-Card') Expected: 4 Received: 0 Call log: - expect.toHaveCount with timeout 5000ms - waiting for locator('.consonant-Card') - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" 34 | await test.step('step-2: Verify CAAS collection content/specs', async () => { 35 | // verify number of cards in the collection > 36 | await expect(await caas.caasCards).toHaveCount(data.cardsPerPage); | ^ 37 | 38 | // verify caas title and paginator 39 | await expect(await caas.caasTitle).toContainText(data.caasTitle); at /Users/runner/work/nala/nala/tests/milo/caas.feature.test.js:36:42

Check failure on line 36 in tests/milo/caas.feature.test.js

View workflow job for this annotation

GitHub Actions / Running tests (macos-latest)

[milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @Card Collection

1) [milo-live-chromium] › caas.feature.test.js:24:7 › Milo CAAS Feature test suite › @card Collection,@caas @smoke @regression @milo › step-2: Verify CAAS collection content/specs Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toHaveCount(expected) Locator: locator('.consonant-Card') Expected: 4 Received: 0 Call log: - expect.toHaveCount with timeout 5000ms - waiting for locator('.consonant-Card') - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" 34 | await test.step('step-2: Verify CAAS collection content/specs', async () => { 35 | // verify number of cards in the collection > 36 | await expect(await caas.caasCards).toHaveCount(data.cardsPerPage); | ^ 37 | 38 | // verify caas title and paginator 39 | await expect(await caas.caasTitle).toContainText(data.caasTitle); at /Users/runner/work/nala/nala/tests/milo/caas.feature.test.js:36:42

// verify caas title and paginator
await expect(await caas.caasTitle).toContainText(data.caasTitle);
await expect(await caas.caasPaginator).toContainText(data.paginator);
});
});
});

0 comments on commit 2bd1951

Please sign in to comment.