fix: remove edx keyword from tests (#698)

This commit is contained in:
Zainab Amir
2022-12-12 21:23:12 +05:00
committed by GitHub
parent 5af93a57c7
commit 5bfdd8e1ef
11 changed files with 25 additions and 30 deletions

View File

@@ -39,7 +39,7 @@ describe('Logistration', () => {
);
beforeEach(() => {
auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'edX' }));
auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'test-user' }));
});
it('should render registration page', () => {
configure({

View File

@@ -1,5 +1,6 @@
import React from 'react';
import { getConfig } from '@edx/frontend-platform';
import { mount } from 'enzyme';
import FieldRenderer from '../FieldRenderer';
@@ -82,7 +83,7 @@ describe('FieldRendererTests', () => {
it('should render checkbox field', () => {
const fieldData = {
type: 'checkbox',
label: 'I agree that edX may send me marketing messages.',
label: `I agree that ${getConfig().SITE_NAME} may send me marketing messages.`,
name: 'marketing-emails-opt-in-field',
};
@@ -91,7 +92,7 @@ describe('FieldRendererTests', () => {
field.simulate('change', { target: { checked: true, type: 'checkbox' } });
expect(field.prop('type')).toEqual('checkbox');
expect(fieldRenderer.find('label').text()).toEqual('I agree that edX may send me marketing messages.');
expect(fieldRenderer.find('label').text()).toEqual(fieldData.label);
expect(value).toEqual(true);
});

View File

@@ -51,7 +51,7 @@ describe('ForgotPasswordPage', () => {
beforeEach(() => {
store = mockStore(initialState);
auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'edX' }));
auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'test-user' }));
configure({
loggingService: { logError: jest.fn() },
config: {

View File

@@ -104,11 +104,6 @@ const messages = defineMessages({
defaultMessage: 'First time here?',
description: 'A question that appears before sign up link',
},
'email.help.message': {
id: 'email.help.message',
defaultMessage: 'The email address you used to register with edX.',
description: 'Message that appears below email field on login page',
},
'enterprise.login.btn.text': {
id: 'enterprise.login.btn.text',
defaultMessage: 'Company or school credentials',

View File

@@ -64,7 +64,7 @@ describe('LoginFailureMessage', () => {
errorCode: INACTIVE_USER,
context: {
platformName: 'openedX',
supportLink: 'https://support.edx.org/',
supportLink: 'http://support.openedx.test',
},
},
};
@@ -80,7 +80,7 @@ describe('LoginFailureMessage', () => {
+ 'check your spam folders or contact openedX support.';
expect(loginFailureMessage.find('#login-failure-alert').first().text()).toEqual(expectedMessage);
expect(loginFailureMessage.find('#login-failure-alert').find('a').props().href).toEqual('https://support.edx.org/');
expect(loginFailureMessage.find('#login-failure-alert').find('a').props().href).toEqual('http://support.openedx.test');
});
it('test match failed login attempt error', () => {
@@ -269,7 +269,7 @@ describe('LoginFailureMessage', () => {
email: 'text@example.com',
errorCode: ALLOWED_DOMAIN_LOGIN_ERROR,
context: {
allowedDomain: 'edx.org',
allowedDomain: 'test.com',
provider: 'Google',
tpaHint: 'google-auth2',
},
@@ -282,7 +282,7 @@ describe('LoginFailureMessage', () => {
</IntlProvider>,
);
const errorMessage = "We couldn't sign you in.As edx.org user, You must login with your edx.org Google account.";
const errorMessage = "We couldn't sign you in.As test.com user, You must login with your test.com Google account.";
const url = 'http://localhost:18000/dashboard/?tpa_hint=google-auth2';
expect(loginFailureMessage.find('#login-failure-alert').first().text()).toEqual(errorMessage);

View File

@@ -73,7 +73,7 @@ describe('LoginPage', () => {
id: 'oa2-apple-id',
name: 'Apple',
iconClass: null,
iconImage: 'https://edx.devstack.lms/logo.png',
iconImage: 'https://openedx.devstack.lms/logo.png',
loginUrl: '/auth/login/apple-id/?auth_entry=login&next=/dashboard',
};
@@ -272,7 +272,7 @@ describe('LoginPage', () => {
thirdPartyAuthContext: {
...initialState.commonComponents.thirdPartyAuthContext,
currentProvider: 'Apple',
platformName: 'edX',
platformName: 'openedX',
},
},
});

View File

@@ -214,11 +214,6 @@ const messages = defineMessages({
defaultMessage: 'Gender (optional)',
description: 'Placeholder for the gender options dropdown',
},
'registration.goals.label': {
id: 'registration.goals.label',
defaultMessage: 'Tell us why you\'re interested in edX (optional)',
description: 'Placeholder for the goals options dropdown',
},
'registration.field.gender.options.f': {
id: 'registration.field.gender.options.f',
defaultMessage: 'Female',

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mergeConfig } from '@edx/frontend-platform';
import { getConfig, mergeConfig } from '@edx/frontend-platform';
import { injectIntl, IntlProvider } from '@edx/frontend-platform/i18n';
import { mount } from 'enzyme';
@@ -24,12 +24,16 @@ describe('HonorCodeTest', () => {
});
it('should render error msg if honor code is not checked', () => {
const errorMessage = `You must agree to the ${getConfig().SITE_NAME} Honor Code`;
const honorCode = mount(
<IntlProvider locale="en">
<IntlHonorCode errorMessage="You must agree to the edx Honor Code" onChangeHandler={changeHandler} />
<IntlHonorCode
errorMessage={errorMessage}
onChangeHandler={changeHandler}
/>
</IntlProvider>,
);
expect(honorCode.find('.form-text-size').last().text()).toEqual('You must agree to the edx Honor Code');
expect(honorCode.find('.form-text-size').last().text()).toEqual(errorMessage);
});
it('should render Honor code field', () => {

View File

@@ -142,7 +142,7 @@ describe('RegistrationPage', () => {
id: 'oa2-apple-id',
name: 'Apple',
iconClass: null,
iconImage: 'https://edx.devstack.lms/logo.png',
iconImage: 'https://openedx.devstack.lms/logo.png',
loginUrl: '/auth/login/apple-id/?auth_entry=login&next=/dashboard',
};
@@ -337,9 +337,9 @@ describe('RegistrationPage', () => {
it('should remove space from the start of username', () => {
const registrationPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
registrationPage.find('input#username').simulate('change', { target: { value: ' edX', name: 'username' } });
registrationPage.find('input#username').simulate('change', { target: { value: ' test-user', name: 'username' } });
expect(registrationPage.find('input#username').prop('value')).toEqual('edX');
expect(registrationPage.find('input#username').prop('value')).toEqual('test-user');
});
// ******** test field focus in functionality ********

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mergeConfig } from '@edx/frontend-platform';
import { getConfig, mergeConfig } from '@edx/frontend-platform';
import { injectIntl, IntlProvider } from '@edx/frontend-platform/i18n';
import { mount } from 'enzyme';
@@ -23,7 +23,7 @@ describe('TermsOfServiceTest', () => {
});
it('should render error msg if Terms of Service checkbox is not checked', () => {
const errorMessage = 'You must agree to the edx Terms of Service';
const errorMessage = `You must agree to the ${getConfig().SITE_NAME} Terms of Service`;
const termsOfService = mount(
<IntlProvider locale="en">
<IntlTermsOfService errorMessage={errorMessage} onChangeHandler={changeHandler} />

View File

@@ -103,12 +103,12 @@ describe('ProgressiveProfilingTests', () => {
auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, username: 'abc123' }));
const formPayload = {
gender: 'm',
extended_profile: [{ field_name: 'company', field_value: 'edx' }],
extended_profile: [{ field_name: 'company', field_value: 'test company' }],
};
store.dispatch = jest.fn(store.dispatch);
const progressiveProfilingPage = await getProgressiveProfilingPage();
progressiveProfilingPage.find('select#gender').simulate('change', { target: { value: 'm', name: 'gender' } });
progressiveProfilingPage.find('input#company').simulate('change', { target: { value: 'edx', name: 'company' } });
progressiveProfilingPage.find('input#company').simulate('change', { target: { value: 'test company', name: 'company' } });
progressiveProfilingPage.find('button.btn-brand').simulate('click');
expect(store.dispatch).toHaveBeenCalledWith(saveUserProfile('abc123', formPayload));