mirror of
https://github.com/Redocly/redoc.git
synced 2025-11-04 17:57:30 +03:00
Co-authored-by: Roman Hotsiy <gotsijroman@gmail.com> Co-authored-by: Alex Varchuk <olexandr.varchuk@gmail.com> Co-authored-by: Oprysk Vyacheslav <vyacheslav@redocly.com> Co-authored-by: Ivan Kropyvnytskyi <130547411+ivankropyvnytskyi@users.noreply.github.com> Co-authored-by: Yevhen Pylyp <yevhen.pylyp@redocly.com> Co-authored-by: Vladyslav Makarenko <vladyslav.makarenko@redocly.com> Co-authored-by: Yevhenii Medviediev <yevhenii.medviediev@redocly.com> Co-authored-by: Oleksii Horbachevskyi <oleksii.horbachevskyi@redocly.com> Co-authored-by: volodymyr-rutskyi <rutskyi.v@gmail.com> Co-authored-by: Adam Altman <adam@redoc.ly> Co-authored-by: Andrew Tatomyr <andrew.tatomyr@redocly.com> Co-authored-by: Anastasiia Derymarko <anastasiia@redocly.com> Co-authored-by: Roman Marshevskyy <roman.marshevskyy@redoc.ly> Co-authored-by: Lorna Mitchell <lorna.mitchell@redocly.com> Co-authored-by: Taylor Krusen <taylor.krusen@redocly.com>
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { type Page, expect } from '@playwright/test';
|
|
|
|
export default class Section {
|
|
readonly page: Page;
|
|
readonly sectionId: string;
|
|
|
|
constructor(page, sectionId: string = 'pet/addpet') {
|
|
this.page = page;
|
|
this.sectionId = sectionId;
|
|
}
|
|
|
|
getSection() {
|
|
return this.page.locator(`[data-section-id="${this.sectionId}"]`);
|
|
}
|
|
|
|
getOperationNavigationList() {
|
|
return this.getSection().locator('[data-testid="operation-navigation-list"]');
|
|
}
|
|
|
|
getRequest() {
|
|
return this.getSection().getByText('Request');
|
|
}
|
|
|
|
getCookies() {
|
|
return this.getSection().getByText('Cookies');
|
|
}
|
|
|
|
getHeaders() {
|
|
return this.getSection().getByText('Headers');
|
|
}
|
|
|
|
getBody() {
|
|
return this.getSection().getByText('Body');
|
|
}
|
|
|
|
getResponses() {
|
|
return this.getSection().getByText('Responses');
|
|
}
|
|
|
|
getSamples() {
|
|
return this.page.locator('div.panel-container-request-samples');
|
|
}
|
|
|
|
getSamplesHeader() {
|
|
return this.getSamples().locator('[data-component-name="Panel/PanelHeader"]');
|
|
}
|
|
|
|
async verifyAllSchemaLinksHaveHref() {
|
|
const schemaLinks = await this.getSection().locator('a .schema-name').count();
|
|
for (let i = 0; i < schemaLinks; i++) {
|
|
await expect(
|
|
this.getSection().locator('a .schema-name').nth(i).locator('..'),
|
|
).toHaveAttribute('href', /.*/);
|
|
}
|
|
}
|
|
|
|
async verifyHeaderDeepLink(headerId: string) {
|
|
await expect(this.page.locator(`[id="${headerId}"] a`)).toHaveAttribute(
|
|
'href',
|
|
new RegExp(`.*#${headerId.replace(/\//g, '\\/')}`),
|
|
);
|
|
}
|
|
}
|