Skip to content

Commit d5fc2c2

Browse files
committed
Add test for latest changes in line page
1 parent 7c7c87b commit d5fc2c2

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

cypress/e2e/lineChangeHistory.cy.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,4 +515,66 @@ describe('Line & Route Change History', { tags }, () => {
515515
.getAllGroupElements()
516516
.should('have.length', 0);
517517
});
518+
519+
it('Should display 3 latest change history items on line details page', () => {
520+
cy.section('Verify initial state', () => {
521+
LineDetailsPage.latestChangeHistory.container().shouldBeVisible();
522+
LineDetailsPage.latestChangeHistory
523+
.title()
524+
.shouldBeVisible()
525+
.should('contain.text', 'Muutoshistoria');
526+
527+
LineDetailsPage.latestChangeHistory.getItems().should('have.length', 3);
528+
});
529+
530+
cy.section('Make multiple changes to create history', () => {
531+
// Change 1
532+
LineDetailsPage.getEditLineButton().click();
533+
LineForm.getFinnishNameInput().clearAndType('First change');
534+
LineForm.save();
535+
LineForm.checkLineSubmitSuccess();
536+
537+
// Change 2
538+
LineDetailsPage.getEditLineButton().click();
539+
LineForm.getFinnishNameInput().clearAndType('Second change');
540+
LineForm.save();
541+
LineForm.checkLineSubmitSuccess();
542+
543+
// Change 3
544+
LineDetailsPage.getEditLineButton().click();
545+
LineForm.getFinnishNameInput().clearAndType('Third change');
546+
LineForm.save();
547+
LineForm.checkLineSubmitSuccess();
548+
549+
// Change 4 to ensure only 3 latest changes are shown
550+
LineDetailsPage.getEditLineButton().click();
551+
LineForm.getFinnishNameInput().clearAndType('Fourth change');
552+
LineForm.save();
553+
LineForm.checkLineSubmitSuccess();
554+
});
555+
556+
cy.section('Verify 3 latest changes are displayed', () => {
557+
LineDetailsPage.latestChangeHistory.getItems().should('have.length', 3);
558+
559+
LineDetailsPage.latestChangeHistory
560+
.getNthItem(0)
561+
.should('contain.text', 'Linja 901')
562+
.and('contain.text', 'Fourth change');
563+
564+
LineDetailsPage.latestChangeHistory
565+
.getNthItem(1)
566+
.should('contain.text', 'Linja 901')
567+
.and('contain.text', 'Third change');
568+
569+
LineDetailsPage.latestChangeHistory
570+
.getNthItem(2)
571+
.should('contain.text', 'Linja 901')
572+
.and('contain.text', 'Second change');
573+
});
574+
575+
cy.section('Verify "Show all" link', () => {
576+
LineDetailsPage.latestChangeHistory.showAllLink().click();
577+
cy.url().should('include', '/lines/901/history');
578+
});
579+
});
518580
});

cypress/pageObjects/routes-and-lines/LineDetailsPage.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,15 @@ export class LineDetailsPage {
3939
static getChangeHistoryLink() {
4040
return cy.getByTestId('LineTitle::changeHistoryLink');
4141
}
42+
43+
static latestChangeHistory = {
44+
container: () => cy.getByTestId('LatestLineChangeHistoryTable::Container'),
45+
title: () => cy.getByTestId('LatestLineChangeHistoryTable::Title'),
46+
showAllLink: () =>
47+
cy.getByTestId('LatestLineChangeHistoryTable::ShowAllLink'),
48+
getItems: () =>
49+
cy.get('[data-testid^="LatestLineChangeHistoryTable::Item"]'),
50+
getNthItem: (index: number) =>
51+
cy.get('[data-testid^="LatestLineChangeHistoryTable::Item"]').eq(index),
52+
};
4253
}

0 commit comments

Comments
 (0)