Skip to content

Commit

Permalink
Added getting-started functional testing awslabs#1056
Browse files Browse the repository at this point in the history
  • Loading branch information
Pushpajyothi committed Nov 9, 2023
1 parent 2b34daa commit 5048e78
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
112 changes: 112 additions & 0 deletions tests/functional-homepage-iot-application/getting-started.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { expect, test } from '@playwright/test';
import {
DashboardsIndexPage,
GettingStartedSection,
} from '../pages/dashboards-index.page';

test.describe('Homepage For Iot Application - Getting Started', () => {
// Positive Scenario - Checking for the existence of Getting Started
test('Existence of Getting Started Section in the dashboard', async ({
page,
}) => {
test.slow();

const dashboardsPage = new DashboardsIndexPage(page);
const gettingStartedSection = new GettingStartedSection(page);

// Navigate to the dashboard page
await dashboardsPage.goto();

// Check if the "Getting Started" section is present
expect(gettingStartedSection.gettingStartedButton).toBeDefined();
});

// Positive Scenario - Getting Started remains in expanded by default
test('The "Getting Started" container remains expanded by default', async ({
page,
}) => {
const dashboardsPage = new DashboardsIndexPage(page);
const gettingStartedSection = new GettingStartedSection(page);

// Navigate to the dashboard page
await dashboardsPage.goto();

// Check if "Getting Started" container is expanded by default
await expect(gettingStartedSection.gettingStartedButton).toHaveAttribute(
'aria-expanded',
'true',
);
});

//Positive scenario - Click Getting started for expansion and collapsed modes
test('getting started section expand and collapse ', async ({ page }) => {
const dashboardsPage = new DashboardsIndexPage(page);
const gettingStartedSection = new GettingStartedSection(page);

// Navigate to the dashboard page
await dashboardsPage.goto();

// Collapse the ""Getting Started"" section
await gettingStartedSection.collapseGettingStarted();

// Check if the ""Getting Started"" section is collapsed
await expect(gettingStartedSection.gettingStartedButton).toHaveAttribute(
'aria-expanded',
'false',
);

// Expand the ""Getting Started"" section
await gettingStartedSection.expandGettingStarted();

// Check if the ""Getting Started"" section is expanded
await expect(gettingStartedSection.gettingStartedButton).toHaveAttribute(
'aria-expanded',
'true',
);
});

// Negative Scenario - Getting Started should not be expandable
test('The "Getting Started" should not be expandable', async ({ page }) => {
const dashboardsPage = new DashboardsIndexPage(page);
const gettingStartedSection = new GettingStartedSection(page);

// Navigate to the dashboard page
await dashboardsPage.goto();

// Check if "Getting Started" container is not expandable
const isExpandable =
await gettingStartedSection.isGettingStartedExpandable();
// Assert it is not expandable
expect(isExpandable).toBeFalsy();
});

// Negative Scenario - Getting Started should not be collapsible
test('The "Getting Started" should not be collapsible', async ({ page }) => {
const dashboardsPage = new DashboardsIndexPage(page);
const gettingStartedSection = new GettingStartedSection(page);

// Navigate to the dashboard page
await dashboardsPage.goto();

// Check if "Getting Started" container is not collapsible
const isCollapsible = await gettingStartedSection.isExpanded();
// Assert it is not collapsible
expect(isCollapsible).toBeTruthy();
});

// Negative Scenario - Getting Started section should not be collapsed initially
test('Getting Started section should not be collapsed initially', async ({
page,
}) => {
const dashboardsPage = new DashboardsIndexPage(page);
const gettingStartedSection = new GettingStartedSection(page);

// Navigate to the dashboard page
await dashboardsPage.goto();

// Check if the "Getting Started" section is not collapsed by default
const isExpanded = await gettingStartedSection.isExpanded();
// Assert it not to be collapsed
expect(isExpanded).toBe(true);
});
});
30 changes: 30 additions & 0 deletions tests/pages/dashboards-index.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,33 @@ export class DashboardsIndexPage {
await expect(this.heading).toBeHidden();
}
}

// Adding Getting Started section
export class GettingStartedSection {
public readonly gettingStartedButton: Locator;

constructor(page: Page) {
this.gettingStartedButton = page.getByRole('button', {
name: 'Getting Started',
});
}

public async expandGettingStarted() {
await this.gettingStartedButton.click();
}

public async collapseGettingStarted() {
await this.gettingStartedButton.click();
}

public async isExpanded() {
const ariaExpandedValue =
await this.gettingStartedButton.getAttribute('aria-expanded');
return ariaExpandedValue === 'true';
}
public async isGettingStartedExpandable() {
const expand =
await this.gettingStartedButton.getAttribute('aria-expanded');
return expand === 'false';
}
}

0 comments on commit 5048e78

Please sign in to comment.