Skip to content

Commit 8f8b752

Browse files
committed
wip
1 parent a3b7913 commit 8f8b752

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@Hoist @Rope-Record
2+
Feature: Rope Records
3+
4+
Background: Login
5+
Given I navigate to the Rope record page
6+
7+
Scenario: User requests an extension for an In Service rope
8+
Given I navigate to the Rope Detail Page for an In Service rope with Serial number 'CUCSNO168681'
9+
And I provide the following information in the Request Extension form
10+
| Request by days | 4 |
11+
# Then I should be able to see the request in Extension history section

src/pages/CreateRopeRecord.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ export class CreateRopeRecord {
3535
{ name: 'Standard torsion test of the', type: 'input' },
3636
{ name: 'The percentage by mass of', type: 'input' },
3737
{ name: 'The trade name of the', type: 'input' },
38+
{ name: 'Request by days', type: 'input' },
3839
];
3940

4041
// Dynamic field value setter
41-
public async setFieldValue(fieldName: string, value: string, metadata: FormFieldMetadata[]): Promise<void> {
42+
public async setFieldValue(
43+
fieldName: string,
44+
value: string,
45+
metadata: FormFieldMetadata[],
46+
): Promise<void> {
4247
const fieldMeta = metadata.find(meta => meta.name === fieldName);
4348
if (!fieldMeta) {
4449
throw new Error(`Field metadata not found for "${fieldName}"`);
@@ -47,7 +52,10 @@ export class CreateRopeRecord {
4752
}
4853

4954
// Set multiple field values for a specific metadata group
50-
public async setFieldValues(fields: Record<string, string>, metadata: FormFieldMetadata[]): Promise<void> {
55+
public async setFieldValues(
56+
fields: Record<string, string>,
57+
metadata: FormFieldMetadata[],
58+
): Promise<void> {
5159
for (const [fieldName, value] of Object.entries(fields)) {
5260
await this.setFieldValue(fieldName, value, metadata);
5361
}

src/steps/nagivation.steps.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@ Given(
4848
},
4949
);
5050

51+
Given(
52+
'I navigate to the Rope Detail Page for an In Service rope with Serial number {string}',
53+
async function (this: IHoistWorld, serialNumber: string) {
54+
const page = this.page!;
55+
console.log(`Searching for In Service rope: ${serialNumber}`);
56+
57+
try {
58+
await page
59+
.getByRole('gridcell', { name: serialNumber, exact: true })
60+
.click({ timeout: 5000 });
61+
} catch {
62+
const statusHeader = page.locator('.ag-cell-label-container').filter({ hasText: 'Status' });
63+
await statusHeader.locator('.menu-icon').click();
64+
await page.getByLabel('(Select All)').uncheck();
65+
await page.getByLabel('In Service').check();
66+
67+
try {
68+
await page
69+
.getByRole('gridcell', { name: serialNumber, exact: true })
70+
.click({ timeout: 5000 });
71+
} catch {
72+
throw new Error(`Rope ${serialNumber} not found in 'In Service' status`);
73+
}
74+
}
75+
76+
const text = page.getByText('Rope record details', { exact: true });
77+
await expect(text).toBeVisible();
78+
},
79+
);
80+
5181
Given('I navigate to the Rope Detail Page for a {string} rope', async function (this: IHoistWorld) {
5282
const page = this.page!;
5383
await page.getByRole('gridcell', { name: 'status' }).click();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { DataTable, When } from '@cucumber/cucumber';
2+
3+
import { CreateRopeRecord } from '../../../pages/CreateRopeRecord';
4+
import { IHoistWorld } from '../../../support/hoist-world';
5+
6+
When(
7+
'I provide the following information in the Request Extension form',
8+
async function (this: IHoistWorld, requestExtensionInfo: DataTable) {
9+
const page = this.page!;
10+
await page.getByTestId('requestExtButton').click();
11+
const ropeRecord = new CreateRopeRecord(page);
12+
const requestExtensionData = requestExtensionInfo.rowsHash();
13+
for (const [fieldName, value] of Object.entries(requestExtensionData)) {
14+
await ropeRecord.setFieldValue(fieldName, value, ropeRecord.ropeMetadata);
15+
}
16+
await page.getByRole('button', { name: 'Next' }).click();
17+
// for download and Confirmation modal
18+
const download1Promise = page.waitForEvent('download');
19+
await page.getByRole('button', { name: 'Confirm' }).click();
20+
const download1 = await download1Promise;
21+
console.log('downloading email', download1);
22+
},
23+
);

0 commit comments

Comments
 (0)