Skip to content
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
3 changes: 2 additions & 1 deletion source/frontend/src/components/common/ExpandableTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LinkButton } from './buttons';
export interface IExpandableTextCardProps {
text: string;
maxHeight?: number;
dataTestid?: string;
}

export const ExpandableTextCard: React.FunctionComponent<
Expand All @@ -26,7 +27,7 @@ export const ExpandableTextCard: React.FunctionComponent<
}, [max]);

return (
<StyledCard body style={{ padding: 0 }}>
<StyledCard body style={{ padding: 0 }} data-testid={props.dataTestid}>
<Card.Body style={{ padding: 0 }}>
<Card.Text ref={ref} style={{ padding: 0, wordBreak: 'break-all' }}>
<ContentCard style={{ maxHeight: expanded ? 'fit-content' : max }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ export const SelectedDocumentRow: React.FunctionComponent<ISelectedDocumentRowPr
</Col>
</Row>

<StyledErrorDiv className={clsx('ml-0 pb-1')}>{fileError}</StyledErrorDiv>
<StyledErrorDiv
className={clsx('ml-0 pb-1')}
data-testid={`document[${index}]-error-message`}
>
{fileError}
</StyledErrorDiv>
</div>
}
isCollapsable={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,7 @@ exports[`ResearchContainer component > renders as expected 1`] = `
</div>
<div
class="c41 card"
data-testid="request-description"
style="padding: 0px;"
>
<div
Expand Down Expand Up @@ -1461,6 +1462,7 @@ exports[`ResearchContainer component > renders as expected 1`] = `
</div>
<div
class="c41 card"
data-testid="research-result"
style="padding: 0px;"
>
<div
Expand Down Expand Up @@ -1543,6 +1545,7 @@ exports[`ResearchContainer component > renders as expected 1`] = `
</div>
<div
class="c41 card"
data-testid="expropriation-notes"
style="padding: 0px;"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ exports[`ResearchFileTabs component > matches snapshot 1`] = `
</div>
<div
class="c8 card"
data-testid="request-description"
style="padding: 0px;"
>
<div
Expand Down Expand Up @@ -442,6 +443,7 @@ exports[`ResearchFileTabs component > matches snapshot 1`] = `
</div>
<div
class="c8 card"
data-testid="research-result"
style="padding: 0px;"
>
<div
Expand Down Expand Up @@ -522,6 +524,7 @@ exports[`ResearchFileTabs component > matches snapshot 1`] = `
</div>
<div
class="c8 card"
data-testid="expropriation-notes"
style="padding: 0px;"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ const ResearchSummaryView: React.FunctionComponent<IResearchSummaryViewProps> =
</SectionField>
)}
<SectionField label="Description of request"></SectionField>
<ExpandableTextCard text={detail.requestDescription ?? ''} />
<ExpandableTextCard
dataTestid="request-description"
text={detail.requestDescription ?? ''}
/>
</Section>
<Section header="Result">
<SectionField label="Research completed on">
Expand All @@ -135,12 +138,15 @@ const ResearchSummaryView: React.FunctionComponent<IResearchSummaryViewProps> =
: 'not complete'}
</SectionField>
<SectionField label="Result of request" />
<ExpandableTextCard text={detail.researchResult ?? ''} />
<ExpandableTextCard dataTestid="research-result" text={detail.researchResult ?? ''} />
</Section>
<Section header="Expropriation">
<SectionField label="Expropriation?">{detail.isExpropriation ? 'Yes' : 'No'}</SectionField>
<SectionField label="Expropriation comments" />
<ExpandableTextCard text={detail.expropriationNotes ?? ''} />
<ExpandableTextCard
dataTestid="expropriation-notes"
text={detail.expropriationNotes ?? ''}
/>
</Section>
</StyledSummarySection>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ exports[`ResearchSummaryView component > renders as expected 1`] = `
</div>
<div
class="c6 card"
data-testid="request-description"
style="padding: 0px;"
>
<div
Expand Down Expand Up @@ -360,6 +361,7 @@ exports[`ResearchSummaryView component > renders as expected 1`] = `
</div>
<div
class="c6 card"
data-testid="research-result"
style="padding: 0px;"
>
<div
Expand Down Expand Up @@ -442,6 +444,7 @@ exports[`ResearchSummaryView component > renders as expected 1`] = `
</div>
<div
class="c6 card"
data-testid="expropriation-notes"
style="padding: 0px;"
>
<div
Expand Down
30 changes: 30 additions & 0 deletions testing/pims-integration/models/research-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export interface ApiGen_Concepts_ResearchFile {

Check warning on line 1 in testing/pims-integration/models/research-file.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename interface "ApiGen_Concepts_ResearchFile" to match the regular expression ^\$?[A-Z][a-zA-Z0-9]*$.

See more on https://sonarcloud.io/project/issues?id=bcgov_PSP&issues=AZ8GFjkAgEL1MlHh8L2i&open=AZ8GFjkAgEL1MlHh8L2i&pullRequest=5345
id: number;
fileName: string | null;
fileNumber: string | null;
totalAllowableCompensation: number | null;
//fileStatusTypeCode: ApiGen_Base_CodeType<string> | null;
//fileProperties: ApiGen_Concepts_FileProperty[] | null;
roadName: string | null;
roadAlias: string | null;
//fileProperties: ApiGen_Concepts_ResearchFileProperty[] | null;
//requestDate: UtcIsoDate | null;
requestDescription: string | null;
requestSourceDescription: string | null;
researchResult: string | null;
//researchCompletionDate: UtcIsoDate | null;
isExpropriation: boolean | null;
expropriationNotes: string | null;
//requestSourceType: ApiGen_Base_CodeType<string> | null;
//requestorPerson: ApiGen_Concepts_Person | null;
//requestorOrganization: ApiGen_Concepts_Organization | null;
//researchFilePurposes: ApiGen_Concepts_ResearchFilePurpose[] | null;
//researchFileProjects: ApiGen_Concepts_ResearchFileProject[] | null;
//appCreateTimestamp: UtcIsoDateTime;
//appLastUpdateTimestamp: UtcIsoDateTime;
appLastUpdateUserid: string | null;
appCreateUserid: string | null;
appLastUpdateUserGuid: string | null;
appCreateUserGuid: string | null;
rowVersion: number | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ export class DocumentUploadModalPage {
}

async getDocumentErrorLabel(index: number = 0): Promise<string> {
const documentHeaderWrapper = this.page.locator(
`//div[@data-testid='document[${index}]-error']/parent::div/following-sibling::div`
);
return await documentHeaderWrapper.innerText();
const documentErrorLabel = this.page.getByTestId(`document[${index}]-error-message`);
return await documentErrorLabel.innerText();
}

