Skip to content

Commit

Permalink
Merge commit '6278447e220ee09d5bb9d4e9bb5f1af80893a71d' into upload-v…
Browse files Browse the repository at this point in the history
…ia-link-sm-v2-staging
  • Loading branch information
future-pirate-king committed Jun 5, 2024
2 parents 75f55f1 + 6278447 commit b3ac244
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/components/upload-app/index.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<UploadApp::ViaSystem />

{{#if this.isCypressOrg}}
{{#if this.urlUploadAllowed}}
<UploadApp::ViaLink />
{{/if}}

Expand Down
7 changes: 0 additions & 7 deletions app/components/upload-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ import Component from '@glimmer/component';
import { inject as service } from '@ember/service';

import ConfigurationService from 'irene/services/configuration';
import OrganizationService from 'irene/services/organization';

export default class UploadAppComponent extends Component {
@service declare configuration: ConfigurationService;
@service declare organization: OrganizationService;

get urlUploadAllowed() {
return this.configuration.serverData.urlUploadAllowed;
}

// TODO: Remove dependency on cypress org when feature is ready for release
get isCypressOrg() {
return this.organization.selected?.name.toLowerCase().includes('cypress');
}
}

declare module '@glint/environment-ember-loose/registry' {
Expand Down
4 changes: 2 additions & 2 deletions app/components/upload-app/via-link/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
</AkTypography>
</li>

<li>
{{! <li>
<AkTypography
@variant='body2'
data-test-uploadAppViaLinkModal-appstoreValidUrl
>
https://apps.apple.com/{country_code}/app/{app_slug}/id{app_id}
</AkTypography>
</li>
</li> }}
</ul>
</AkStack>

Expand Down
18 changes: 2 additions & 16 deletions app/components/upload-app/via-link/validator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const GOOGLE_PLAYSTORE_DOMAIN = 'play.google.com';
const APPLE_APPSTORE_DOMAIN = 'apps.apple.com';
const ERROR_MESSAGE = 'URL should have valid Playstore or Appstore Domain';
const ERROR_MESSAGE = 'Only Google PlayStore URLs are accepted';

export function validateStoreDomain() {
return function (key: string, value: string) {
Expand All @@ -9,9 +8,7 @@ export function validateStoreDomain() {
const url = new URL(value);

return (
[GOOGLE_PLAYSTORE_DOMAIN, APPLE_APPSTORE_DOMAIN].includes(
url.hostname
) || ERROR_MESSAGE
[GOOGLE_PLAYSTORE_DOMAIN].includes(url.hostname) || ERROR_MESSAGE
);
} catch {
return ERROR_MESSAGE;
Expand Down Expand Up @@ -40,17 +37,6 @@ export function validateStorePathname() {
return 'Playstore url should be valid, the expected format is : https://play.google.com/store/apps/details?id={package_name}';
}
}

if (url.host === APPLE_APPSTORE_DOMAIN) {
const appStoreRegex = /^\/([^/]+)\/app\/[^/]+\/id([^/]+)$/;
const match = url.pathname.match(appStoreRegex);

if (match) {
return true;
} else {
return 'Appstore url should be valid, the expected format is : https://apps.apple.com/{country_code}/app/{app_slug}/id{app_id}';
}
}
}
} catch {
return ERROR_MESSAGE;
Expand Down
21 changes: 6 additions & 15 deletions tests/integration/components/upload-app/via-link-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ module('Integration | Component | upload-app/via-link', function (hooks) {
.dom('[data-test-uploadAppViaLinkModal-playstoreValidUrl]')
.hasText('https://play.google.com/store/apps/details?id={package_name}');

assert
.dom('[data-test-uploadAppViaLinkModal-appstoreValidUrl]')
.hasText(
'https://apps.apple.com/{country_code}/app/{app_slug}/id{app_id}'
);

assert
.dom('[data-test-uploadAppViaLinkModal-confirmBtn]')
.isDisabled()
Expand All @@ -92,19 +86,16 @@ module('Integration | Component | upload-app/via-link', function (hooks) {
test.each(
'test upload app via link validation',
[
['test', 'URL should have valid Playstore or Appstore Domain'],
[
'https://example.com',
'URL should have valid Playstore or Appstore Domain',
],
['test', 'Only Google PlayStore URLs are accepted'],
['https://example.com', 'Only Google PlayStore URLs are accepted'],
[
'https://play.google.com/store/apps/details',
'Playstore url should be valid, the expected format is : https://play.google.com/store/apps/details?id={package_name}',
],
[
'https://apps.apple.com/in/app/example/i',
'Appstore url should be valid, the expected format is : https://apps.apple.com/{country_code}/app/{app_slug}/id{app_id}',
],
// [
// 'https://apps.apple.com/in/app/example/i',
// 'Appstore url should be valid, the expected format is : https://apps.apple.com/{country_code}/app/{app_slug}/id{app_id}',
// ],
],
async function (assert, [storeUrl, errorMessage]) {
await render(hbs`<UploadApp::ViaLink />`);
Expand Down
6 changes: 3 additions & 3 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1342,11 +1342,11 @@
"uploadAppModule": {
"linkPastePlaceholder": "Paste the link here...",
"viaLink": "Via Link",
"supportedStores": "Supported Stores",
"stores": "Google Play Store and Apple App Store",
"supportedStores": "Supported Store",
"stores": "Google Play Store",
"linkUploadPopupHeader": "Upload using a link",
"linkInputLabel": "Add a link",
"validURLFormatTitle": "Valid URL Formats :"
"validURLFormatTitle": "Valid URL Format :"
},
"uploadCount": "Upload Count",
"uploadStatus": "Upload Status",
Expand Down
6 changes: 3 additions & 3 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1342,11 +1342,11 @@
"uploadAppModule": {
"linkPastePlaceholder": "Paste the link here...",
"viaLink": "Via Link",
"supportedStores": "Supported Stores",
"stores": "Google Play Store and Apple App Store",
"supportedStores": "Supported Store",
"stores": "Google Play Store",
"linkUploadPopupHeader": "Upload using a link",
"linkInputLabel": "Add a link",
"validURLFormatTitle": "Valid URL Formats :"
"validURLFormatTitle": "Valid URL Format :"
},
"uploadCount": "Upload Count",
"uploadStatus": "Upload Status",
Expand Down

0 comments on commit b3ac244

Please sign in to comment.