Skip to content

Commit ec3f57c

Browse files
committed
Add tests for terminal stops tab
1 parent 283f73c commit ec3f57c

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

cypress/e2e/stop-registry/terminals.cy.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,4 +503,98 @@ describe('Terminal details', () => {
503503
},
504504
);
505505
});
506+
507+
describe('stops tab', () => {
508+
it(
509+
'should display stops tab with correct count',
510+
{ tags: [Tag.StopRegistry] },
511+
() => {
512+
terminalDetailsPage.page().shouldBeVisible();
513+
514+
terminalDetailsPage
515+
.getTabSelector()
516+
.getStopsTab()
517+
.shouldHaveText('Pysäkit (2)');
518+
},
519+
);
520+
521+
it(
522+
'should open stops tab and display member stops',
523+
{ tags: [Tag.StopRegistry] },
524+
() => {
525+
terminalDetailsPage.page().shouldBeVisible();
526+
527+
terminalDetailsPage.getTabSelector().getStopsTab().click();
528+
529+
terminalDetailsPage
530+
.getStopsSection()
531+
.getTitle()
532+
.shouldHaveText('Pysäkit');
533+
534+
terminalDetailsPage
535+
.getStopsSection()
536+
.getStopAreas()
537+
.should('have.length', 2);
538+
539+
terminalDetailsPage
540+
.getStopsSection()
541+
.getNthStopArea(0)
542+
.within(() => {
543+
terminalDetailsPage
544+
.getStopsSection()
545+
.getStopAreaHeader()
546+
.should('contain.text', 'Finnoonkartano');
547+
548+
terminalDetailsPage
549+
.getStopsSection()
550+
.getStopAreaStopsTable()
551+
.shouldBeVisible();
552+
terminalDetailsPage
553+
.getStopsSection()
554+
.getStopAreaStopsTable()
555+
.find('tbody tr')
556+
.should('have.length', 1);
557+
});
558+
559+
terminalDetailsPage
560+
.getStopsSection()
561+
.getNthStopArea(1)
562+
.within(() => {
563+
terminalDetailsPage
564+
.getStopsSection()
565+
.getStopAreaHeader()
566+
.should('contain.text', 'Kuttulammentie');
567+
568+
terminalDetailsPage
569+
.getStopsSection()
570+
.getStopAreaStopsTable()
571+
.shouldBeVisible();
572+
terminalDetailsPage
573+
.getStopsSection()
574+
.getStopAreaStopsTable()
575+
.find('tbody tr')
576+
.should('have.length', 1);
577+
});
578+
},
579+
);
580+
581+
it(
582+
'should navigate to stop area details when clicking stop area link',
583+
{ tags: [Tag.StopRegistry] },
584+
() => {
585+
terminalDetailsPage.page().shouldBeVisible();
586+
587+
terminalDetailsPage.getTabSelector().getStopsTab().click();
588+
589+
terminalDetailsPage
590+
.getStopsSection()
591+
.getNthStopArea(0)
592+
.within(() => {
593+
terminalDetailsPage.getStopsSection().getStopAreaHeader().click();
594+
});
595+
596+
cy.url().should('include', '/stop-registry/stop-areas/');
597+
},
598+
);
599+
});
506600
});

cypress/pageObjects/stop-registry/TerminalDetailsPage.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,27 @@ export class TerminalDetailsPage {
3131
validityPeriod() {
3232
return cy.getByTestId('TerminalVersioningRow::validityPeriod');
3333
}
34+
35+
getTabSelector() {
36+
return {
37+
getStopsTab: () => cy.getByTestId('TerminalDetailsPage::stopsTabButton'),
38+
getBasicDetailsTab: () =>
39+
cy.getByTestId('TerminalDetailsPage::basicDetailsTabButton'),
40+
};
41+
}
42+
43+
getStopsSection() {
44+
return {
45+
getTitle: () => cy.getByTestId('TerminalDetailsPage::stopsTitle'),
46+
getStopAreas: () =>
47+
cy.getByTestId('TerminalDetailsPage::stopAreaSection'),
48+
getNthStopArea(index: number) {
49+
return this.getStopAreas().eq(index);
50+
},
51+
getStopAreaHeader: () =>
52+
cy.getByTestId('TerminalDetailsPage::stopAreaHeader'),
53+
getStopAreaStopsTable: () =>
54+
cy.getByTestId('TerminalDetailsPage::stopAreaStopsTable'),
55+
};
56+
}
3457
}

0 commit comments

Comments
 (0)