|
| 1 | +import { Given, Then, When } from 'cypress-cucumber-preprocessor/steps'; |
| 2 | +import { |
| 3 | + devNavigationMenuPO, |
| 4 | + quickSearchAddPO, |
| 5 | + quickStartCard, |
| 6 | + quickStartLeaveModalPO, |
| 7 | + quickStartSidebarPO, |
| 8 | +} from '../../pageObjects'; |
| 9 | +import { app } from '../../pages'; |
| 10 | + |
| 11 | +Given('Build with guided documentation card is present in Add page', () => { |
| 12 | + cy.byTestID('card quick-start').should('be.visible'); |
| 13 | +}); |
| 14 | + |
| 15 | +When('user click on Add to project icon', () => { |
| 16 | + cy.get(quickSearchAddPO.quickSearchButton).click(); |
| 17 | +}); |
| 18 | + |
| 19 | +When('user clicks on Start button from the quick search result', () => { |
| 20 | + cy.get(quickSearchAddPO.quickSearchCreateButton).click(); |
| 21 | +}); |
| 22 | + |
| 23 | +When('user types {string} in input box', (tourName: string) => { |
| 24 | + cy.get(quickSearchAddPO.quickSearchInput).type(tourName); |
| 25 | +}); |
| 26 | + |
| 27 | +When( |
| 28 | + 'user see the tour will start with link to four steps present as a sidepane with close button', |
| 29 | + () => { |
| 30 | + cy.get(quickStartSidebarPO.quickStartSidebar).should('be.visible'); |
| 31 | + cy.get('[class*="quick-start-task-header__title"]').then(($elements) => { |
| 32 | + return $elements.length === 3; |
| 33 | + }); |
| 34 | + }, |
| 35 | +); |
| 36 | + |
| 37 | +When( |
| 38 | + 'user clicks on the {string} link on the card to see the tour will start with link to four steps present as a sidepane with close button', |
| 39 | + (tourName: string) => { |
| 40 | + cy.get(quickStartCard(tourName)).click(); |
| 41 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(tourName); |
| 42 | + cy.get('[class*="quick-start-task-header__title"]').then(($elements) => { |
| 43 | + return $elements.length === 4; |
| 44 | + }); |
| 45 | + cy.get(quickStartSidebarPO.closePanel).should('be.visible'); |
| 46 | + }, |
| 47 | +); |
| 48 | + |
| 49 | +When( |
| 50 | + 'user clicks on the "Start" tour option to see {string} step to install Red Hat Developer Hub', |
| 51 | + (stepName: string) => { |
| 52 | + cy.get(quickStartSidebarPO.startButton).click(); |
| 53 | + cy.get(quickStartSidebarPO.quickStartSidebar).get('h3').contains(stepName); |
| 54 | + cy.byLegacyTestID('quick-start-task-subtitle').contains('1 of 4'); |
| 55 | + }, |
| 56 | +); |
| 57 | + |
| 58 | +When('user clicks on next button twice', () => { |
| 59 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 60 | + app.waitForLoad(); |
| 61 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 62 | +}); |
| 63 | + |
| 64 | +When('user clicks on next button', () => { |
| 65 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 66 | +}); |
| 67 | + |
| 68 | +When( |
| 69 | + 'user selects Yes option for alert titled {string} asking to {string}', |
| 70 | + (alert: string, message: string) => { |
| 71 | + cy.byTestID('quickstart drawer').contains(alert); |
| 72 | + cy.byTestID('quickstart drawer').contains(message); |
| 73 | + cy.get(quickStartSidebarPO.yesOptionCheckInput).click(); |
| 74 | + }, |
| 75 | +); |
| 76 | + |
| 77 | +When('user selects Yes option on alert titled {string}', (alert: string) => { |
| 78 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(alert); |
| 79 | + cy.get(quickStartSidebarPO.yesOptionCheckInput).click(); |
| 80 | +}); |
| 81 | + |
| 82 | +When( |
| 83 | + 'user clicks on next to see {string} step started for upgrading developer installation', |
| 84 | + (stepName: string) => { |
| 85 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 86 | + cy.get(quickStartSidebarPO.quickStartSidebar).get('h3').contains(stepName); |
| 87 | + }, |
| 88 | +); |
| 89 | + |
| 90 | +When( |
| 91 | + 'user clicks on next to see {string} optional step to modify developer hub instance URL', |
| 92 | + (stepName: string) => { |
| 93 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 94 | + cy.get(quickStartSidebarPO.quickStartSidebar).get('h3').contains(stepName); |
| 95 | + }, |
| 96 | +); |
| 97 | + |
| 98 | +When( |
| 99 | + 'user clicks on next to see {string} optional step to add developer hub to Openshift Console menu', |
| 100 | + (stepName: string) => { |
| 101 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 102 | + cy.get(quickStartSidebarPO.quickStartSidebar).get('h3').contains(stepName); |
| 103 | + }, |
| 104 | +); |
| 105 | + |
| 106 | +When('user clicks on next to see next step {string} started', (stepName: string) => { |
| 107 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 108 | + cy.get(quickStartSidebarPO.quickStartSidebar).get('h3').contains(stepName); |
| 109 | +}); |
| 110 | + |
| 111 | +When('user sees the message saying {string}', (message: string) => { |
| 112 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(message); |
| 113 | +}); |
| 114 | + |
| 115 | +When('user sees "Close", "Back" and "Restart"', () => { |
| 116 | + cy.get(quickStartSidebarPO.closePanel).should('be.visible'); |
| 117 | + cy.get(quickStartSidebarPO.backButton).should('be.visible'); |
| 118 | + cy.get(quickStartSidebarPO.restartSideNoteAction).should('be.visible'); |
| 119 | +}); |
| 120 | + |
| 121 | +When('user clicks on the link {string} on the card', (link: string) => { |
| 122 | + cy.byTestID('item all-quick-starts').contains(link).click(); |
| 123 | +}); |
| 124 | + |
| 125 | +When( |
| 126 | + 'user sees Complete label marked on {string} card after clicking on "close" button to close the sidepane', |
| 127 | + (tourName: string) => { |
| 128 | + cy.get(quickStartSidebarPO.closePanel).click(); |
| 129 | + cy.get(quickStartCard(tourName)).byTestID('status').contains('Complete'); |
| 130 | + }, |
| 131 | +); |
| 132 | + |
| 133 | +When('user clicks on the link {string} on the card', (linkString: string) => { |
| 134 | + cy.byTestID('item all-quick-starts').contains(linkString).click(); |
| 135 | +}); |
| 136 | + |
| 137 | +Given('user is at Quick Starts catalog page', () => { |
| 138 | + cy.get(devNavigationMenuPO.add).click(); |
| 139 | + cy.byTestID('item all-quick-starts').click(); |
| 140 | +}); |
| 141 | + |
| 142 | +When('user clicks on the Start tour option to see {string} step is started', (stepName: string) => { |
| 143 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(stepName); |
| 144 | + cy.get(quickStartSidebarPO.quickStartSidebar).byTestID('Start button').click(); |
| 145 | +}); |
| 146 | + |
| 147 | +When('user clicks on the {string} card', (tourName: string) => { |
| 148 | + cy.reload(); |
| 149 | + cy.get(quickStartCard(tourName)).click('topRight'); |
| 150 | +}); |
| 151 | + |
| 152 | +When( |
| 153 | + 'user selects No option on alert appears "Check your work" asking to verify that your application was successfully created', |
| 154 | + () => { |
| 155 | + cy.get(quickStartSidebarPO.noOptionCheckInput).click(); |
| 156 | + }, |
| 157 | +); |
| 158 | + |
| 159 | +Then('user sees that the alert is saying {string}', (alert: string) => { |
| 160 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(alert); |
| 161 | +}); |
| 162 | + |
| 163 | +When('user clicks "close" button to close the sidepane back to tour page', () => { |
| 164 | + cy.byTestID('Close button').click(); |
| 165 | +}); |
| 166 | + |
| 167 | +When('user sees alert titled {string} asking to {string}', (alert: string, message: string) => { |
| 168 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(alert); |
| 169 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(message); |
| 170 | +}); |
| 171 | + |
| 172 | +When('user clicks back button to go back to previous step', () => { |
| 173 | + cy.get(quickStartSidebarPO.backButton).click(); |
| 174 | +}); |
| 175 | + |
| 176 | +When('user clicks on Close button', () => { |
| 177 | + cy.byTestID('Close button').click(); |
| 178 | +}); |
| 179 | + |
| 180 | +Then('user sees Complete label marked on {string} card', (tourName: string) => { |
| 181 | + cy.get(quickStartCard(tourName)).byTestID('status').contains('Complete'); |
| 182 | +}); |
| 183 | + |
| 184 | +When('user closes the close button', () => { |
| 185 | + cy.get(quickStartSidebarPO.closePanel).click(); |
| 186 | +}); |
| 187 | + |
| 188 | +When('user clicks on Leave button on modal {string}', (modelString: string) => { |
| 189 | + cy.get('[role="dialog"]').contains(modelString); |
| 190 | + cy.get(quickStartLeaveModalPO.leaveButton).click(); |
| 191 | +}); |
| 192 | + |
| 193 | +Then( |
| 194 | + 'user sees that the tour has started again with Yes option selected for the alert titled {string} in step 1', |
| 195 | + (alert: string) => { |
| 196 | + cy.byLegacyTestID('quick-start-task-subtitle').contains('1 of 4'); |
| 197 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(alert); |
| 198 | + cy.get(quickStartSidebarPO.yesOptionCheckInput).should('be.checked'); |
| 199 | + }, |
| 200 | +); |
| 201 | + |
| 202 | +When( |
| 203 | + 'user clicks on third step {string} from the link to four steps present in the card', |
| 204 | + (stepName: string) => { |
| 205 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains('h3', stepName).click(); |
| 206 | + }, |
| 207 | +); |
| 208 | + |
| 209 | +When('user clicks on second step {string}', (stepName: string) => { |
| 210 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains('h3', stepName).click(); |
| 211 | +}); |
| 212 | + |
| 213 | +When('user clicks on first step {string} step', (stepName: string) => { |
| 214 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains('h3', stepName).click(); |
| 215 | +}); |
| 216 | + |
| 217 | +When( |
| 218 | + 'user clicks on next to see step {string} with {string} alert', |
| 219 | + (stepName: string, alert: string) => { |
| 220 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 221 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains('h3', stepName); |
| 222 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(alert); |
| 223 | + }, |
| 224 | +); |
| 225 | + |
| 226 | +When( |
| 227 | + 'user clicks on next to see step {string} with {string} alert', |
| 228 | + (stepName: string, alert: string) => { |
| 229 | + cy.get(quickStartSidebarPO.nextButton).click(); |
| 230 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains('h3', stepName); |
| 231 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(alert); |
| 232 | + }, |
| 233 | +); |
| 234 | + |
| 235 | +When('user selects Yes option in alert titled {string}', (title: string) => { |
| 236 | + cy.get(quickStartSidebarPO.quickStartSidebar).contains(title); |
| 237 | +}); |
0 commit comments