async getDocumentErrorFilename(index: number = 0): Promise<string> {
Expand Down
16 changes: 0 additions & 16 deletions testing/pims-integration/pages/research/research-create.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ export class ResearchCreatePage extends LayoutPage {
await this.page.goto('/mapview/sidebar/research/new', { waitUntil: 'domcontentloaded' });
}

async setResearchNameValue(researchName: string) {
const now = new Date();

const timestamp =
now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0') +
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0') +
String(now.getSeconds()).padStart(2, '0');

const fileName = `${researchName}-${timestamp}`;

await this.researchNameInput.fill(fileName);
}

async cancelButtonClick() {
await this.cancelButton.click();
}
Expand Down
40 changes: 40 additions & 0 deletions testing/pims-integration/pages/research/research-list.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class ResearchListPage extends LayoutPage {

readonly researcSearchByLabel: Locator;
readonly researchByRegionSelect: Locator;
readonly researchSearchNameInput: Locator;
readonly researchByStatusSelect: Locator;
readonly researchSearchBySelect: Locator;
readonly researchSearchPidInput: Locator;
Expand Down Expand Up @@ -74,6 +75,7 @@ export class ResearchListPage extends LayoutPage {
this.researchByStatusSelect = page.locator('#input-researchFileStatusTypeCode');
this.researchSearchBySelect = page.locator('#input-researchSearchBy');
this.researchSearchPidInput = page.locator('#input-pid');
this.researchSearchNameInput = page.locator('#input-name');
this.researchSearchRoadInput = page.locator('#input-roadOrAlias');
this.researchSearchDateSelect = page.locator('#input-createOrUpdateRange');
this.researchSearchDateToInput = page.locator('#datepicker-updatedOnStartDate');
Expand Down Expand Up @@ -134,4 +136,42 @@ export class ResearchListPage extends LayoutPage {
async createNewResearchClick() {
await this.researchNewButton.click();
}

async openResearchFileInNewTab(index: number): Promise<Page> {
const selectedFile = this.page
.getByTestId('researchFilesTable')
.locator('.tbody .tr-wrapper')
.nth(index - 1)
.locator('a');
const [newPage] = await Promise.all([
this.page.context().waitForEvent('page'),
selectedFile.click(),
]);

await newPage.waitForLoadState('domcontentloaded');
await newPage.waitForURL(/\/mapview\/sidebar\/research\/\d+/, {
timeout: 30000,
});
// eslint-disable-next-line playwright/no-networkidle
await newPage.waitForLoadState('networkidle');
await newPage.bringToFront();

return newPage;
}

async searchByName(name: string) {
await this.researchSearchBySelect.selectOption('Research file name');
await this.researchSearchNameInput.fill(name);
await this.researchSearchButton.click();
}

async clickResearchFileResult(index: number): Promise<void> {
const link = this.page
.getByTestId('researchFilesTable')
.locator('.tbody .tr-wrapper')
.nth(index - 1)
.locator('a');

await link.click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,20 @@ export class ResearchViewFileDetails extends LayoutPage {

readonly researchProjectSubtitle: Locator;
readonly researchProjectLabel: Locator;
readonly researchProjectContent: Locator;

readonly reseachRoadTitle: Locator;
readonly researchRoadNameLabel: Locator;
readonly researchRoadNameContent: Locator;
readonly researchRoadAliasLabel: Locator;
readonly researchRoadAliasContent: Locator;

readonly researchRequestTitle: Locator;
readonly researchPurposeLabel: Locator;
readonly researchPurposeContent: Locator;
readonly researchRequestDateLabel: Locator;
readonly researchSourceRequestLabel: Locator;
readonly researchRequestDateContent: Locator;

readonly researchRequesterLabel: Locator;
readonly researchSourceRequestContent: Locator;
readonly researchRequesterContent: Locator;
readonly researchDescriptionLabel: Locator;
readonly researchDescriptionContent: Locator;

readonly researchResultTitle: Locator;
readonly researchCompletedOnLabel: Locator;
Expand All @@ -48,29 +43,17 @@ export class ResearchViewFileDetails extends LayoutPage {

this.researchProjectSubtitle = page.locator('div').filter({ hasText: 'Project' }).first();
this.researchProjectLabel = page.getByText('Ministry project:', { exact: true });
this.researchProjectContent = page.locator(
"//label[text()='Ministry project']/parent::div/following-sibling::div"
);

this.reseachRoadTitle = page.getByText('Roads', { exact: true });
this.researchRoadNameLabel = page.locator('label:has-text("Road name:")');
this.researchRoadNameContent = page.locator(
"//label[text()='Road name:']/parent::div/following-sibling::div"
);

this.researchRoadAliasLabel = page.locator('label:has-text("Road alias:")');
this.researchRoadAliasContent = page.locator(
"//label[text()='Road alias:']/parent::div/following-sibling::div"
);

this.researchRequestTitle = page.getByText('Research Request', { exact: true });
this.researchPurposeLabel = page.getByText('Research purpose:', { exact: true });
this.researchPurposeContent = page.locator(
"//label[text()='Research purpose:']/parent::div/following-sibling::div"
);

this.researchRequestDateLabel = page.getByText('Request date:', { exact: true });
this.researchRequestDateContent = page.locator(
"//label[text()='Request date:']/parent::div/following-sibling::div"
);

this.researchSourceRequestLabel = page.getByText('Source of request:', { exact: true });
this.researchSourceRequestContent = page.locator(
"//label[text()='Source of request:']/parent::div/following-sibling::div"
Expand All @@ -80,9 +63,6 @@ export class ResearchViewFileDetails extends LayoutPage {
"//label[text()='Source of request:']/parent::div/following-sibling::div"
);
this.researchDescriptionLabel = page.locator('label:has-text("Requester:")');
this.researchDescriptionContent = page.locator(
"//label[text()='Requester:']/parent::div/following-sibling::div"
);

this.researchResultTitle = page.locator(':text-is("Result")');
this.researchCompletedOnLabel = page.locator('label:has-text("Research completed on:")');
Expand All @@ -96,4 +76,24 @@ export class ResearchViewFileDetails extends LayoutPage {
async navigateDocumentsTab() {
await this.researchDocumentTab.click();
}

async getFieldValueByLabel(label: string): Promise<string> {
return await this.page
.locator(
`//label[contains(normalize-space(), '${label}')]/parent::div/following-sibling::div`
)
.innerText();
}

async getResearchDescription(): Promise<string> {
return (await this.page.getByTestId('request-description').locator('label').innerText()).trim();
}

async getResearchResult(): Promise<string> {
return (await this.page.getByTestId('research-result').locator('label').innerText()).trim();
}

async getResearchExpropriationNotes(): Promise<string> {
return (await this.page.getByTestId('expropriation-notes').locator('label').innerText()).trim();
}
}
Loading