From 7eb8c3e93b662845103615a78f2fc25a81788b42 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 29 Aug 2023 11:10:24 +1000 Subject: [PATCH] test: :white_check_mark: add default contentType prop, tests --- .../search-listing/pagination.feature | 11 +++++++++++ .../step_definitions/content-types/listing.ts | 19 +++++++++++++++++++ .../pagination/RplPagination.stories.mdx | 3 +-- .../components/pagination/RplPagination.vue | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/examples/nuxt-app/test/features/search-listing/pagination.feature b/examples/nuxt-app/test/features/search-listing/pagination.feature index d9d8495e1d..82fa2da687 100644 --- a/examples/nuxt-app/test/features/search-listing/pagination.feature +++ b/examples/nuxt-app/test/features/search-listing/pagination.feature @@ -106,3 +106,14 @@ Feature: Searching listing - Pagination | title | | Soup | | Biscuit | + + @mockserver + Example: Aria labels are set on pagination controls + Given the page endpoint for path "/pagination" returns fixture "/search-listing/pagination/page" with status 200 + And the search network request is stubbed with fixture "/search-listing/pagination/response-page-3" and status 200 + And the current date is "Fri, 02 Feb 2050 03:04:05 GMT" + When I visit the page "/pagination?page=2" + + Then the "Previous" pagination link should have an aria-label "Go to previous page" + And the "Next" pagination link should have an aria-label "Go to next page" + And the "3" complex pagination link should have an aria-label "Go to page 3" diff --git a/packages/ripple-test-utils/step_definitions/content-types/listing.ts b/packages/ripple-test-utils/step_definitions/content-types/listing.ts index 146513fb52..40a0e2bf6c 100644 --- a/packages/ripple-test-utils/step_definitions/content-types/listing.ts +++ b/packages/ripple-test-utils/step_definitions/content-types/listing.ts @@ -214,3 +214,22 @@ Then( }) } ) + +Then( + 'the {string} pagination link should have an aria-label {string}', + (label: string, text: string) => { + cy.get('.rpl-pagination__link') + .contains(label) + .should('have.attr', 'aria-label', text) + } +) + +Then( + 'the {string} complex pagination link should have an aria-label {string}', + (label: string, text: string) => { + cy.get('.rpl-pagination__page') + .contains(label) + .parent() + .should('have.attr', 'aria-label', text) + } +) diff --git a/packages/ripple-ui-core/src/components/pagination/RplPagination.stories.mdx b/packages/ripple-ui-core/src/components/pagination/RplPagination.stories.mdx index f7efcb9565..05eae0277b 100644 --- a/packages/ripple-ui-core/src/components/pagination/RplPagination.stories.mdx +++ b/packages/ripple-ui-core/src/components/pagination/RplPagination.stories.mdx @@ -28,8 +28,7 @@ export const SingleTemplate = (args) => ({ label: 'Page navigation', totalPages: 20, currentPage: 1, - surroundingPages: 3, - contentType: 'Page' + surroundingPages: 3 }} /> diff --git a/packages/ripple-ui-core/src/components/pagination/RplPagination.vue b/packages/ripple-ui-core/src/components/pagination/RplPagination.vue index 9ba9ada6b6..bbe654012a 100644 --- a/packages/ripple-ui-core/src/components/pagination/RplPagination.vue +++ b/packages/ripple-ui-core/src/components/pagination/RplPagination.vue @@ -25,7 +25,7 @@ const props = withDefaults(defineProps(), { label: undefined, currentPage: 1, surroundingPages: 2, - contentType: undefined, + contentType: 'page', showTally: false, variant: 'complex', prevLabel: 'Previous',