Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e-tests: headlamp.spec: Add test for pagination #1798

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions e2e-tests/tests/headlamp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,20 @@ test('404 page is present', async ({ page }) => {
await headlampPage.authenticate();
await headlampPage.navigateTopage('/404test', /Whoops! This page doesn't exist/);
});

test('pagination goes to next page', async ({ page }) => {
const headlampPage = new HeadlampPage(page);
await headlampPage.authenticate();

const securityPage = new SecurityPage(page);
await securityPage.navigateToSecurity();
await securityPage.clickOnRolesSection();

// Check if there is text "Rows per page" on the page
await headlampPage.checkPageContent('Rows per page');

// Check working of pagination
await headlampPage.checkRows();
});

// --- Headlamp tests end --- //
22 changes: 22 additions & 0 deletions e2e-tests/tests/headlampPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class HeadlampPage {
}

async checkPageContent(text: string) {
await this.page.waitForSelector(`:has-text("${text}")`);
const pageContent = await this.page.content();
expect(pageContent).toContain(text);
}
Expand Down Expand Up @@ -97,4 +98,25 @@ export class HeadlampPage {
await this.page.click(`a:has-text("${pluginName}")`);
await this.page.waitForLoadState('load');
}

async checkRows() {
// Get value of rows per page
const rowsDisplayed1 = await this.getRowsDisplayed();

// Click on the next page button
const nextPageButton = this.page.getByTitle('Next page');
await nextPageButton.click();

// Get value of rows per page after clicking next page button
const rowsDisplayed2 = await this.getRowsDisplayed();

// Check if the rows displayed are different
expect(rowsDisplayed1).not.toBe(rowsDisplayed2);
}

async getRowsDisplayed() {
const paginationCaption = this.page.locator("p:has-text(' of ')");
const captionText = await paginationCaption.textContent();
return captionText;
}
}
9 changes: 9 additions & 0 deletions e2e-tests/tests/securityPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ export class SecurityPage {
// Wait for the page to load
await this.page.waitForLoadState('load');
}

async clickOnRolesSection() {
// Wait for the Service Accounts tab to load
await this.page.waitForSelector('span:has-text("Roles")');
// Click on the "Service Accounts" section
await this.page.click('span:has-text("Roles")');
// Wait for the page to load
await this.page.waitForLoadState('load');
}
}
Loading