Changeset View
Changeset View
Standalone View
Standalone View
src/tests/quick-tests/tst_CreateRoomPage.qml
| Show All 26 Lines | property var createRoom: mockHelper.promise([ | ||||
| 'name', | 'name', | ||||
| 'alias', | 'alias', | ||||
| 'invites', | 'invites', | ||||
| 'isDirect', | 'isDirect', | ||||
| 'allowFederate', | 'allowFederate', | ||||
| 'topic', | 'topic', | ||||
| 'powerLevelContentOverride', | 'powerLevelContentOverride', | ||||
| 'preset', | 'preset', | ||||
| 'encrypted', | |||||
| ]) | ]) | ||||
| } | } | ||||
| property var sdkVars: ({}) | property var sdkVars: ({}) | ||||
| Kazv.CreateRoomPage { | Kazv.CreateRoomPage { | ||||
| anchors.fill: parent | anchors.fill: parent | ||||
| id: createRoomPage | id: createRoomPage | ||||
| } | } | ||||
| TestCase { | TestCase { | ||||
| id: createRoomPageTest | id: createRoomPageTest | ||||
| name: 'CreateRoomPageTest' | name: 'CreateRoomPageTest' | ||||
| when: windowShown | when: windowShown | ||||
| function initTestCase() { | function initTestCase() { | ||||
| if (MK.KazvUtil.kfQtMajorVersion === 6) { | if (MK.KazvUtil.kfQtMajorVersion === 6) { | ||||
| createRoomPage.contentItem.clip = false; | createRoomPage.contentItem.clip = false; | ||||
| } | } | ||||
| } | } | ||||
| function cleanup() { | function cleanup() { | ||||
| mockHelper.clearAll(); | mockHelper.clearAll(); | ||||
| createRoomPage.inviteUserIds = []; | createRoomPage.inviteUserIds = []; | ||||
| createRoomPage.creatingRoom = false; | createRoomPage.creatingRoom = false; | ||||
| createRoomPage.encryptedChangedOnce = false; | |||||
| } | } | ||||
| function test_createRoomPublic() { | function test_createRoomPublic() { | ||||
| mouseClick(findChild(createRoomPage, 'typePublicRadio')); | mouseClick(findChild(createRoomPage, 'typePublicRadio')); | ||||
| findChild(createRoomPage, 'roomNameInput').text = 'some name'; | findChild(createRoomPage, 'roomNameInput').text = 'some name'; | ||||
| findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | ||||
| findChild(createRoomPage, 'roomTopicInput').text = 'some topic'; | findChild(createRoomPage, 'roomTopicInput').text = 'some topic'; | ||||
| const button = findChild(createRoomPage, 'createRoomButton'); | const button = findChild(createRoomPage, 'createRoomButton'); | ||||
| verify(button.enabled); | verify(button.enabled); | ||||
| mouseClick(button); | mouseClick(button); | ||||
| tryVerify(() => item.matrixSdk.createRoom.calledTimes() === 1, 1000); | tryVerify(() => item.matrixSdk.createRoom.calledTimes() === 1, 1000); | ||||
| verify(Helpers.deepEqual(item.matrixSdk.createRoom.lastArgs(), { | verify(Helpers.deepEqual(item.matrixSdk.createRoom.lastArgs(), { | ||||
| isPrivate: false, | isPrivate: false, | ||||
| name: 'some name', | name: 'some name', | ||||
| alias: 'alias', | alias: 'alias', | ||||
| topic: 'some topic', | topic: 'some topic', | ||||
| invites: [], | invites: [], | ||||
| isDirect: false, | isDirect: false, | ||||
| allowFederate: true, | allowFederate: true, | ||||
| powerLevelContentOverride: {}, | powerLevelContentOverride: {}, | ||||
| preset: MK.MatrixSdk.PublicChat, | preset: MK.MatrixSdk.PublicChat, | ||||
| encrypted: false, | |||||
| })); | })); | ||||
| } | } | ||||
| function test_createRoomPrivate() { | function test_createRoomPrivate() { | ||||
| mouseClick(findChild(createRoomPage, 'typePrivateRadio')); | mouseClick(findChild(createRoomPage, 'typePrivateRadio')); | ||||
| findChild(createRoomPage, 'roomNameInput').text = 'some name'; | findChild(createRoomPage, 'roomNameInput').text = 'some name'; | ||||
| findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | ||||
| findChild(createRoomPage, 'roomTopicInput').text = 'some topic'; | findChild(createRoomPage, 'roomTopicInput').text = 'some topic'; | ||||
| const button = findChild(createRoomPage, 'createRoomButton'); | const button = findChild(createRoomPage, 'createRoomButton'); | ||||
| verify(button.enabled); | verify(button.enabled); | ||||
| mouseClick(button); | mouseClick(button); | ||||
| tryVerify(() => item.matrixSdk.createRoom.calledTimes() === 1, 1000); | tryVerify(() => item.matrixSdk.createRoom.calledTimes() === 1, 1000); | ||||
| verify(Helpers.deepEqual(item.matrixSdk.createRoom.lastArgs(), { | verify(Helpers.deepEqual(item.matrixSdk.createRoom.lastArgs(), { | ||||
| isPrivate: true, | isPrivate: true, | ||||
| name: 'some name', | name: 'some name', | ||||
| alias: 'alias', | alias: 'alias', | ||||
| topic: 'some topic', | topic: 'some topic', | ||||
| invites: [], | invites: [], | ||||
| isDirect: false, | isDirect: false, | ||||
| allowFederate: true, | allowFederate: true, | ||||
| powerLevelContentOverride: {}, | powerLevelContentOverride: {}, | ||||
| preset: MK.MatrixSdk.PrivateChat, | preset: MK.MatrixSdk.PrivateChat, | ||||
| encrypted: true, | |||||
| })); | })); | ||||
| } | } | ||||
| function test_createRoomDirect() { | function test_createRoomDirect() { | ||||
| mouseClick(findChild(createRoomPage, 'typeDirectRadio')); | mouseClick(findChild(createRoomPage, 'typeDirectRadio')); | ||||
| findChild(createRoomPage, 'roomNameInput').text = 'some name'; | findChild(createRoomPage, 'roomNameInput').text = 'some name'; | ||||
| findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | ||||
| findChild(createRoomPage, 'roomTopicInput').text = 'some topic'; | findChild(createRoomPage, 'roomTopicInput').text = 'some topic'; | ||||
| const button = findChild(createRoomPage, 'createRoomButton'); | const button = findChild(createRoomPage, 'createRoomButton'); | ||||
| verify(button.enabled); | verify(button.enabled); | ||||
| mouseClick(button); | mouseClick(button); | ||||
| tryVerify(() => item.matrixSdk.createRoom.calledTimes() === 1, 1000); | tryVerify(() => item.matrixSdk.createRoom.calledTimes() === 1, 1000); | ||||
| verify(Helpers.deepEqual(item.matrixSdk.createRoom.lastArgs(), { | verify(Helpers.deepEqual(item.matrixSdk.createRoom.lastArgs(), { | ||||
| isPrivate: true, | isPrivate: true, | ||||
| name: 'some name', | name: 'some name', | ||||
| alias: 'alias', | alias: 'alias', | ||||
| topic: 'some topic', | topic: 'some topic', | ||||
| invites: [], | invites: [], | ||||
| isDirect: false, | isDirect: false, | ||||
| allowFederate: true, | allowFederate: true, | ||||
| powerLevelContentOverride: {}, | powerLevelContentOverride: {}, | ||||
| preset: MK.MatrixSdk.TrustedPrivateChat, | preset: MK.MatrixSdk.TrustedPrivateChat, | ||||
| encrypted: true, | |||||
| })); | })); | ||||
| } | } | ||||
| function test_createRoomDirectInviteOne() { | function test_createRoomDirectInviteOne() { | ||||
| mouseClick(findChild(createRoomPage, 'typeDirectRadio')); | mouseClick(findChild(createRoomPage, 'typeDirectRadio')); | ||||
| findChild(createRoomPage, 'roomNameInput').text = 'some name'; | findChild(createRoomPage, 'roomNameInput').text = 'some name'; | ||||
| findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | ||||
| Show All 15 Lines | function test_createRoomDirectInviteOne() { | ||||
| name: 'some name', | name: 'some name', | ||||
| alias: 'alias', | alias: 'alias', | ||||
| topic: 'some topic', | topic: 'some topic', | ||||
| invites: ['@foo:example.org'], | invites: ['@foo:example.org'], | ||||
| isDirect: true, | isDirect: true, | ||||
| allowFederate: true, | allowFederate: true, | ||||
| powerLevelContentOverride: {}, | powerLevelContentOverride: {}, | ||||
| preset: MK.MatrixSdk.TrustedPrivateChat, | preset: MK.MatrixSdk.TrustedPrivateChat, | ||||
| encrypted: true, | |||||
| })); | })); | ||||
| } | } | ||||
| function test_createRoomDirectInviteMultiple() { | function test_createRoomDirectInviteMultiple() { | ||||
| mouseClick(findChild(createRoomPage, 'typeDirectRadio')); | mouseClick(findChild(createRoomPage, 'typeDirectRadio')); | ||||
| findChild(createRoomPage, 'roomNameInput').text = 'some name'; | findChild(createRoomPage, 'roomNameInput').text = 'some name'; | ||||
| findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | ||||
| Show All 19 Lines | function test_createRoomDirectInviteMultiple() { | ||||
| name: 'some name', | name: 'some name', | ||||
| alias: 'alias', | alias: 'alias', | ||||
| topic: 'some topic', | topic: 'some topic', | ||||
| invites: ['@foo:example.org', '@bar:example.org'], | invites: ['@foo:example.org', '@bar:example.org'], | ||||
| isDirect: false, | isDirect: false, | ||||
| allowFederate: true, | allowFederate: true, | ||||
| powerLevelContentOverride: {}, | powerLevelContentOverride: {}, | ||||
| preset: MK.MatrixSdk.TrustedPrivateChat, | preset: MK.MatrixSdk.TrustedPrivateChat, | ||||
| encrypted: true, | |||||
| })); | })); | ||||
| } | } | ||||
| function test_invite() { | function test_invite() { | ||||
| mouseClick(findChild(createRoomPage, 'typePublicRadio')); | mouseClick(findChild(createRoomPage, 'typePublicRadio')); | ||||
| findChild(createRoomPage, 'roomNameInput').text = 'some name'; | findChild(createRoomPage, 'roomNameInput').text = 'some name'; | ||||
| findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | findChild(createRoomPage, 'roomAliasInput').text = 'alias'; | ||||
| Show All 35 Lines | function test_invite() { | ||||
| name: 'some name', | name: 'some name', | ||||
| alias: 'alias', | alias: 'alias', | ||||
| topic: 'some topic', | topic: 'some topic', | ||||
| invites: ['@foo:example.org', '@baz:example.org'], | invites: ['@foo:example.org', '@baz:example.org'], | ||||
| isDirect: false, | isDirect: false, | ||||
| allowFederate: true, | allowFederate: true, | ||||
| powerLevelContentOverride: {}, | powerLevelContentOverride: {}, | ||||
| preset: MK.MatrixSdk.PublicChat, | preset: MK.MatrixSdk.PublicChat, | ||||
| encrypted: false, | |||||
| })); | })); | ||||
| } | |||||
| function test_encryptedCheckBox() { | |||||
| const publicRadio = findChild(createRoomPage, 'typePublicRadio'); | |||||
| const privateRadio = findChild(createRoomPage, 'typePrivateRadio'); | |||||
| const directRadio = findChild(createRoomPage, 'typeDirectRadio') | |||||
| const encryptedInput = findChild(createRoomPage, 'encryptedInput'); | |||||
| mouseClick(publicRadio); | |||||
| verify(!encryptedInput.checked); | |||||
| mouseClick(privateRadio); | |||||
| verify(encryptedInput.checked); | |||||
| mouseClick(directRadio); | |||||
| verify(encryptedInput.checked); | |||||
| mouseClick(encryptedInput); | |||||
| verify(!encryptedInput.checked); | |||||
| mouseClick(publicRadio); | |||||
| verify(!encryptedInput.checked); | |||||
| mouseClick(directRadio); | |||||
| verify(!encryptedInput.checked); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||