Skip to content

Commit e79fe68

Browse files
committed
console: Refactor set tutorial seen in cypress
1 parent da1f9f4 commit e79fe68

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

cypress/support/commands.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ Cypress.Commands.add('getAccessToken', callback => {
126126
callback(accessToken)
127127
})
128128

129+
Cypress.Commands.add('setAllTutorialSeen', user => {
130+
const tutorialNames = ['TUTORIAL_LIVE_DATA_SPLIT_VIEW']
131+
cy.task(
132+
'execSql',
133+
`UPDATE users SET console_preferences = '{"dashboard_layouts":{},"sort_by":{},"tutorials":{"seen":[${tutorialNames.map(name => `"${name}"`).join(',')}]}}'::jsonb::text::bytea WHERE primary_email_address = '${user.primary_email_address}';`,
134+
)
135+
})
136+
129137
// Helper function to create a new user programmatically.
130138
Cypress.Commands.add('createUser', user => {
131139
const baseUrl = Cypress.config('baseUrl')
@@ -147,13 +155,8 @@ Cypress.Commands.add('createUser', user => {
147155
})
148156
})
149157

150-
console.log('User created:', user)
151-
152-
cy.task(
153-
'execSql',
154-
`UPDATE users SET console_preferences = '{"dashboard_layouts":{},"sort_by":{},"tutorials":{"seen":["TUTORIAL_LIVE_DATA_SPLIT_VIEW"]}}'::jsonb::text::bytea WHERE primary_email_address = '${user.primary_email_address}';`,
155-
)
156-
158+
// Set all tutorials as seen.
159+
cy.setAllTutorialSeen(user)
157160
// Reset cookies and local storage to avoid csrf and session state inconsistencies within tests.
158161
cy.clearCookies()
159162
cy.clearLocalStorage()

0 commit comments

Comments
 (0)