e2e test toasts v2

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2020-05-27 13:10:28 +01:00
parent 7b6d49c416
commit d9552c7f5c
2 changed files with 12 additions and 12 deletions

View File

@ -14,10 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const {acceptToast} = require("../usecases/toasts"); const {acceptToast, rejectToast} = require("../usecases/toasts");
module.exports = async function toastScenarios(alice, bob) { module.exports = async function toastScenarios(alice, bob) {
console.log(" checking and clearing all toasts:"); console.log(" checking and clearing all toasts:");
alice.log.startGroup(`clears toasts`);
await acceptToast(alice, "Notifications");
await acceptToast(alice, "Help us improve Riot"); await acceptToast(alice, "Help us improve Riot");
await acceptToast(bob, "Help us improve Riot"); alice.log.endGroup();
bob.log.startGroup(`clears toasts`);
await rejectToast(bob, "Notifications");
await rejectToast(bob, "Help us improve Riot");
bob.log.endGroup();
}; };

View File

@ -23,21 +23,13 @@ async function assertToast(session, expectedTitle) {
} }
async function acceptToast(session, expectedTitle) { async function acceptToast(session, expectedTitle) {
const foundToast = await assertToast(session, expectedTitle); await assertToast(session, expectedTitle);
if (!foundToast) {
throw new Error("could not find expected toast");
}
const btn = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_primary'); const btn = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_primary');
await btn.click(); await btn.click();
} }
async function rejectToast(session, expectedTitle) { async function rejectToast(session, expectedTitle) {
const foundToast = await assertToast(session, expectedTitle); await assertToast(session, expectedTitle);
if (!foundToast) {
throw new Error("could not find expected toast");
}
const btn = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_danger'); const btn = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_danger');
await btn.click(); await btn.click();
} }