66 */
77
88import { type GeneratedSecretStorageKey } from "matrix-js-sdk/src/crypto-api" ;
9+ import { assertNoToasts , getToast , rejectToast } from "@element-hq/element-web-playwright-common" ;
910
1011import { test , expect } from "../../element-web-test" ;
1112import { createBot , deleteCachedSecrets , disableKeyBackup , logIntoElement , logIntoElementAndVerify } from "./utils" ;
@@ -63,7 +64,7 @@ test.describe("Key storage out of sync toast", () => {
6364test . describe ( "'Turn on key storage' toast" , ( ) => {
6465 let botClient : Bot | undefined ;
6566
66- test . beforeEach ( async ( { page, homeserver, credentials, toasts } ) => {
67+ test . beforeEach ( async ( { page, homeserver, credentials } ) => {
6768 // Set up all crypto stuff. Key storage defaults to on.
6869
6970 const res = await createBot ( page , homeserver , credentials ) ;
@@ -81,13 +82,13 @@ test.describe("'Turn on key storage' toast", () => {
8182 await page . getByRole ( "textbox" , { name : "Name" } ) . fill ( "Test room" ) ;
8283 await page . getByRole ( "button" , { name : "Create room" } ) . click ( ) ;
8384
84- await toasts . rejectToast ( "Notifications" ) ;
85+ await rejectToast ( page , "Notifications" ) ;
8586 } ) ;
8687
87- test ( "should not show toast if key storage is on" , async ( { page, toasts } ) => {
88+ test ( "should not show toast if key storage is on" , async ( { page } ) => {
8889 // Given the default situation after signing in
8990 // Then no toast is shown (because key storage is on)
90- await toasts . assertNoToasts ( ) ;
91+ await assertNoToasts ( page ) ;
9192
9293 // When we reload
9394 await page . reload ( ) ;
@@ -96,15 +97,15 @@ test.describe("'Turn on key storage' toast", () => {
9697 await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
9798
9899 // Then still no toast is shown
99- await toasts . assertNoToasts ( ) ;
100+ await assertNoToasts ( page ) ;
100101 } ) ;
101102
102- test ( "should not show toast if key storage is off because we turned it off" , async ( { app, page, toasts } ) => {
103+ test ( "should not show toast if key storage is off because we turned it off" , async ( { app, page } ) => {
103104 // Given the backup is disabled because we disabled it
104105 await disableKeyBackup ( app ) ;
105106
106107 // Then no toast is shown
107- await toasts . assertNoToasts ( ) ;
108+ await assertNoToasts ( page ) ;
108109
109110 // When we reload
110111 await page . reload ( ) ;
@@ -113,10 +114,10 @@ test.describe("'Turn on key storage' toast", () => {
113114 await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
114115
115116 // Then still no toast is shown
116- await toasts . assertNoToasts ( ) ;
117+ await assertNoToasts ( page ) ;
117118 } ) ;
118119
119- test ( "should show toast if key storage is off but account data is missing" , async ( { app, page, toasts } ) => {
120+ test ( "should show toast if key storage is off but account data is missing" , async ( { app, page } ) => {
120121 // Given the backup is disabled but we didn't set account data saying that is expected
121122 await disableKeyBackup ( app ) ;
122123 await botClient . setAccountData ( "m.org.matrix.custom.backup_disabled" , { disabled : false } ) ;
@@ -128,7 +129,7 @@ test.describe("'Turn on key storage' toast", () => {
128129 await page . reload ( ) ;
129130
130131 // Then the toast is displayed
131- let toast = await toasts . getToast ( "Turn on key storage" ) ;
132+ let toast = await getToast ( page , "Turn on key storage" ) ;
132133
133134 // And when we click "Continue"
134135 await toast . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
@@ -140,7 +141,7 @@ test.describe("'Turn on key storage' toast", () => {
140141 await page . getByRole ( "button" , { name : "Close dialog" } ) . click ( ) ;
141142
142143 // Then we see the toast again
143- toast = await toasts . getToast ( "Turn on key storage" ) ;
144+ toast = await getToast ( page , "Turn on key storage" ) ;
144145
145146 // And when we click "Dismiss"
146147 await toast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
@@ -154,7 +155,7 @@ test.describe("'Turn on key storage' toast", () => {
154155 await page . getByTestId ( "dialog-background" ) . click ( { force : true , position : { x : 10 , y : 10 } } ) ;
155156
156157 // Then we see the toast again
157- toast = await toasts . getToast ( "Turn on key storage" ) ;
158+ toast = await getToast ( page , "Turn on key storage" ) ;
158159
159160 // And when we click Dismiss and then "Go to Settings"
160161 await toast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
@@ -165,12 +166,12 @@ test.describe("'Turn on key storage' toast", () => {
165166
166167 // And when we close that, see the toast, click Dismiss, and Yes, Dismiss
167168 await page . getByRole ( "button" , { name : "Close dialog" } ) . click ( ) ;
168- toast = await toasts . getToast ( "Turn on key storage" ) ;
169+ toast = await getToast ( page , "Turn on key storage" ) ;
169170 await toast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
170171 await page . getByRole ( "button" , { name : "Yes, dismiss" } ) . click ( ) ;
171172
172173 // Then the toast is gone
173- await toasts . assertNoToasts ( ) ;
174+ await assertNoToasts ( page ) ;
174175 } ) ;
175176} ) ;
176177
0 commit comments