Skip to content

Commit 770fbe0

Browse files
committed
test for em test, better date handling, import fixes
1 parent c910bda commit 770fbe0

File tree

15 files changed

+109
-81
lines changed

15 files changed

+109
-81
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@Hoist @Rope-Record
2+
Feature: Rope Records
3+
4+
Background: Login
5+
Given I navigate to the Rope record page
6+
And I navigate to the Rope Detail Page for an In Service rope
7+
8+
Scenario: User adds a new EM test record
9+
When I provide the following information in the Add EM test record form
10+
| EM test date | June 28, 2024 |
11+
| Percent loss | 23 |
12+
Then I should be able to see the record in the Records table
13+

src/fixtures/sample.pdf

38.5 KB
Binary file not shown.

src/pages/CreateRopeRecord.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, Page } from '@playwright/test';
22

3-
import { FormFieldMetadata, FormHelper } from '../support/FormHelper';
3+
import { FormFieldMetadata, FormHelper } from '@/support/FormHelper';
44

55
export class CreateRopeRecord {
66
private readonly page: Page;
@@ -37,6 +37,8 @@ export class CreateRopeRecord {
3737
{ name: 'The trade name of the', type: 'input' },
3838
{ name: 'Request by days', type: 'input' },
3939
{ name: 'Request by date', type: 'date' },
40+
{ name: 'EM test date', type: 'date' },
41+
{ name: 'Percent loss', type: 'input' },
4042
];
4143

4244
// Dynamic field value setter

src/pages/EmailVerification.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { Download, expect, Page } from '@playwright/test';
1+
import { Download, expect } from '@playwright/test';
22

33
export class EmailVerification {
4-
private readonly page: Page;
5-
6-
constructor(page: Page) {
7-
this.page = page;
8-
}
9-
104
verifyEmail(download: Download, expectedFilePattern: RegExp): boolean {
115
const filename = download.suggestedFilename();
126
expect(filename).toMatch(expectedFilePattern);

src/steps/action-items/update-action-item.page.ts renamed to src/steps/action-items/update-action-item.steps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { DataTable, Given, Then } from '@cucumber/cucumber';
22
import { expect } from 'playwright/test';
33

4-
import { ActionItems } from '../../pages/ActionItems';
5-
import { IHoistWorld } from '../../support/hoist-world';
4+
import { ActionItems } from '@/pages/ActionItems';
5+
import { IHoistWorld } from '@/support/hoist-world';
66

77
Then('I can see Hoist and shaft action items text', async function (this: IHoistWorld) {
88
const page = this.page!;

src/steps/login.steps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Given, Then, When } from '@cucumber/cucumber';
22
import { Browser, chromium, Page } from '@playwright/test';
33

4-
import { LoginPage } from '../pages/LoginPage';
5-
import { IHoistWorld } from '../support/hoist-world';
4+
import { LoginPage } from '@/pages/LoginPage';
5+
import { IHoistWorld } from '@/support/hoist-world';
66

77
let browser: Browser;
88
let page: Page;

src/steps/nagivation.steps.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { Given } from '@cucumber/cucumber';
22
import { Page } from '@playwright/test';
33
import { expect } from 'playwright/test';
44

5+
import { HoistWorld, IHoistWorld } from '@/support/hoist-world';
6+
57
import { SCREENSHOT_DIR } from '../../constants';
6-
import { HoistWorld, IHoistWorld } from '../support/hoist-world';
78

89
async function filterRopesByStatus(page: Page, status?: string) {
910
const statusHeader = page.locator('.ag-cell-label-container').filter({ hasText: 'Status' });

src/steps/rope-record/add-new-rope/add-new-rope.page.ts renamed to src/steps/rope-record/add-new-rope/add-new-rope.steps.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { DataTable, Given, When } from '@cucumber/cucumber';
22

3+
import { CreateRopeRecord } from '@/pages/CreateRopeRecord';
4+
import { HoistWorld, IHoistWorld } from '@/support/hoist-world';
5+
import { UniqueIdentifierGenerator } from '@/support/UniqueIdentifierGenerator';
6+
37
import { SCREENSHOT_DIR } from '../../../../constants';
4-
import { CreateRopeRecord } from '../../../pages/CreateRopeRecord';
5-
import { HoistWorld, IHoistWorld } from '../../../support/hoist-world';
6-
import { UniqueIdentifierGenerator } from '../../../support/UniqueIdentifierGenerator';
78

89
Given('I add a new rope', async function (this: IHoistWorld) {
910
const createRopeRecord = new CreateRopeRecord(this.page!);

src/steps/rope-record/rope-details/request-extension.ts renamed to src/steps/rope-record/rope-details/request-extension.steps.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Then, When } from '@cucumber/cucumber';
22
import { expect } from '@playwright/test';
33

4-
import { CreateRopeRecord } from '../../../pages/CreateRopeRecord';
5-
import { EmailVerification } from '../../../pages/EmailVerification';
6-
import { IHoistWorld } from '../../../support/hoist-world';
4+
import { CreateRopeRecord } from '@/pages/CreateRopeRecord';
5+
import { EmailVerification } from '@/pages/EmailVerification';
6+
import { IHoistWorld } from '@/support/hoist-world';
77

88
Then(
99
'I should be able to see the request in Extension history section',
@@ -22,7 +22,7 @@ Then(
2222
await page.getByRole('button', { name: 'Confirm' }).click();
2323
const emailDownload = await downloadPromise;
2424

25-
const emailPage = new EmailVerification(this.page!);
25+
const emailPage = new EmailVerification();
2626
emailPage.verifyEmail(emailDownload, /^Request extension -.+\.eml$/);
2727

2828
// navigate to Rope information tab to verify the extension request
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { DataTable, Then, When } from '@cucumber/cucumber';
2+
import { expect } from '@playwright/test';
3+
4+
import { CreateRopeRecord } from '@/pages/CreateRopeRecord';
5+
import { IHoistWorld } from '@/support/hoist-world';
6+
7+
When(
8+
'I provide the following information in the Add EM test record form',
9+
async function (this: IHoistWorld, emTestRecordInfo: DataTable) {
10+
await this.page?.getByTestId('Add record').click();
11+
const ropeRecord = new CreateRopeRecord(this.page!);
12+
const emTestRecord = emTestRecordInfo.rowsHash();
13+
for (const [fieldName, value] of Object.entries(emTestRecord)) {
14+
await ropeRecord.setFieldValue(fieldName, value, ropeRecord.ropeMetadata);
15+
}
16+
17+
// attach sample.pdf as the file
18+
await this.page
19+
?.locator('input[data-testid="openAttachmentUpload"]')
20+
.setInputFiles('src/fixtures/sample.pdf');
21+
},
22+
);
23+
24+
Then('I should be able to see the record in the Records table', async function (this: IHoistWorld) {
25+
const page = this.page!;
26+
27+
// save the EM test date input
28+
const savedPercentLoss = await page
29+
.getByRole('textbox', { name: 'Percent loss', exact: true })
30+
.inputValue();
31+
32+
// save the form
33+
await page.getByRole('button', { name: 'Save', exact: true }).click();
34+
35+
// wait for success notification
36+
await expect(page.getByText('EM test record added')).toBeVisible();
37+
38+
// verify saved percent loss
39+
await expect(page.getByRole('main')).toContainText(`${savedPercentLoss}%`);
40+
});

0 commit comments

Comments
 (0)