Skip to content

Commit

Permalink
fix: updated all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kiremitrov123 committed Mar 23, 2023
1 parent b238fa3 commit 5077dad
Show file tree
Hide file tree
Showing 20 changed files with 1,183 additions and 1,177 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"lint:ts": "tsc --pretty --noEmit -p .",
"lint:stylelint": "stylelint '**/*.{css,scss}'",
"commit-msg": "commitlint --edit $1",
"codecept:mobile": "cd test-e2e && rm -rf \"./output/mobile\" && codeceptjs --config ./codecept.mobile.js run-workers --suites ${WORKER_COUNT:=8} ",
"codecept:desktop": "cd test-e2e && rm -rf \"./output/desktop\" && codeceptjs --config ./codecept.desktop.js run-workers --suites ${WORKER_COUNT:=8} ",
"codecept:mobile": "cd test-e2e && rm -rf \"./output/mobile\" && codeceptjs --config ./codecept.mobile.js run-workers --suites ${WORKER_COUNT:=1} ",
"codecept:desktop": "cd test-e2e && rm -rf \"./output/desktop\" && codeceptjs --config ./codecept.desktop.js run-workers --suites ${WORKER_COUNT:=1} ",
"serve-report:mobile": "cd test-e2e && allure serve \"./output/mobile\"",
"serve-report:desktop": "cd test-e2e && allure serve \"./output/desktop\"",
"codecept-serve:mobile": "yarn codecept:mobile ; yarn serve-report:mobile",
Expand Down
2 changes: 1 addition & 1 deletion src/components/PaymentForm/PaymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const PaymentForm: React.FC<Props> = ({ couponCode, setUpdatingOrder }) => {
</div>
</div>
<div>
<Button label="continue" variant="contained" color="primary" onClick={paymentData.handleSubmit as () => void} size="large" fullWidth />
<Button label="Continue" variant="contained" color="primary" onClick={paymentData.handleSubmit as () => void} size="large" fullWidth />
</div>
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/en_US/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,9 @@
"back_to_profile": "Back to profile",
"message": "You have been successfully resubscribed. Your fee will be {{price}} starting from {{date}}",
"title": "Your subscription has been renewed"
},
"validation": {
"first_name": "firstName can have max 50 characters.",
"last_name": "lastName can have max 50 characters."
}
}
4 changes: 4 additions & 0 deletions src/i18n/locales/nl_NL/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,9 @@
"back_to_profile": "",
"message": "",
"title": ""
},
"validation": {
"first_name": "",
"last_name": ""
}
}
2 changes: 1 addition & 1 deletion src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ function formatPublisherConsents(consent: Partial<GetRegisterField>) {
}

function getTermsConsent(): Consent {
const label = 'I accept the <a href="https://inplayer.com/legal/terms" target="_blank">Terms and Conditions</a> of InPlayer.';
const label = 'I accept the <a href="https://inplayer.com/legal/terms" target="_blank">Terms and Conditions</a> of JW Player.';
return formatPublisherConsents({
required: true,
name: 'terms',
Expand Down
6 changes: 3 additions & 3 deletions src/services/inplayer.subscription.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getActiveSubscription({ config }: { config: Config }) {
const activeSubscription = data.collection.find((subscription: SubscriptionDetails) => subscription.item_id === assetId);

if (activeSubscription) {
return formatActiveSubscription(activeSubscription);
return formatActiveSubscription(activeSubscription, hasAccess?.data?.expires_at);
}

return formatGrantedSubscription(hasAccess.data);
Expand Down Expand Up @@ -138,7 +138,7 @@ const formatTransaction = (transaction: InPlayerPurchaseDetails): Transaction =>
};
};

const formatActiveSubscription = (subscription: SubscriptionDetails) => {
const formatActiveSubscription = (subscription: SubscriptionDetails, expiresAt: number) => {
let status = '';
switch (subscription.action_type) {
case 'free-trial':
Expand All @@ -159,7 +159,7 @@ const formatActiveSubscription = (subscription: SubscriptionDetails) => {
subscriptionId: subscription.subscription_id,
offerId: subscription.item_id?.toString(),
status,
expiresAt: subscription.next_rebill_date,
expiresAt,
nextPaymentAt: subscription.next_rebill_date,
nextPaymentPrice: subscription.subscription_price,
nextPaymentCurrency: subscription.currency,
Expand Down
6 changes: 4 additions & 2 deletions src/stores/AccountController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import jwtDecode from 'jwt-decode';
import i18next from 'i18next';

import { useFavoritesStore } from '#src/stores/FavoritesStore';
import { useWatchHistoryStore } from '#src/stores/WatchHistoryStore';
Expand Down Expand Up @@ -139,6 +140,7 @@ export async function updateUser(values: FirstLastNameInput | EmailConfirmPasswo
}

let payload = values;
// this is needed as a fallback when the name is empty (cannot be empty on JWP integration)
if (!accountService.canSupportEmptyFullName) {
payload = { ...values, email: user.email };
}
Expand Down Expand Up @@ -491,10 +493,10 @@ async function afterLogin(
const validateInputLength = (values: { firstName: string; lastName: string }) => {
const errors: string[] = [];
if (Number(values?.firstName?.length) > 50) {
errors.push('firstName can have max 50 characters.');
errors.push(i18next.t('account:validation.first_name'));
}
if (Number(values?.lastName?.length) > 50) {
errors.push('lastName can have max 50 characters.');
errors.push(i18next.t('account:validation.last_name'));
}

return errors;
Expand Down
2 changes: 1 addition & 1 deletion src/stores/NotificationsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const subscribeToNotifications = async (uuid: string = '') => {
break;
case NotificationsTypes.ACCESS_GRANTED:
await reloadActiveSubscription();
window.location.href = addQueryParams(window.location.origin, { u: 'welcome' });
window.location.href = addQueryParams(window.location.href, { u: 'welcome' });
break;
case NotificationsTypes.ACCESS_REVOKED:
await reloadActiveSubscription();
Expand Down
4 changes: 2 additions & 2 deletions test-e2e/codecept.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ setHeadlessWhen(process.env.HEADLESS);

exports.config = {
grep: '(?=.*)^(?!.*@mobile-only)',
tests: ['./tests/**/*.js', './tests/account_test.ts'],
tests: ['./tests/**/*.js', './tests/payments/subscription_test.ts'],
output: './output/desktop',
timeout: 3000,
helpers: {
Playwright: {
url: 'http://localhost:8080',
show: true,
show: !!process.env.SHOW,
channel: 'chrome',
locale: 'en-US',
},
Expand Down
Loading

0 comments on commit 5077dad

Please sign in to comment.