66 */
77
88import { type GeneratedSecretStorageKey } from "matrix-js-sdk/src/crypto-api" ;
9+ import { assertNoToasts , getToast , rejectToast } from "@element-hq/element-web-playwright-common/src/utils/toasts" ;
910
1011import { test , expect } from "../../element-web-test" ;
1112import { createBot , deleteCachedSecrets , disableKeyBackup , logIntoElement , logIntoElementAndVerify } from "./utils" ;
@@ -72,7 +73,7 @@ test.describe("Key storage out of sync toast", () => {
7273test . describe ( "'Turn on key storage' toast" , ( ) => {
7374 let botClient : Bot | undefined ;
7475
75- test . beforeEach ( async ( { page, homeserver, credentials, toasts } ) => {
76+ test . beforeEach ( async ( { page, homeserver, credentials } ) => {
7677 // Set up all crypto stuff. Key storage defaults to on.
7778
7879 const res = await createBot ( page , homeserver , credentials ) ;
@@ -90,13 +91,13 @@ test.describe("'Turn on key storage' toast", () => {
9091 await page . getByRole ( "textbox" , { name : "Name" } ) . fill ( "Test room" ) ;
9192 await page . getByRole ( "button" , { name : "Create room" } ) . click ( ) ;
9293
93- await toasts . rejectToast ( "Notifications" ) ;
94+ await rejectToast ( page , "Notifications" ) ;
9495 } ) ;
9596
96- test ( "should not show toast if key storage is on" , async ( { page, toasts } ) => {
97+ test ( "should not show toast if key storage is on" , async ( { page } ) => {
9798 // Given the default situation after signing in
9899 // Then no toast is shown (because key storage is on)
99- await toasts . assertNoToasts ( ) ;
100+ await assertNoToasts ( page ) ;
100101
101102 // When we reload
102103 await page . reload ( ) ;
@@ -105,15 +106,15 @@ test.describe("'Turn on key storage' toast", () => {
105106 await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
106107
107108 // Then still no toast is shown
108- await toasts . assertNoToasts ( ) ;
109+ await assertNoToasts ( page ) ;
109110 } ) ;
110111
111- test ( "should not show toast if key storage is off because we turned it off" , async ( { app, page, toasts } ) => {
112+ test ( "should not show toast if key storage is off because we turned it off" , async ( { app, page } ) => {
112113 // Given the backup is disabled because we disabled it
113114 await disableKeyBackup ( app ) ;
114115
115116 // Then no toast is shown
116- await toasts . assertNoToasts ( ) ;
117+ await assertNoToasts ( page ) ;
117118
118119 // When we reload
119120 await page . reload ( ) ;
@@ -122,10 +123,10 @@ test.describe("'Turn on key storage' toast", () => {
122123 await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
123124
124125 // Then still no toast is shown
125- await toasts . assertNoToasts ( ) ;
126+ await assertNoToasts ( page ) ;
126127 } ) ;
127128
128- test ( "should show toast if key storage is off but account data is missing" , async ( { app, page, toasts } ) => {
129+ test ( "should show toast if key storage is off but account data is missing" , async ( { app, page } ) => {
129130 // Given the backup is disabled but we didn't set account data saying that is expected
130131 await disableKeyBackup ( app ) ;
131132 await botClient . setAccountData ( "m.org.matrix.custom.backup_disabled" , { disabled : false } ) ;
@@ -137,7 +138,7 @@ test.describe("'Turn on key storage' toast", () => {
137138 await page . reload ( ) ;
138139
139140 // Then the toast is displayed
140- let toast = await toasts . getToast ( "Turn on key storage" ) ;
141+ let toast = await getToast ( page , "Turn on key storage" ) ;
141142
142143 // And when we click "Continue"
143144 await toast . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
@@ -149,7 +150,7 @@ test.describe("'Turn on key storage' toast", () => {
149150 await page . getByRole ( "button" , { name : "Close dialog" } ) . click ( ) ;
150151
151152 // Then we see the toast again
152- toast = await toasts . getToast ( "Turn on key storage" ) ;
153+ toast = await getToast ( page , "Turn on key storage" ) ;
153154
154155 // And when we click "Dismiss"
155156 await toast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
@@ -163,7 +164,7 @@ test.describe("'Turn on key storage' toast", () => {
163164 await page . getByTestId ( "dialog-background" ) . click ( { force : true , position : { x : 10 , y : 10 } } ) ;
164165
165166 // Then we see the toast again
166- toast = await toasts . getToast ( "Turn on key storage" ) ;
167+ toast = await getToast ( page , "Turn on key storage" ) ;
167168
168169 // And when we click Dismiss and then "Go to Settings"
169170 await toast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
@@ -174,12 +175,12 @@ test.describe("'Turn on key storage' toast", () => {
174175
175176 // And when we close that, see the toast, click Dismiss, and Yes, Dismiss
176177 await page . getByRole ( "button" , { name : "Close dialog" } ) . click ( ) ;
177- toast = await toasts . getToast ( "Turn on key storage" ) ;
178+ toast = await getToast ( page , "Turn on key storage" ) ;
178179 await toast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
179180 await page . getByRole ( "button" , { name : "Yes, dismiss" } ) . click ( ) ;
180181
181182 // Then the toast is gone
182- await toasts . assertNoToasts ( ) ;
183+ await assertNoToasts ( page ) ;
183184 } ) ;
184185} ) ;
185186
0 commit comments