|
| 1 | +/* |
| 2 | +Copyright 2022 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +/// <reference types='cypress' /> |
| 18 | + |
| 19 | +export function startCrossSigning(userId: string): string { |
| 20 | + if (userId) { |
| 21 | + cy.get(".mx_RightPanel_roomSummaryButton").click(); |
| 22 | + cy.get(".mx_RoomSummaryCard_icon_people").click(); |
| 23 | + cy.get(".mx_MemberList_query").type(userId); |
| 24 | + cy.get(".mx_MemberList_wrapper .mx_EntityTile").click(); |
| 25 | + cy.get(".mx_UserInfo_verifyButton").click(); |
| 26 | + cy.get(".mx_UserInfo_startVerification").click(); |
| 27 | + } else { |
| 28 | + cy.gotoAllSettings(); |
| 29 | + cy.get("[data-testid='settings-tab-USER_SECURITY_TAB']").click(); |
| 30 | + cy.contains("Verify").first().click(); |
| 31 | + cy.contains("Verify with another device").click(); |
| 32 | + } |
| 33 | + return 'started_crosssign'; |
| 34 | +} |
| 35 | + |
| 36 | +export function acceptCrossSigningRequest(): string { |
| 37 | + // Can we please tag some buttons :) |
| 38 | + // Click 'Verify' when it comes up |
| 39 | + cy.get('.mx_Toast_buttons > .mx_AccessibleButton_kind_primary').click(); |
| 40 | + return 'accepted_crosssign'; |
| 41 | +} |
| 42 | + |
| 43 | +export function verifyCrossSigningEmoji(): string { |
| 44 | + // Click to move to emoji verification |
| 45 | + cy.wait(1000).then(() => { |
| 46 | + // Choose whichever exists |
| 47 | + Cypress.$(".mx_VerificationPanel_verifyByEmojiButton")?.trigger("click"); |
| 48 | + Cypress.$('.mx_VerificationPanel_QRPhase_startOption > .mx_AccessibleButton')?.trigger("click"); |
| 49 | + }); |
| 50 | + cy.contains("They match").click(); |
| 51 | + cy.contains("Got it").click(); |
| 52 | + return 'verified_crosssign'; |
| 53 | +} |
| 54 | + |
| 55 | +export function verifyDeviceIsTrusted(): string { |
| 56 | + cy.gotoAllSettings(); |
| 57 | + cy.get("[data-testid='settings-tab-USER_SECURITY_TAB']").click(); |
| 58 | + // For now, we only care if there are any verified devices |
| 59 | + // Eventually, we'd want to check if a device is verified by name |
| 60 | + cy.contains(/^Verified devices$/); |
| 61 | + cy.get(".mx_DevicesPanel_device").children(); |
| 62 | + return "verified"; |
| 63 | +} |
| 64 | + |
| 65 | +export function enableKeyBackup(passphrase: string): string { |
| 66 | + cy.gotoAllSettings(); |
| 67 | + cy.get("[data-testid='settings-tab-USER_SECURITY_TAB']").click(); |
| 68 | + cy.get(".mx_SecureBackupPanel_buttonRow").contains("Set up").click(); |
| 69 | + cy.get(".mx_CreateSecretStorageDialog_optionIcon_securePhrase").click(); |
| 70 | + cy.get(".mx_CreateSecretStorageDialog [data-testid='dialog-primary-button']").click(); |
| 71 | + cy.get(".mx_CreateSecretStorageDialog_passPhraseContainer input[type='password']").type(passphrase); |
| 72 | + cy.get("[data-testid='dialog-primary-button']").click(); |
| 73 | + // confirm the password again |
| 74 | + cy.get(".mx_CreateSecretStorageDialog_passPhraseContainer input[type='password']").type(passphrase); |
| 75 | + cy.get("[data-testid='dialog-primary-button']").click(); |
| 76 | + // Continue to next screen |
| 77 | + cy.get("[data-testid='dialog-primary-button']").click(); |
| 78 | + // Classic flakiness fix |
| 79 | + cy.wait(500); |
| 80 | + cy.get(".mx_CreateSecretStorageDialog").contains("Continue").click(); |
| 81 | + return "key_backup_enabled"; |
| 82 | +} |
| 83 | + |
| 84 | +export function enableDehydratedDevice(passphrase: string): string { |
| 85 | + cy.gotoAllSettings(); |
| 86 | + cy.get("[data-testid='settings-tab-USER_LABS_TAB']").click(); |
| 87 | + cy.get("[aria-label='Offline encrypted messaging using dehydrated devices']").click(); |
| 88 | + cy.get(".mx_Dialog_cancelButton").click(); |
| 89 | + enableKeyBackup(passphrase); |
| 90 | + return "enabled_dehydrated_device"; |
| 91 | +} |
0 commit comments