diff --git a/apps/mudita-center-e2e/src/helpers/entity-fixtures.ts b/apps/mudita-center-e2e/src/helpers/entity-fixtures.ts new file mode 100644 index 0000000000..78178e6ec8 --- /dev/null +++ b/apps/mudita-center-e2e/src/helpers/entity-fixtures.ts @@ -0,0 +1,998 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +import { EntityData } from "device/models" + +export const contactEntities: EntityData[] = [ + { + entityType: "contacts", + contactId: "425", + searchName: "Dr. Anna Nowak Jr.", + sortField: "NowakAnna", + firstName: "Anna", + lastName: "Nowak", + namePrefix: "Dr.", + middleName: "Maria", + nameSuffix: "Jr.", + phoneNumbers: [ + { + id: "2981", + phoneNumber: "+48123456789", + phoneType: "MOBILE", + }, + ], + emailAddresses: [ + { + id: "2982", + emailAddress: "anna.nowak@example.com", + emailType: "WORK", + }, + ], + company: "ABC Corp.", + department: "HR", + workTitle: "Manager", + address: { + streetAddress: "Main Street 12", + city: "Warsaw", + country: "Poland", + type: "WORK", + }, + website: "https://example.com", + notes: "VIP client", + starred: false, + displayName1: "Dr.", + displayName2: "Anna", + displayName3: "Nowak", + displayName4: "Jr.", + }, + { + entityType: "contacts", + contactId: "426", + searchName: "Ms. Emily Clark", + sortField: "ClarkEmily", + firstName: "Emily", + lastName: "Clark", + namePrefix: "Ms.", + middleName: "Rose", + phoneNumbers: [ + { + id: "2989", + phoneNumber: "+12123456789", + phoneType: "WORK", + }, + ], + emailAddresses: [ + { + id: "2990", + emailAddress: "emily.clark@startup.com", + emailType: "WORK", + }, + ], + company: "Innovatech", + department: "Marketing", + workTitle: "Marketing Director", + address: { + streetAddress: "456 Innovation Ave", + city: "San Francisco", + country: "USA", + type: "WORK", + }, + website: "https://emilyclark.me", + notes: "Lead of the marketing strategy team.", + starred: false, + displayName1: "Ms.", + displayName2: "Emily", + displayName3: "Clark", + }, + { + entityType: "contacts", + contactId: "427", + searchName: "Dr. Michael Johnson PhD", + sortField: "JohnsonMichael", + firstName: "Michael", + lastName: "Johnson", + namePrefix: "Dr.", + middleName: "David", + nameSuffix: "PhD", + phoneNumbers: [ + { + id: "2997", + phoneNumber: "+49876543210", + phoneType: "MOBILE", + }, + { + id: "2998", + phoneNumber: "+49871234567", + phoneType: "HOME", + }, + ], + emailAddresses: [ + { + id: "2999", + emailAddress: "michael.j@researchlab.com", + emailType: "WORK", + }, + ], + company: "Research Labs", + department: "R&D", + workTitle: "Chief Scientist", + address: { + streetAddress: "789 Science Blvd", + city: "Berlin", + country: "Germany", + type: "WORK", + }, + website: "https://michaeljohnsonphd.com", + notes: "Collaborating on AI research projects.", + starred: false, + displayName1: "Dr.", + displayName2: "Michael", + displayName3: "Johnson", + displayName4: "PhD", + }, + { + entityType: "contacts", + contactId: "428", + searchName: + "Long Display Name (last name is long) Anna Maria Katarzyna Nowak-Wielka-Zabłocka-Długosz-Ostrowska-Mickiewicz-Piękna-Sobieska-Kowalewska-Jagiellońska-Słowacka-Krzyżanowska-Kordecka-Kościuszkowska", + sortField: + "Anna Maria Katarzyna Nowak-Wielka-Zabłocka-Długosz-Ostrowska-Mickiewicz-Piękna-Sobieska-Kowalewska-Jagiellońska-Słowacka-Krzyżanowska-Kordecka-KościuszkowskaLong Display Name (last name is long)", + firstName: "Long Display Name (last name is long)", + lastName: + "Anna Maria Katarzyna Nowak-Wielka-Zabłocka-Długosz-Ostrowska-Mickiewicz-Piękna-Sobieska-Kowalewska-Jagiellońska-Słowacka-Krzyżanowska-Kordecka-Kościuszkowska", + phoneNumbers: [ + { + id: "3006", + phoneNumber: "+48123456786", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Long Display Name (last name is long)", + displayName3: + "Anna Maria Katarzyna Nowak-Wielka-Zabłocka-Długosz-Ostrowska-Mickiewicz-Piękna-Sobieska-Kowalewska-Jagiellońska-Słowacka-Krzyżanowska-Kordecka-Kościuszkowska", + }, + { + entityType: "contacts", + contactId: "429", + searchName: + "Aleksandra-Marianna-Katarzyna-Magdalena-Joanna-Weronika-Zofia-Karolina-Małgorzata-Anastazja Long Display Name (first name is long)", + sortField: + "Long Display Name (first name is long)Aleksandra-Marianna-Katarzyna-Magdalena-Joanna-Weronika-Zofia-Karolina-Małgorzata-Anastazja", + firstName: + "Aleksandra-Marianna-Katarzyna-Magdalena-Joanna-Weronika-Zofia-Karolina-Małgorzata-Anastazja", + lastName: "Long Display Name (first name is long)", + phoneNumbers: [ + { + id: "3013", + phoneNumber: "+48234567890", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: + "Aleksandra-Marianna-Katarzyna-Magdalena-Joanna-Weronika-Zofia-Karolina-Małgorzata-Anastazja", + displayName3: "Long Display Name (first name is long)", + }, + { + entityType: "contacts", + contactId: "430", + searchName: + "Special Character (last name with special characters) !@#$%^&*()-=+[]{}|;:',.<>?/`~", + sortField: + "!@#$%^&*()-=+[]{}|;:',.<>?/`~Special Character (last name with special characters)", + firstName: "Special Character (last name with special characters)", + lastName: "!@#$%^&*()-=+[]{}|;:',.<>?/`~", + phoneNumbers: [ + { + id: "3020", + phoneNumber: "+49123454789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Special Character (last name with special characters)", + displayName3: "!@#$%^&*()-=+[]{}|;:',.<>?/`~", + }, + { + entityType: "contacts", + contactId: "431", + searchName: "### Special Character (first name with special characters)", + sortField: "Special Character (first name with special characters)###", + firstName: "###", + lastName: "Special Character (first name with special characters)", + phoneNumbers: [ + { + id: "3027", + phoneNumber: "+49123426789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "###", + displayName3: "Special Character (first name with special characters)", + }, + { + entityType: "contacts", + contactId: "432", + searchName: "Plus (last name with plus) +", + sortField: "+Plus (last name with plus)", + firstName: "Plus (last name with plus)", + lastName: "+", + phoneNumbers: [ + { + id: "3034", + phoneNumber: "+49123156789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Plus (last name with plus)", + displayName3: "+", + }, + { + entityType: "contacts", + contactId: "433", + searchName: "+ Plus (first name with plus)", + sortField: "Plus (first name with plus)+", + firstName: "+", + lastName: "Plus (first name with plus)", + phoneNumbers: [ + { + id: "3041", + phoneNumber: "+49123156789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "+", + displayName3: "Plus (first name with plus)", + }, + { + entityType: "contacts", + contactId: "434", + searchName: "Marek Marmarecki", + sortField: "MarmareckiMarek", + firstName: "Marek", + lastName: "Marmarecki", + phoneNumbers: [ + { + id: "3048", + phoneNumber: "500500500", + phoneType: "MOBILE", + }, + { + id: "3049", + phoneNumber: "500500600", + phoneType: "WORK", + }, + ], + starred: false, + displayName2: "Marek", + displayName3: "Marmarecki", + }, + { + entityType: "contacts", + contactId: "435", + searchName: "Numer (last name is numeric) 12345", + sortField: "12345Numer (last name is numeric)", + firstName: "Numer (last name is numeric)", + lastName: "12345", + phoneNumbers: [ + { + id: "3056", + phoneNumber: "+48901234567", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Numer (last name is numeric)", + displayName3: "12345", + }, + { + entityType: "contacts", + contactId: "436", + searchName: "Prof. PhD. (prefix & suffix only)", + sortField: "Prof.", + namePrefix: "Prof.", + nameSuffix: "PhD. (prefix & suffix only)", + phoneNumbers: [ + { + id: "3063", + phoneNumber: "+48345678901", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName1: "Prof.", + displayName4: "PhD. (prefix & suffix only)", + }, + { + entityType: "contacts", + contactId: "437", + searchName: "Jan (only middle name)", + sortField: "Jan (only middle name)", + middleName: "Jan (only middle name)", + starred: false, + displayName3: "Jan (only middle name)", + }, + { + entityType: "contacts", + contactId: "438", + searchName: "%%%% (only middle name)", + sortField: "%%%% (only middle name)", + middleName: "%%%% (only middle name)", + starred: false, + displayName3: "%%%% (only middle name)", + }, + { + entityType: "contacts", + contactId: "439", + searchName: "490123456789", + sortField: "490123456789", + phoneNumbers: [ + { + id: "3082", + phoneNumber: "490123456789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName3: "490123456789", + }, + { + entityType: "contacts", + contactId: "440", + searchName: "911234567890", + sortField: "911234567890", + phoneNumbers: [ + { + id: "3089", + phoneNumber: "911234567890", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName3: "911234567890", + }, + { + entityType: "contacts", + contactId: "441", + searchName: "8612345678901", + sortField: "8612345678901", + phoneNumbers: [ + { + id: "3096", + phoneNumber: "8612345678901", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName3: "8612345678901", + }, + { + entityType: "contacts", + contactId: "442", + searchName: "+48345678902", + sortField: "+48345678902", + phoneNumbers: [ + { + id: "3103", + phoneNumber: "+48345678902", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName3: "+48345678902", + }, + { + entityType: "contacts", + contactId: "443", + searchName: "+48345678902", + sortField: "+48345678902", + phoneNumbers: [ + { + id: "3110", + phoneNumber: "+48345678902", + phoneType: "MOBILE", + }, + { + id: "3111", + phoneNumber: "+48445678903", + phoneType: "HOME", + }, + ], + starred: false, + displayName3: "+48345678902", + }, + { + entityType: "contacts", + contactId: "444", + searchName: "+48345678902", + sortField: "+48345678902", + phoneNumbers: [ + { + id: "3118", + phoneNumber: "+48345678902", + phoneType: "MOBILE", + }, + { + id: "3119", + phoneNumber: "+48445678903", + phoneType: "HOME", + }, + { + id: "3120", + phoneNumber: "+48555678904", + phoneType: "WORK", + }, + ], + starred: false, + displayName3: "+48345678902", + }, + { + entityType: "contacts", + contactId: "445", + searchName: "+48345678902", + sortField: "+48345678902", + phoneNumbers: [ + { + id: "3127", + phoneNumber: "+48345678902", + phoneType: "MOBILE", + }, + { + id: "3128", + phoneNumber: "+48445678903", + phoneType: "HOME", + }, + { + id: "3130", + phoneNumber: "+48665678905", + phoneType: "OTHER", + }, + { + id: "3129", + phoneNumber: "+48555678904", + phoneType: "WORK", + }, + ], + starred: false, + displayName3: "+48345678902", + }, + { + entityType: "contacts", + contactId: "446", + searchName: "+48555678904", + sortField: "+48555678904", + phoneNumbers: [ + { + id: "3138", + phoneNumber: "+48665678905", + phoneType: "OTHER", + }, + { + id: "3137", + phoneNumber: "+48555678904", + phoneType: "WORK", + }, + ], + starred: false, + displayName3: "+48555678904", + }, + { + entityType: "contacts", + contactId: "447", + searchName: "Anna (Germany-style)", + sortField: "Anna (Germany-style)", + firstName: "Anna (Germany-style)", + phoneNumbers: [ + { + id: "3145", + phoneNumber: "48123456789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Anna (Germany-style)", + }, + { + entityType: "contacts", + contactId: "448", + searchName: "Carlos (Brazil-style)", + sortField: "Carlos (Brazil-style)", + firstName: "Carlos (Brazil-style)", + phoneNumbers: [ + { + id: "3152", + phoneNumber: "551112345678", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Carlos (Brazil-style)", + }, + { + entityType: "contacts", + contactId: "449", + searchName: "Yuki (Japan-style)", + sortField: "Yuki (Japan-style)", + firstName: "Yuki (Japan-style)", + phoneNumbers: [ + { + id: "3159", + phoneNumber: "81312345678", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "Yuki (Japan-style)", + }, + { + entityType: "contacts", + contactId: "450", + searchName: "Liam (Ireland & Australia)", + sortField: "Liam (Ireland & Australia)", + firstName: "Liam (Ireland & Australia)", + phoneNumbers: [ + { + id: "3166", + phoneNumber: "1512345678", + phoneType: "MOBILE", + }, + { + id: "3167", + phoneNumber: "611234567890123", + phoneType: "WORK", + }, + ], + starred: false, + displayName2: "Liam (Ireland & Australia)", + }, + { + entityType: "contacts", + contactId: "451", + searchName: "Amina (Morocco & USA)", + sortField: "Amina (Morocco & USA)", + firstName: "Amina (Morocco & USA)", + phoneNumbers: [ + { + id: "3175", + phoneNumber: "14155552671", + phoneType: "MOBILE", + }, + { + id: "3174", + phoneNumber: "201234567", + phoneType: "HOME", + }, + ], + starred: false, + displayName2: "Amina (Morocco & USA)", + }, + { + entityType: "contacts", + contactId: "452", + searchName: "home@email.com", + sortField: "home@email.com", + emailAddresses: [ + { + id: "3182", + emailAddress: "home@email.com", + emailType: "HOME", + }, + ], + starred: false, + displayName3: "home@email.com", + }, + { + entityType: "contacts", + contactId: "453", + searchName: "home@email.com", + sortField: "home@email.com", + emailAddresses: [ + { + id: "3189", + emailAddress: "home@email.com", + emailType: "HOME", + }, + { + id: "3190", + emailAddress: "work@email.com", + emailType: "WORK", + }, + ], + starred: false, + displayName3: "home@email.com", + }, + { + entityType: "contacts", + contactId: "454", + searchName: "home@email.com", + sortField: "home@email.com", + emailAddresses: [ + { + id: "3197", + emailAddress: "home@email.com", + emailType: "HOME", + }, + { + id: "3198", + emailAddress: "work@email.com", + emailType: "WORK", + }, + { + id: "3199", + emailAddress: "other@email.com", + emailType: "OTHER", + }, + ], + starred: false, + displayName3: "home@email.com", + }, + { + entityType: "contacts", + contactId: "455", + searchName: "home@email.com", + sortField: "home@email.com", + emailAddresses: [ + { + id: "3206", + emailAddress: "home@email.com", + emailType: "HOME", + }, + { + id: "3207", + emailAddress: "work@email.com", + emailType: "WORK", + }, + { + id: "3208", + emailAddress: "other@email.com", + emailType: "OTHER", + }, + { + id: "3209", + emailAddress: "unknown@email.com", + emailType: "OTHER", + }, + ], + starred: false, + displayName3: "home@email.com", + }, + { + entityType: "contacts", + contactId: "456", + searchName: "work@email.com", + sortField: "work@email.com", + emailAddresses: [ + { + id: "3216", + emailAddress: "work@email.com", + emailType: "WORK", + }, + { + id: "3217", + emailAddress: "other@email.com", + emailType: "OTHER", + }, + ], + starred: false, + displayName3: "work@email.com", + }, + { + entityType: "contacts", + contactId: "457", + searchName: "Bobby (nickname only)", + sortField: "Bobby (nickname only)", + nickName: "Bobby (nickname only)", + starred: false, + displayName3: "Bobby (nickname only)", + }, + { + entityType: "contacts", + contactId: "458", + searchName: "Innovative Technologies (company)", + sortField: "Innovative Technologies (company)", + company: "Innovative Technologies (company)", + starred: false, + displayName3: "Innovative Technologies (company)", + }, + { + entityType: "contacts", + contactId: "459", + searchName: "Human Resources (department)", + sortField: "Human Resources (department)", + department: "Human Resources (department)", + starred: false, + displayName3: "Human Resources (department)", + }, + { + entityType: "contacts", + contactId: "460", + searchName: "Chief Marketing Officer (job title)", + sortField: "Chief Marketing Officer (job title)", + workTitle: "Chief Marketing Officer (job title)", + starred: false, + displayName3: "Chief Marketing Officer (job title)", + }, + { + entityType: "contacts", + contactId: "461", + searchName: "Innovative Technologies (company & department)", + sortField: "Innovative Technologies (company & department)", + company: "Innovative Technologies (company & department)", + department: "Human Resources", + starred: false, + displayName3: "Innovative Technologies (company & department)", + }, + { + entityType: "contacts", + contactId: "462", + searchName: "Innovative Technologies (company & job title)", + sortField: "Innovative Technologies (company & job title)", + company: "Innovative Technologies (company & job title)", + workTitle: "Chief Marketing Officer", + starred: false, + displayName3: "Innovative Technologies (company & job title)", + }, + { + entityType: "contacts", + contactId: "463", + searchName: "Human Resources (department & job title)", + sortField: "Human Resources (department & job title)", + department: "Human Resources (department & job title)", + workTitle: "Chief Marketing Officer", + starred: false, + displayName3: "Human Resources (department & job title)", + }, + { + entityType: "contacts", + contactId: "464", + searchName: "Innovative Technologies (company, department & job title)", + sortField: "Innovative Technologies (company, department & job title)", + company: "Innovative Technologies (company, department & job title)", + department: "Human Resources", + workTitle: "Chief Marketing Officer", + starred: false, + displayName3: "Innovative Technologies (company, department & job title)", + }, + { + entityType: "contacts", + contactId: "465", + searchName: "Street 7 (full address), 10115, Berlin", + sortField: "Street 7 (full address), Berlin, 10115", + address: { + streetAddress: "Street 7 (full address)", + city: "Berlin", + zipCode: "10115", + type: "HOME", + }, + starred: false, + displayName3: "Street 7 (full address), 10115, Berlin", + }, + { + entityType: "contacts", + contactId: "466", + searchName: "Jane Smith", + sortField: "SmithJane", + firstName: "Jane", + lastName: "Smith", + address: { + streetAddress: "Street 5 (only street address)", + type: "HOME", + }, + starred: false, + displayName2: "Jane", + displayName3: "Smith", + }, + { + entityType: "contacts", + contactId: "467", + searchName: "Adam Johnson", + sortField: "JohnsonAdam", + firstName: "Adam", + lastName: "Johnson", + address: { + city: "Krakow", + type: "HOME", + }, + starred: false, + displayName2: "Adam", + displayName3: "Johnson", + }, + { + entityType: "contacts", + contactId: "468", + searchName: "Emily Davis", + sortField: "DavisEmily", + firstName: "Emily", + lastName: "Davis", + address: { + zipCode: "00-002", + type: "HOME", + }, + starred: false, + displayName2: "Emily", + displayName3: "Davis", + }, + { + entityType: "contacts", + contactId: "469", + searchName: "Michael Brown", + sortField: "BrownMichael", + firstName: "Michael", + lastName: "Brown", + address: { + streetAddress: "Street 9", + zipCode: "00-003", + type: "HOME", + }, + starred: false, + displayName2: "Michael", + displayName3: "Brown", + }, + { + entityType: "contacts", + contactId: "470", + searchName: "Michael Brown", + sortField: "BrownMichael", + firstName: "Michael", + lastName: "Brown", + address: { + state: "California", + country: "USA", + type: "HOME", + }, + starred: false, + displayName2: "Michael", + displayName3: "Brown", + }, + { + entityType: "contacts", + contactId: "471", + searchName: "sip:jan.nowak@siponly.com", + sortField: "sip:jan.nowak@siponly.com", + sip: "sip:jan.nowak@siponly.com", + starred: false, + displayName3: "sip:jan.nowak@siponly.com", + }, + { + entityType: "contacts", + contactId: "472", + searchName: "https://websiteonly.com", + sortField: "https://websiteonly.com", + website: "https://websiteonly.com", + starred: false, + displayName3: "https://websiteonly.com", + }, + { + entityType: "contacts", + contactId: "473", + searchName: "This is a test note. (only notes)", + sortField: "This is a test note. (only notes)", + notes: "This is a test note. (only notes)", + starred: false, + displayName3: "This is a test note. (only notes)", + }, + { + entityType: "contacts", + contactId: "474", + searchName: "🌞 Clark", + sortField: "Clark🌞", + firstName: "🌞", + lastName: "Clark", + phoneNumbers: [ + { + id: "3327", + phoneNumber: "+12123456789", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "🌞", + displayName3: "Clark", + }, + { + entityType: "contacts", + contactId: "475", + searchName: "John 🍀", + sortField: "🍀John", + firstName: "John", + lastName: "🍀", + phoneNumbers: [ + { + id: "3334", + phoneNumber: "+441234567890", + phoneType: "MOBILE", + }, + ], + starred: false, + displayName2: "John", + displayName3: "🍀", + }, + { + entityType: "contacts", + contactId: "476", + searchName: "+49876543210", + sortField: "+49876543210", + phoneNumbers: [ + { + id: "3341", + phoneNumber: "+49876543210", + phoneType: "MOBILE", + }, + ], + nickName: "🐶🐱", + starred: false, + displayName3: "+49876543210", + }, + { + entityType: "contacts", + contactId: "477", + searchName: "+48123456789", + sortField: "+48123456789", + phoneNumbers: [ + { + id: "3348", + phoneNumber: "+48123456789", + phoneType: "MOBILE", + }, + ], + company: "🚀💼", + starred: false, + displayName3: "+48123456789", + }, + { + entityType: "contacts", + contactId: "478", + searchName: "+48223456789", + sortField: "+48223456789", + phoneNumbers: [ + { + id: "3355", + phoneNumber: "+48223456789", + phoneType: "WORK", + }, + ], + notes: "💡🚨", + starred: false, + displayName3: "+48223456789", + }, +] + +export const selectedContactsEntities: EntityData[] = [ + contactEntities[0], // Dr. Anna Nowak Jr. – spełnia wymagania a (First name and Last name + Phone) + contactEntities[2], // Dr. Michael Johnson PhD – spełnia wymagania c (Suffix, First name and Last name + Phone) + contactEntities[3], // Long Display Name (last name is long) – spełnia wymagania e (Last name only + Phone) + contactEntities[9], // Plus (last name with plus) – nietypowy przypadek nazwiska z symbolem "+" + contactEntities[10], // Marek Marmarecki – spełnia wymagania g (Contact with two phone numbers) + contactEntities[19], // +48345678902 – spełnia wymagania f (Phone only) + contactEntities[31], // Anna (Germany-style) – różnicujący przypadek z imieniem i numerem + contactEntities[33], // Carlos (Brazil-style) – różnicujący przypadek regionalny + contactEntities[44], // 🌞 Clark – różnicujący przypadek z emoji w imieniu + contactEntities[45], // John 🍀 – różnicujący przypadek z emoji w nazwisku + contactEntities[46], // 🐶🐱 (nickname) – różnicujący przypadek z emoji w pseudonimie + contactEntities[53], // 💡🚨 (notes) – różnicujący przypadek z emoji w notatkach + contactEntities[7], // Special Character (last name with special characters) – różnicujący przypadek z nietypowym nazwiskiem + contactEntities[13], // Numer (last name is numeric) – różnicujący przypadek z liczbami w nazwisku + contactEntities[19], // +48345678902 – sam numer, spełnia wymaganie f + contactEntities[47], // Liam (Ireland & Australia) – kontakt z numerami z różnych regionów + contactEntities[48], // Amina (Morocco & USA) – różnorodność regionalna i wiele numerów +] + +export const audioFileEntities: EntityData[] = [ + { + id: "457", + filePath: "/storage/emulated/0/test.mp3", + fileName: "test.mp3", + extension: "mp3", + fileSize: 1048576000, + fileType: "AUDIO", + mimeType: "audio/mpeg", + isInternal: true, + entityType: "audioFiles", + }, +] diff --git a/apps/mudita-center-e2e/src/helpers/index.ts b/apps/mudita-center-e2e/src/helpers/index.ts index 62a4e2bea6..be5360b462 100644 --- a/apps/mudita-center-e2e/src/helpers/index.ts +++ b/apps/mudita-center-e2e/src/helpers/index.ts @@ -3,5 +3,6 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ +export * from "./mock-entity-download-process.helper" export * from "./sleep.helper" export * from "./testid.helper" diff --git a/apps/mudita-center-e2e/src/helpers/mock-entity-download-process.helper.ts b/apps/mudita-center-e2e/src/helpers/mock-entity-download-process.helper.ts new file mode 100644 index 0000000000..576cd50635 --- /dev/null +++ b/apps/mudita-center-e2e/src/helpers/mock-entity-download-process.helper.ts @@ -0,0 +1,90 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +import { E2EMockClient } from "../../../../libs/e2e-mock/client/src/lib/e2e-mock-client" +import { generateUniqueNumber } from "./utils/generate-unique-number-id.helper" +import { generateBase64Info } from "./utils/generate-base-64-info.helper" + +interface mockEntityDownloadProcessOptions { + path: string + entityType: string + data: Record[] +} + +export const mockEntityDownloadProcess = ({ + path, + entityType, + data, +}: mockEntityDownloadProcessOptions) => { + const { base64, sizeInBytes, crc32Hex } = generateBase64Info({ data }) + const totalEntities = data.length + const transferId = generateUniqueNumber() + + E2EMockClient.mockResponse({ + path, + body: { totalEntities, uniqueKey: "1733750368390" }, + match: { + expected: { + entityType: entityType, + }, + }, + endpoint: "ENTITIES_METADATA", + method: "GET", + status: 200, + }) + + E2EMockClient.mockResponse({ + path, + body: { + filePath: `../${entityType}_entities.json`, + progress: 100, + }, + match: { + expected: { + entityType: entityType, + responseType: "file", + }, + }, + endpoint: "ENTITIES_DATA", + method: "GET", + status: 200, + }) + + E2EMockClient.mockResponse({ + path, + body: { + transferId, + chunkSize: sizeInBytes, + fileSize: sizeInBytes, + crc32: crc32Hex, + }, + match: { + expected: { + filePath: `../${entityType}_entities.json`, + }, + }, + endpoint: "PRE_FILE_TRANSFER", + method: "GET", + status: 200, + }) + + E2EMockClient.mockResponse({ + path, + body: { + transferId, + chunkNumber: 1, + data: base64, + }, + match: { + expected: { + transferId, + chunkNumber: 1, + }, + }, + endpoint: "FILE_TRANSFER", + method: "GET", + status: 200, + }) +} diff --git a/apps/mudita-center-e2e/src/helpers/utils/generate-base-64-info.helper.ts b/apps/mudita-center-e2e/src/helpers/utils/generate-base-64-info.helper.ts new file mode 100644 index 0000000000..7a9422f825 --- /dev/null +++ b/apps/mudita-center-e2e/src/helpers/utils/generate-base-64-info.helper.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +import crc32 from "crc-32" + +export function generateBase64Info(obj: Record) { + const jsonString = JSON.stringify(obj) + const data = Buffer.from(jsonString, "utf8").toString() + const base64String = Buffer.from(data).toString("base64") + const sizeInBytes = Buffer.byteLength(data, "utf8") + const crc32Hex = (crc32.buf(Buffer.from(base64String, "utf8")) >>> 0) + .toString(16) + .padStart(8, "0") + + return { + base64: base64String, + sizeInBytes: sizeInBytes, + crc32Hex: crc32Hex, + } +} diff --git a/apps/mudita-center-e2e/src/helpers/utils/generate-unique-number-id.helper.ts b/apps/mudita-center-e2e/src/helpers/utils/generate-unique-number-id.helper.ts new file mode 100644 index 0000000000..0c7b745c13 --- /dev/null +++ b/apps/mudita-center-e2e/src/helpers/utils/generate-unique-number-id.helper.ts @@ -0,0 +1,7 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +export const generateUniqueNumber = () => + Date.now() + Math.floor(Math.random() * 1000) diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-lock-sample.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-lock-sample.e2e.ts index a0f36b50b5..ae5b5b1cb7 100644 --- a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-lock-sample.e2e.ts +++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-lock-sample.e2e.ts @@ -1,11 +1,14 @@ -// import { DEFAULT_RESPONSES } from "Libs/e2e-mock/responses/src/lib/default-responses" import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src" +import { DEFAULT_RESPONSES } from "../../../../../libs/e2e-mock/responses/src" +import { mockEntityDownloadProcess } from "../../helpers/mock-entity-download-process.helper" import { - DEFAULT_RESPONSES, - outboxReloadOverview, - overviewDataWithoutBadge, -} from "../../../../../libs/e2e-mock/responses/src" -// import { outboxReloadOverview } from "Libs/e2e-mock/responses/src" + audioFileEntities, + selectedContactsEntities, +} from "../../helpers/entity-fixtures" + +function getBodyAsRecord(body: unknown): Record { + return body ? (body as Record) : {} +} describe("E2E mock lock sample", () => { before(async () => { @@ -66,34 +69,111 @@ describe("E2E mock lock sample", () => { E2EMockClient.mockResponse({ path: "path-1", - body: DEFAULT_RESPONSES.FEATURE_DATA?.GET?.body as Record, + body: getBodyAsRecord( + DEFAULT_RESPONSES.API_CONFIGURATION?.GET?.[0]?.body + ), + endpoint: "API_CONFIGURATION", + method: "GET", + status: 200, + }) + + await browser.pause(2000) + + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord(DEFAULT_RESPONSES.FEATURE_DATA?.GET?.[0]?.body), + match: { + expected: { + feature: "mc-overview", + lang: "en-US", + }, + }, endpoint: "FEATURE_DATA", method: "GET", status: 200, }) - // await browser.pause(2000) E2EMockClient.mockResponse({ path: "path-1", - body: DEFAULT_RESPONSES.FEATURE_CONFIGURATION?.GET?.body as Record< - string, - any - >, + body: getBodyAsRecord(DEFAULT_RESPONSES.FEATURE_DATA?.GET?.[1]?.body), + match: { + expected: { + feature: "fileManager", + lang: "en-US", + }, + }, + endpoint: "FEATURE_DATA", + method: "GET", + status: 200, + }) + + await browser.pause(2000) + + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord( + DEFAULT_RESPONSES.FEATURE_CONFIGURATION?.GET?.[0]?.body + ), + match: { + expected: { + feature: "contacts", + lang: "en-US", + }, + }, + endpoint: "FEATURE_CONFIGURATION", + method: "GET", + status: 200, + }) + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord( + DEFAULT_RESPONSES.FEATURE_CONFIGURATION?.GET?.[1]?.body + ), + match: { + expected: { + feature: "mc-overview", + lang: "en-US", + }, + }, + endpoint: "FEATURE_CONFIGURATION", + method: "GET", + status: 200, + }) + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord( + DEFAULT_RESPONSES.FEATURE_CONFIGURATION?.GET?.[2]?.body + ), + match: { + expected: { + feature: "fileManager", + lang: "en-US", + }, + }, endpoint: "FEATURE_CONFIGURATION", method: "GET", status: 200, }) E2EMockClient.mockResponse({ path: "path-1", - body: DEFAULT_RESPONSES.MENU_CONFIGURATION?.GET?.body as Record< - string, - any - >, + body: getBodyAsRecord( + DEFAULT_RESPONSES.MENU_CONFIGURATION?.GET?.[0]?.body + ), endpoint: "MENU_CONFIGURATION", method: "GET", status: 200, }) + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord( + DEFAULT_RESPONSES.ENTITIES_METADATA?.GET?.[0]?.body + ), + endpoint: "ENTITIES_METADATA", + method: "GET", + status: 200, + }) + E2EMockClient.mockResponse({ path: "path-1", body: { @@ -105,6 +185,39 @@ describe("E2E mock lock sample", () => { status: 200, }) + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord( + DEFAULT_RESPONSES.ENTITIES_CONFIGURATION?.GET?.[0]?.body + ), + match: { expected: { entityType: "contacts" } }, + endpoint: "ENTITIES_CONFIGURATION", + method: "GET", + status: 200, + }) + + E2EMockClient.mockResponse({ + path: "path-1", + body: getBodyAsRecord( + DEFAULT_RESPONSES.ENTITIES_CONFIGURATION?.GET?.[1]?.body + ), + match: { expected: { entityType: "audioFiles" } }, + endpoint: "ENTITIES_CONFIGURATION", + method: "GET", + status: 200, + }) + + mockEntityDownloadProcess({ + path: "path-1", + data: selectedContactsEntities, + entityType: "contacts", + }) + mockEntityDownloadProcess({ + path: "path-1", + data: audioFileEntities, + entityType: "audioFiles", + }) + await browser.pause(10000) }) }) diff --git a/libs/e2e-mock/responses/src/lib/default-responses.ts b/libs/e2e-mock/responses/src/lib/default-responses.ts index ec19e17a83..956cd0856a 100644 --- a/libs/e2e-mock/responses/src/lib/default-responses.ts +++ b/libs/e2e-mock/responses/src/lib/default-responses.ts @@ -6,7 +6,15 @@ import { ApiResponse } from "Core/device/types/mudita-os" import { MatchConfig } from "Libs/e2e-mock/server/src" import { APIEndpointType, APIMethodsType } from "device/models" - +import { + entitiesConfiguration, + entitiesConfigurationAudioFiles, +} from "./entities-configuration-responses" +import { + featureConfigurationContacts, + featureConfigurationFileManager, + featureConfigurationOverview, +} from "./feature-configuration-responses" //import from "Core/device" breaks usage in e2e enum ResponseStatus { Ok = 200, @@ -45,167 +53,281 @@ export type MocksArrayResponsesMap = Partial< Record > -export const DEFAULT_RESPONSES: MockResponsesMap = { +export const DEFAULT_RESPONSES: MocksArrayResponsesMap = { API_CONFIGURATION: { - GET: { - status: ResponseStatus.Ok, - body: { - apiVersion: "1.0.0", - osVersion: "0.0.46 MuditaOS K", - lang: "en-US", - variant: "black", - features: ["mc-overview"], - productId: "2006", - vendorId: "0e8d", - serialNumber: "0123456789ABCDEF", - }, - }, + GET: [ + { + status: ResponseStatus.Ok, + body: { + apiVersion: "1.0.0", + osVersion: "0.0.46 MuditaOS K", + lang: "en-US", + variant: "black", + features: ["mc-overview", "contacts", "fileManager"], + entityTypes: ["contacts", "audioFiles"], + productId: "2006", + vendorId: "0e8d", + serialNumber: "0123456789ABCDEF", + otaApiConfig: { + otaApiKey: "864055030180383", + osVersionTimestamp: 1733752055000, + }, + }, + }, + ], }, MENU_CONFIGURATION: { - GET: { - status: ResponseStatus.Ok, - body: { - title: "Kompakt", - menuItems: [ - { - feature: "mc-overview", - displayName: "Overview", - icon: "overview", - }, - ], + GET: [ + { + status: ResponseStatus.Ok, + body: { + title: "Kompakt", + menuItems: [ + { + feature: "mc-overview", + displayName: "Overview", + icon: "overview", + }, + { + feature: "contacts", + displayName: "Contacts", + icon: "contacts-book", + }, + { + feature: "fileManager", + displayName: "Manage Files", + icon: "file-manager", + }, + ], + }, }, - }, + ], }, OUTBOX: { - GET: { - status: ResponseStatus.Ok, - body: { features: [], data: [] }, - }, + GET: [ + { + status: ResponseStatus.Ok, + body: { features: [], data: [] }, + }, + ], }, - FEATURE_DATA: { - GET: { - status: ResponseStatus.Ok, - body: { - summary: { - about: { - serialNumber: { text: "0123456789ABCDEF" }, - imei1: { text: "864055030138811" }, - imei2: { text: "864055030138829" }, - sar: { - text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.", - }, + FEATURE_CONFIGURATION: { + GET: [ + { + status: ResponseStatus.Ok, + body: featureConfigurationContacts, + match: { + expected: { + feature: "contacts", + lang: "en-US", }, }, - sections: { - battery: { icon: "battery-charging-5", text: "100%", subText: "" }, - update: { text: "ANDROID 12", version: "0.3.0" }, - status: { badgeText: "Offline+" }, - "airplane-mode": { icon: "airplane-mode", text: "Airplane mode" }, + }, + { + status: ResponseStatus.Ok, + body: featureConfigurationOverview, + match: { + expected: { + feature: "mc-overview", + lang: "en-US", + }, }, }, - }, + { + status: ResponseStatus.Ok, + body: featureConfigurationFileManager, + match: { + expected: { + feature: "fileManager", + lang: "en-US", + }, + }, + }, + ], }, - FEATURE_CONFIGURATION: { - GET: { - status: ResponseStatus.Ok, - body: { - title: "Overview", - summary: { - show: true, - showImg: true, - imgVariant: "black", - showSerialNumber: true, - serialNumberLabel: "Serial number", - showAbout: true, - aboutTitle: "About your device", - aboutIcon: "device", - aboutSubtitle: "Device details", - aboutFields: [ - { - dataKey: "serialNumber", - type: "detail-list-text", - title: "Serial number", - }, - { - dataKey: "imei1", - type: "detail-list-text", - title: "IMEI (sim slot 1)", - }, - { - dataKey: "imei2", - type: "detail-list-text", - title: "IMEI (sim slot 2)", + FEATURE_DATA: { + GET: [ + { + status: ResponseStatus.Ok, + body: { + summary: { + about: { + serialNumber: { text: "0123456789ABCDEF" }, + imei1: { text: "864055030138811" }, + imei2: { text: "864055030138829" }, + sar: { + text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.", + }, }, + }, + sections: { + battery: { icon: "battery-charging-5", text: "100%", subText: "" }, + update: { text: "ANDROID 12", version: "0.3.0" }, + status: { badgeText: "Offline+" }, + "airplane-mode": { icon: "airplane-mode", text: "Airplane mode" }, + }, + }, + match: { expected: { feature: "mc-overview", lang: "en-US" } }, + }, + { + status: ResponseStatus.Ok, + body: { + storageInformation: [ { - dataKey: "sar", - type: "detail-list-modal", - title: "SAR", - buttonText: "Check SAR information", + storageType: "INTERNAL", + totalSpaceBytes: 32000000000, + usedSpaceBytes: 9576652800, + totalSpaceString: "32 GB", + usedSpaceString: "9.6 GB", + categoriesSpaceInformation: { + imageFiles: { + storageCategory: "imageFiles", + spaceUsedBytes: 90085267, + spaceUsedString: "90.1 MB", + }, + audioFiles: { + storageCategory: "audioFiles", + spaceUsedBytes: 1048576000, + spaceUsedString: "1 GB", + }, + ebookFiles: { + storageCategory: "ebookFiles", + spaceUsedBytes: 0, + spaceUsedString: "0 B", + }, + otherFiles: { + storageCategory: "otherFiles", + spaceUsedBytes: 8437991533, + spaceUsedString: "8.4 GB", + }, + }, }, ], }, - sections: [ - { - title: "Status", - type: "tile-list", - dataKey: "status", - fields: [ - { dataKey: "battery", type: "icon-text" }, - { dataKey: "airplane-mode", type: "icon-text" }, - ], + match: { expected: { feature: "fileManager", lang: "en-US" } }, + }, + ], + }, + ENTITIES_CONFIGURATION: { + GET: [ + { + status: ResponseStatus.Ok, + body: entitiesConfiguration, + match: { expected: { entityType: "contacts" } }, + }, + { + status: ResponseStatus.Ok, + body: entitiesConfigurationAudioFiles, + match: { expected: { entityType: "audioFiles" } }, + }, + ], + }, + ENTITIES_METADATA: { + GET: [ + { + status: ResponseStatus.Ok, + body: { totalEntities: 1, uniqueKey: "1733750368393" }, + match: { expected: { entityType: "contacts" } }, + }, + { + status: ResponseStatus.Ok, + body: { totalEntities: 1, uniqueKey: "1733750368394" }, + match: { expected: { entityType: "audioFiles" } }, + }, + ], + }, + ENTITIES_DATA: { + GET: [ + { + status: ResponseStatus.Ok, + body: { + filePath: "../contact_entities.json", + progress: 100, + }, + match: { + expected: { + entityType: "contacts", + responseType: "file", }, - { - dataKey: "update", - type: "mc-overview-update", - title: "Android OS", - currentVersionKey: "version", - showBadge: false, - versionLabel: "Current version:", + }, + }, + { + status: ResponseStatus.Ok, + body: { + filePath: "../audioFiles_entities.json", + progress: 100, + }, + match: { + expected: { + entityType: "audioFiles", + responseType: "file", }, - { - dataKey: "backup", - type: "mc-overview-backup", - title: "Backup", - backupFeatures: [ - { label: "Contact list", key: "CONTACT_LIST" }, - { label: "Call log", key: "CALL_LOG" }, - { label: "Messages", key: "MESSAGES" }, - { label: "Notes", key: "NOTES" }, - { label: "Calendar events", key: "CALENDAR_EVENTS" }, - { - label: "OS version & OS settings", - key: "OS_VERSION_AND_SETTINGS", - }, - { label: "App settings: Phone, Messages", key: "APP_SETTINGS" }, - ], - restoreFeatures: [ - { - label: "Contact list", - feature: "CONTACT_LIST", - keys: ["CONTACT_LIST"], - }, - { label: "Call log", feature: "CALL_LOG", keys: ["CALL_LOG"] }, - { label: "Messages", feature: "MESSAGES", keys: ["MESSAGES"] }, - { label: "Notes", feature: "NOTES", keys: ["NOTES"] }, - { - label: "Calendar events", - feature: "CALENDAR_EVENTS", - keys: ["CALENDAR_EVENTS"], - }, - { - label: "OS version & OS settings", - feature: "OS_VERSION_AND_SETTINGS", - keys: ["OS_VERSION_AND_SETTINGS"], - }, - { - label: "App settings: Phone, Messages", - feature: "APP_SETTINGS", - keys: ["APP_SETTINGS"], - }, - ], + }, + }, + ], + }, + PRE_FILE_TRANSFER: { + GET: [ + { + status: ResponseStatus.Ok, + body: { + transferId: 48647, + chunkSize: 6574, + fileSize: 6574, + crc32: "f8748c26", + }, + match: { + expected: { + filePath: "../contact_entities.json", + }, + }, + }, + { + status: ResponseStatus.Ok, + body: { + transferId: 1734669809788, + chunkSize: 214, + fileSize: 214, + crc32: "217b0c15", + }, + match: { + expected: { + filePath: "../audioFiles_entities.json", + }, + }, + }, + ], + }, + FILE_TRANSFER: { + GET: [ + { + status: ResponseStatus.Ok, + body: { + transferId: 48647, + chunkNumber: 1, + data: "eyJkYXRhIjpbeyJjb250YWN0SWQiOiI0MjUiLCJlbnRpdHlUeXBlIjoiY29udGFjdHMiLCJzZWFyY2hOYW1lIjoiRHIuIEFubmEgTm93YWsgSnIuIiwic29ydEZpZWxkIjoiTm93YWtBbm5hIiwiZmlyc3ROYW1lIjoiQW5uYSIsIm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, + chunkNumber: 1 }, - ], + }, + }, + { + status: ResponseStatus.Ok, + body: { + transferId: 1734669809788, + chunkNumber: 1, + data: "eyJkYXRhIjpbeyJlbnRpdHlUeXBlIjoiYXVkaW9GaWxlcyIsImlkIjoiNDU3IiwiZmlsZVBhdGgiOiIvc3RvcmFnZS9lbXVsYXRlZC8wL3Rlc3QubXAzIiwiZmlsZU5hbWUiOiJ0ZXN0Lm1wMyIsImV4dGVuc2lvbiI6Im1wMyIsImZpbGVTaXplIjoxMDQ4NTc2MDAwLCJmaWxlVHlwZSI6IkFVRElPIiwibWltZVR5cGUiOiJhdWRpby9tcGVnIiwiaXNJbnRlcm5hbCI6dHJ1ZX1dfQ==", + }, + match: { + expected: { + transferId: 1734669809788, + chunkNumber: 1 + }, + }, }, - }, + ], }, } diff --git a/libs/e2e-mock/responses/src/lib/entities-configuration-responses.ts b/libs/e2e-mock/responses/src/lib/entities-configuration-responses.ts new file mode 100644 index 0000000000..18618c2645 --- /dev/null +++ b/libs/e2e-mock/responses/src/lib/entities-configuration-responses.ts @@ -0,0 +1,452 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +export const entitiesConfigurationAudioFiles = { + globalValidators: { requiredFieldsCombinations: [] }, + fields: { + id: { type: "id" }, + filePath: { type: "string", validators: [{ required: true }] }, + fileName: { type: "string", validators: [{ required: true }] }, + extension: { type: "string", validators: [{ required: true }] }, + fileSize: { type: "number", validators: [{ required: true }] }, + fileType: { type: "string", validators: [{ required: true }] }, + mimeType: { type: "string", validators: [{ required: true }] }, + isInternal: { type: "boolean" }, + entityType: { type: "string", validators: [{ required: true }] }, + }, +} + +export const entitiesConfiguration = { + globalValidators: { + requiredFieldsCombinations: [ + { + fields: ["phoneNumbers"], + countLogic: "lt", + fieldsCount: 3, + error: "A maximum of two phone numbers can be provided.", + }, + ], + }, + fields: { + contactId: { + type: "id", + }, + firstName: { + type: "string", + validators: [ + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "First name must start with printable character", + }, + ], + }, + lastName: { + type: "string", + validators: [ + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Last name must start with printable character", + }, + ], + }, + namePrefix: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Prefix must start with printable character", + }, + ], + }, + middleName: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Middle name must start with printable character", + }, + ], + }, + nameSuffix: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Suffix must start with printable character", + }, + ], + }, + phoneNumbers: { + type: "array", + items: { + type: "object", + fields: { + id: { + type: "id", + }, + phoneNumber: { + type: "string", + validators: [ + { + required: true, + }, + { + pattern: + "/^(\\+?\\d{1,3}[-.\\s]?)?(\\(?\\d{1,4}\\)?[-.\\s]?)?\\d{1,4}[-.\\s]?\\d{1,4}[-.\\s]?\\d{1,9}$/", + negatePattern: false, + error: "Invalid phone number format", + }, + ], + }, + phoneType: { + type: "string", + validators: [ + { + required: true, + }, + { + pattern: "/^(MOBILE|HOME|WORK|OTHER|UNKNOWN$/i", + negatePattern: false, + error: "Invalid phone type", + }, + ], + }, + }, + validators: [ + { + unique: true, + error: "Given phone object is not unique inside the array", + }, + { + pattern: + '/^\\{"id":"[^"]+","phoneNumber":"[^"]+","phoneType":"[^"]+"\\}$/', + negatePattern: false, + error: "Phone data is invalid", + }, + ], + }, + validators: [ + { + required: false, + }, + ], + }, + emailAddresses: { + type: "array", + items: { + type: "object", + fields: { + id: { + type: "id", + }, + emailAddress: { + type: "string", + validators: [ + { + required: true, + }, + { + pattern: "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/", + negatePattern: false, + error: "Invalid email address", + }, + ], + }, + emailType: { + type: "string", + validators: [ + { + required: true, + }, + { + pattern: "/^(HOME|WORK|OTHER|UNKNOWN$/i", + negatePattern: false, + error: "Invalid email address type", + }, + ], + }, + }, + validators: [ + { + unique: true, + error: "Given email object is not unique inside the array", + }, + { + pattern: + '/^\\{"id":"[^"]+","emailAddress":"[^"]+","emailType":"[^"]+"\\}$/', + negatePattern: false, + error: "Email data is invalid", + }, + ], + }, + validators: [ + { + required: false, + }, + ], + }, + nickName: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Nickname must start with printable character", + }, + ], + }, + company: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Company name must start with printable character", + }, + ], + }, + department: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Department name must start with printable character", + }, + ], + }, + workTitle: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Work title must start with printable character", + }, + ], + }, + address: { + type: "array", + items: { + type: "object", + fields: { + streetAddress: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Street address must start with printable character", + }, + ], + }, + secondStreetAddress: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Street address must start with printable character", + }, + ], + }, + poBox: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "POBox must start with printable character", + }, + ], + }, + city: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "City name must start with printable character", + }, + ], + }, + state: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "State must start with printable character", + }, + ], + }, + country: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Country must start with printable character", + }, + ], + }, + zipCode: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Zip code must start with printable character", + }, + ], + }, + type: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^(HOME|WORK|OTHER|UNKNOWN$/i", + negatePattern: false, + error: "Invalid address type", + }, + ], + }, + }, + }, + validators: [ + { + required: false, + }, + ], + }, + website: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: + "/^(https?=\\/\\/)?([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(\\/[^\\s]*)?$/i\n", + negatePattern: false, + error: "Invalid website URL", + }, + ], + }, + notes: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^$/", + negatePattern: true, + }, + ], + }, + starred: { + type: "boolean", + validators: [ + { + required: false, + }, + { + pattern: "/^TRUE|FALSE$/i", + negatePattern: false, + }, + ], + }, + entityType: { + type: "string", + validators: [ + { + required: true, + }, + ], + defaultValue: "contacts", + }, + sip: { + type: "string", + validators: [ + { + required: false, + }, + { + pattern: "/^[^\\s].*/", + negatePattern: false, + error: "Sip must start with printable character", + }, + ], + }, + searchName: { + type: "string", + }, + displayName1: { + type: "string", + }, + displayName2: { + type: "string", + }, + displayName3: { + type: "string", + }, + displayName4: { + type: "string", + }, + sortField: { + type: "string", + }, + }, +} diff --git a/libs/e2e-mock/responses/src/lib/feature-configuration-responses.ts b/libs/e2e-mock/responses/src/lib/feature-configuration-responses.ts new file mode 100644 index 0000000000..af59e2decf --- /dev/null +++ b/libs/e2e-mock/responses/src/lib/feature-configuration-responses.ts @@ -0,0 +1,122 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +export const featureConfigurationFileManager = { + main: { + screenTitle: "Manage Files", + component: "mc-file-manager-view", + config: { entityTypes: ["audioFiles"] }, + }, +} + +export const featureConfigurationContacts = { + main: { + component: "mc-contacts-view", + config: { + entityTypes: ["contacts"], + }, + // @ts-ignore + screenTitle: "Contacts", + }, +} + +export const featureConfigurationOverview = { + title: "Overview", + summary: { + show: true, + showImg: true, + imgVariant: "black", + showSerialNumber: true, + serialNumberLabel: "Serial number", + showAbout: true, + aboutTitle: "About your device", + aboutIcon: "device", + aboutSubtitle: "Device details", + aboutFields: [ + { + dataKey: "serialNumber", + type: "detail-list-text", + title: "Serial number", + }, + { + dataKey: "imei1", + type: "detail-list-text", + title: "IMEI (sim slot 1)", + }, + { + dataKey: "imei2", + type: "detail-list-text", + title: "IMEI (sim slot 2)", + }, + { + dataKey: "sar", + type: "detail-list-modal", + title: "SAR", + buttonText: "Check SAR information", + }, + ], + }, + sections: [ + { + title: "Status", + type: "tile-list", + dataKey: "status", + fields: [ + { dataKey: "battery", type: "icon-text" }, + { dataKey: "airplane-mode", type: "icon-text" }, + ], + }, + { + dataKey: "update", + type: "mc-overview-update", + title: "Android OS", + currentVersionKey: "version", + showBadge: false, + versionLabel: "Current version:", + }, + { + dataKey: "backup", + type: "mc-overview-backup", + title: "Backup", + backupFeatures: [ + { label: "Contact list", key: "CONTACT_LIST" }, + { label: "Call log", key: "CALL_LOG" }, + { label: "Messages", key: "MESSAGES" }, + { label: "Notes", key: "NOTES" }, + { label: "Calendar events", key: "CALENDAR_EVENTS" }, + { + label: "OS version & OS settings", + key: "OS_VERSION_AND_SETTINGS", + }, + { label: "App settings: Phone, Messages", key: "APP_SETTINGS" }, + ], + restoreFeatures: [ + { + label: "Contact list", + feature: "CONTACT_LIST", + keys: ["CONTACT_LIST"], + }, + { label: "Call log", feature: "CALL_LOG", keys: ["CALL_LOG"] }, + { label: "Messages", feature: "MESSAGES", keys: ["MESSAGES"] }, + { label: "Notes", feature: "NOTES", keys: ["NOTES"] }, + { + label: "Calendar events", + feature: "CALENDAR_EVENTS", + keys: ["CALENDAR_EVENTS"], + }, + { + label: "OS version & OS settings", + feature: "OS_VERSION_AND_SETTINGS", + keys: ["OS_VERSION_AND_SETTINGS"], + }, + { + label: "App settings: Phone, Messages", + feature: "APP_SETTINGS", + keys: ["APP_SETTINGS"], + }, + ], + }, + ], +} diff --git a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.test.ts b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.test.ts new file mode 100644 index 0000000000..d2c7a270a7 --- /dev/null +++ b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.test.ts @@ -0,0 +1,246 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +import { DEFAULT_RESPONSES } from "e2e-mock-responses" +import { APIEndpoints } from "device/models" +import { mockDescriptor, getMockedDevices } from "./mock-descriptor" +import { AddKompaktResponse } from "./mock-descriptor-validators" + +const path = "/dev/ttyUSB0" +const endpoint = APIEndpoints[0] +const method = "GET" + +describe("MockDescriptor", () => { + beforeEach(() => { + mockDescriptor["_devices"] = [] + mockDescriptor["_mockResponsesPerDevice"] = {} + mockDescriptor["_mockResponsesPerDeviceOnce"] = {} + }) + + describe("addKompakt", () => { + test("adds a new kompakt device", () => { + const devicePath = "/dev/ttyUSB0" + const serialNumber = "123456" + mockDescriptor.addKompakt({ path: devicePath, serialNumber }) + + const devices = getMockedDevices() + expect(devices).toHaveLength(1) + expect(devices[0]).toMatchObject({ + path, + serialNumber, + manufacturer: "Mudita", + }) + }) + + test("does not add a duplicate device", () => { + const device = { path: "/dev/ttyUSB0", serialNumber: "123456" } + mockDescriptor.addKompakt(device) + mockDescriptor.addKompakt(device) + + const devices = getMockedDevices() + expect(devices).toHaveLength(1) + }) + }) + + describe("removeDevice", () => { + test("removes a device by path", () => { + const device = { path: "/dev/ttyUSB0", serialNumber: "123456" } + mockDescriptor.addKompakt(device) + + mockDescriptor.removeDevice("/dev/ttyUSB0") + const devices = getMockedDevices() + expect(devices).toHaveLength(0) + }) + }) + + describe("addResponse and getResponse", () => { + test("adds and retrieves a response for a device", () => { + const response: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "value" }, + } + mockDescriptor.addResponse(response) + + const result = mockDescriptor.getResponse(path, endpoint, method, {}) + expect(result).toEqual({ status: 200, body: { key: "value" } }) + }) + + test("adds and retrieves a response with matching data", () => { + const response: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "value" }, + match: { expected: { key: "value" } }, + } + mockDescriptor.addResponse(response) + + const result = mockDescriptor.getResponse(path, endpoint, method, { + key: "value", + }) + expect(result).toEqual({ status: 200, body: { key: "value" } }) + }) + + test("adds a new response and filters out previous one without match", () => { + const firstResponse: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "firstValue" }, + match: undefined, + } + mockDescriptor.addResponse(firstResponse) + + const secondResponse: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "secondValue" }, + match: { expected: { key: "secondValue" } }, + } + mockDescriptor.addResponse(secondResponse) + + const result = mockDescriptor.getResponse(path, endpoint, method, { + key: "secondValue", + }) + expect(result).toEqual({ status: 200, body: { key: "secondValue" } }) + }) + + test("does not retrieve a response if match does not pass", () => { + const response: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "value" }, + match: { expected: { key: "notValue" } }, + } + mockDescriptor.addResponse(response) + + const result = mockDescriptor.getResponse(path, endpoint, method, { + key: "otherValue", + }) + expect(result).toEqual(DEFAULT_RESPONSES[endpoint]?.[method]?.[0]) + }) + + test("includes the response without match if it's the last one added", () => { + const firstResponse: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "firstValue" }, + match: undefined, + } + mockDescriptor.addResponse(firstResponse) + + const secondResponse: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { key: "secondValue" }, + match: undefined, + } + mockDescriptor.addResponse(secondResponse) + + const result = mockDescriptor.getResponse(path, endpoint, method, { + key: "secondValue", + }) + expect(result).toEqual({ status: 200, body: { key: "secondValue" } }) + }) + + test("returns default response if no custom response exists", () => { + const result = mockDescriptor.getResponse(path, endpoint, method, {}) + expect(result).toEqual(DEFAULT_RESPONSES[endpoint]?.[method]?.[0]) + }) + }) + + describe("ddResponseOnce and getResponse", () => { + test("adds and retrieves a one-time response with matching data", () => { + const response: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { once: true, key: "value" }, + match: { expected: { key: "value" } }, + } + mockDescriptor.addResponseOnce(response) + + const firstResult = mockDescriptor.getResponse(path, endpoint, method, { + key: "value", + }) + expect(firstResult).toEqual({ + status: 200, + body: { once: true, key: "value" }, + }) + + const secondResult = mockDescriptor.getResponse(path, endpoint, method, { + key: "value", + }) + expect(secondResult).toEqual(DEFAULT_RESPONSES[endpoint]?.[method]?.[0]) + }) + + test("does not retrieve a one-time response if match does not pass", () => { + const response: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { once: true, key: "value" }, + match: { expected: { key: "notValue" } }, + } + mockDescriptor.addResponseOnce(response) + + const result = mockDescriptor.getResponse(path, endpoint, method, { + key: "otherValue", + }) + expect(result).toEqual(DEFAULT_RESPONSES[endpoint]?.[method]?.[0]) + }) + }) + + describe("addResponseOnce", () => { + test("adds a one-time response and removes it after retrieval", () => { + const response: AddKompaktResponse = { + path, + endpoint, + method, + status: 200, + body: { once: true }, + } + mockDescriptor.addResponseOnce(response) + + const firstResult = mockDescriptor.getResponse(path, endpoint, method, {}) + expect(firstResult).toEqual({ status: 200, body: { once: true } }) + + const secondResult = mockDescriptor.getResponse( + path, + endpoint, + method, + {} + ) + expect(secondResult).toEqual(DEFAULT_RESPONSES[endpoint]?.[method]?.[0]) + }) + }) + + describe("getResponse fallback to default", () => { + test("returns default response if no per-device response exists", () => { + const result = mockDescriptor.getResponse( + "non-existing-path", + endpoint, + method, + {} + ) + expect(result).toEqual(DEFAULT_RESPONSES[endpoint]?.[method]?.[0]) + }) + }) +}) diff --git a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts index 9c376ea158..4dbe5c3e18 100644 --- a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts +++ b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts @@ -3,7 +3,7 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { findIndex, pullAt, find, merge } from "lodash" +import { find, findIndex, merge, pullAt } from "lodash" import { PortInfo } from "serialport" import { AddKompakt, @@ -11,8 +11,8 @@ import { RestoreDefaultResponses, } from "./mock-descriptor-validators" import { - ApiResponseWithConfig, ApiResponsesWithConfigArray, + ApiResponseWithConfig, DEFAULT_RESPONSES, MocksArrayResponsesMap, } from "e2e-mock-responses" @@ -66,7 +66,7 @@ class MockDescriptor { this._mockResponsesPerDevice[path]?.[endpoint]?.[method] ?? [] const filteredResponses = currentResponses.filter((item) => { - if (match?.options?.id === item.match?.options?.id) { + if (item.match === undefined) { return false } return true @@ -120,7 +120,7 @@ class MockDescriptor { this._mockResponsesPerDevice[path]?.[endpoint]?.[method] ?? [] const filteredResponses = currentResponses.filter((item) => { - if (match?.options?.id === item.match?.options?.id) { + if (item.match === undefined) { return false } return true @@ -205,9 +205,11 @@ class MockDescriptor { method, responses: perDeviceOnceResponses, }) - return merge( - foundResponse.response, - this.fillEndpointSpecificFields(endpoint, method, body) + return this.mapResponseWithoutMatch( + merge( + foundResponse.response, + this.fillEndpointSpecificFields(endpoint, method, body) + ) ) } } @@ -241,15 +243,32 @@ class MockDescriptor { const foundResponse = this.findResponse(perDeviceResponses, body) if (foundResponse) { - return merge( - foundResponse.response, - this.fillEndpointSpecificFields(endpoint, method, body) + return this.mapResponseWithoutMatch( + merge( + foundResponse.response, + this.fillEndpointSpecificFields(endpoint, method, body) + ) ) } } return undefined } + private getDefaultResponse( + endpoint: APIEndpointType, + method: APIMethodsType, + body: Record | undefined + ): ApiResponse | undefined { + const perDeviceResponses = DEFAULT_RESPONSES[endpoint]?.[method] + if (perDeviceResponses !== undefined) { + const foundResponse = this.findResponse(perDeviceResponses, body) + if (foundResponse) { + return this.mapResponseWithoutMatch(foundResponse.response) + } + } + return undefined + } + public getResponse( path: string, endpoint: APIEndpointType, @@ -271,11 +290,17 @@ class MockDescriptor { return response } - const defaultResponse: ApiResponse | undefined = - DEFAULT_RESPONSES[endpoint]?.[method] + const defaultResponse = this.getDefaultResponse(endpoint, method, body) return defaultResponse } + + private mapResponseWithoutMatch({ + match, + ...response + }: ApiResponseWithConfig): ApiResponse { + return response + } } export const mockDescriptor = new MockDescriptor()