diff --git a/src/frontend/js/components/SaleTunnel/SaleTunnelInformation/index.tsx b/src/frontend/js/components/SaleTunnel/SaleTunnelInformation/index.tsx index 349cb24396..b69742efca 100644 --- a/src/frontend/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +++ b/src/frontend/js/components/SaleTunnel/SaleTunnelInformation/index.tsx @@ -1,68 +1,76 @@ -import { useState } from 'react'; -import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; -import { Select } from '@openfun/cunningham-react'; -import { useSaleTunnelContext } from 'components/SaleTunnel/GenericSaleTunnel'; -import { SaleTunnelInformationSingular } from 'components/SaleTunnel/SaleTunnelInformation/SaleTunnelInformationSingular'; -import { SaleTunnelInformationGroup } from 'components/SaleTunnel/SaleTunnelInformation/SaleTunnelInformationGroup'; +import { SaleTunnelInformationSingular } from './SaleTunnelInformationSingular'; -const messages = defineMessages({ - purchaseTypeTitle: { - id: 'components.SaleTunnel.Information.purchaseTypeTitle', - description: 'Title for purchase type', - defaultMessage: 'Select purchase type', - }, - purchaseTypeSelect: { - id: 'components.SaleTunnel.Information.purchaseTypeSelect', - description: 'Label for purchase type select', - defaultMessage: 'Purchase type', - }, - purchaseTypeOptionSingle: { - id: 'components.SaleTunnel.Information.purchaseTypeOptionSingle', - description: 'Label for B2C option', - defaultMessage: 'Single purchase (B2C)', - }, - purchaseTypeOptionGroup: { - id: 'components.SaleTunnel.Information.purchaseTypeOptionGroup', - description: 'Label for B2C option', - defaultMessage: 'Group purchase (B2B)', - }, -}); +export const SaleTunnelInformation = () => ( +
+ +
+); -export enum FormType { - GROUP = 'group', - SINGULAR = 'singular', -} - -export const SaleTunnelInformation = () => { - const intl = useIntl(); - const { setBatchOrder, setSchedule } = useSaleTunnelContext(); - const options = [ - { label: intl.formatMessage(messages.purchaseTypeOptionSingle), value: FormType.SINGULAR }, - { label: intl.formatMessage(messages.purchaseTypeOptionGroup), value: FormType.GROUP }, - ]; - const [purchaseType, setPurchaseType] = useState(FormType.SINGULAR); - - return ( -
-
-

- -

- { +// setPurchaseType(e.target.value as FormType); +// setBatchOrder(undefined); +// setSchedule(undefined); +// }} +// /> +//
+// {purchaseType === FormType.SINGULAR && } +// {purchaseType === FormType.GROUP && } +//
+// ); +// }; diff --git a/src/frontend/js/components/SaleTunnel/index.full-process-b2b.spec.tsx b/src/frontend/js/components/SaleTunnel/index.full-process-b2b.spec.tsx index 12183af956..6351bd7d20 100644 --- a/src/frontend/js/components/SaleTunnel/index.full-process-b2b.spec.tsx +++ b/src/frontend/js/components/SaleTunnel/index.full-process-b2b.spec.tsx @@ -1,30 +1,30 @@ -import { screen, within } from '@testing-library/react'; +// import { screen, within } from '@testing-library/react'; import fetchMock from 'fetch-mock'; -import queryString from 'query-string'; -import userEvent from '@testing-library/user-event'; +// import queryString from 'query-string'; +// import userEvent from '@testing-library/user-event'; import { RichieContextFactory as mockRichieContextFactory, - PacedCourseFactory, + // PacedCourseFactory, UserFactory, } from 'utils/test/factories/richie'; -import { render } from 'utils/test/render'; +// import { render } from 'utils/test/render'; import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper'; -import CourseProductItem from 'widgets/SyllabusCourseRunsList/components/CourseProductItem'; -import { - OfferingFactory, - PaymentPlanFactory, - ProductFactory, - OfferingBatchOrderFactory, - BatchOrderReadFactory, - CredentialOrderFactory, -} from 'utils/test/factories/joanie'; -import { CourseRun, NOT_CANCELED_ORDER_STATES, OrderState } from 'types/Joanie'; -import { Priority } from 'types'; -import { expectMenuToBeClosed, expectMenuToBeOpen } from 'utils/test/Cunningham'; +// import CourseProductItem from 'widgets/SyllabusCourseRunsList/components/CourseProductItem'; +// import { +// OfferingFactory, +// PaymentPlanFactory, +// ProductFactory, +// OfferingBatchOrderFactory, +// BatchOrderReadFactory, +// CredentialOrderFactory, +// } from 'utils/test/factories/joanie'; +// import { CourseRun, NOT_CANCELED_ORDER_STATES, OrderState } from 'types/Joanie'; +// import { Priority } from 'types'; +// import { expectMenuToBeClosed, expectMenuToBeOpen } from 'utils/test/Cunningham'; import { OpenEdxApiProfileFactory } from 'utils/test/factories/openEdx'; import { User } from 'types/User'; import { OpenEdxApiProfile } from 'types/openEdx'; -import { createTestQueryClient } from 'utils/test/createTestQueryClient'; +// import { createTestQueryClient } from 'utils/test/createTestQueryClient'; jest.mock('utils/context', () => ({ __esModule: true, @@ -49,10 +49,10 @@ describe('SaleTunnel', () => { let openApiEdxProfile: OpenEdxApiProfile; setupJoanieSession(); - const formatPrice = (currency: string, price: number) => - new Intl.NumberFormat('en', { currency, style: 'currency' }) - .format(price) - .replace(/(\u202F|\u00a0)/g, ' '); + // const formatPrice = (currency: string, price: number) => + // new Intl.NumberFormat('en', { currency, style: 'currency' }) + // .format(price) + // .replace(/(\u202F|\u00a0)/g, ' '); beforeEach(() => { richieUser = UserFactory().one(); @@ -78,279 +78,260 @@ describe('SaleTunnel', () => { afterEach(() => fetchMock.reset()); it('tests the entire process of subscribing to a batch order', async () => { - const course = PacedCourseFactory().one(); - const product = ProductFactory().one(); - const offering = OfferingFactory({ course, product, is_withdrawable: false }).one(); - const paymentPlan = PaymentPlanFactory().one(); - const offeringOrganization = OfferingBatchOrderFactory({ - product: { id: product.id, title: product.title }, - }).one(); - - fetchMock.get( - `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/`, - offering, - ); - fetchMock.get( - `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/`, - paymentPlan, - ); - fetchMock.get(`https://joanie.endpoint/api/v1.0/enrollments/`, []); - fetchMock.get( - `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify({ - product_id: product.id, - course_code: course.code, - state: NOT_CANCELED_ORDER_STATES, - })}`, - [], - ); - fetchMock.get( - `https://joanie.endpoint/api/v1.0/offerings/${offering.id}/get-organizations/`, - offeringOrganization, - ); - - render(, { - queryOptions: { client: createTestQueryClient({ user: richieUser }) }, - }); - - // Verify product info - await screen.findByRole('heading', { level: 3, name: product.title }); - await screen.findByText(formatPrice(product.price_currency, product.price)); - expect(screen.queryByText('Purchased')).not.toBeInTheDocument(); - - const user = userEvent.setup(); - const buyButton = screen.getByRole('button', { name: product.call_to_action }); - - expect(screen.queryByTestId('generic-sale-tunnel-payment-step')).not.toBeInTheDocument(); - await user.click(buyButton); - await screen.findByTestId('generic-sale-tunnel-payment-step'); - - // Verify learning path - await screen.findByText('Your learning path'); - const targetCourses = await screen.findAllByTestId('product-target-course'); - expect(targetCourses).toHaveLength(product.target_courses.length); - targetCourses.forEach((targetCourse, index) => { - const courseItem = product.target_courses[index]; - const courseDetail = within(targetCourse).getByTestId( - `target-course-detail-${courseItem.code}`, - ); - const summary = courseDetail.querySelector('summary')!; - expect(summary).toHaveTextContent(courseItem.title); - - const courseRuns = targetCourse.querySelectorAll( - '.product-detail-row__course-run-dates__item', - ); - const openedCourseRuns = courseItem.course_runs.filter( - (cr: CourseRun) => cr.state.priority <= Priority.FUTURE_NOT_YET_OPEN, - ); - expect(courseRuns).toHaveLength(openedCourseRuns.length); - }); - - // Select group buy form - await screen.findByText('Purchase type'); - const formTypeSelect = screen.getByRole('combobox', { name: 'Purchase type' }); - const menu: HTMLDivElement = screen.getByRole('listbox', { name: 'Purchase type' }); - expectMenuToBeClosed(menu); - await user.click(formTypeSelect); - expectMenuToBeOpen(menu); - await user.click(screen.getByText('Group purchase (B2B)')); - - // Company step - const $companyName = await screen.findByRole('textbox', { name: 'Company name' }); - const $idNumber = screen.getByRole('textbox', { name: /Identification number/ }); - const $address = screen.getByRole('textbox', { name: 'Address' }); - const $postCode = screen.getByRole('textbox', { name: 'Post code' }); - const $city = screen.getByRole('textbox', { name: 'City' }); - const $country = screen.getByRole('combobox', { name: 'Country' }); - - await user.type($companyName, 'GIP-FUN'); - await user.type($idNumber, '789 242 229 01694'); - await user.type($address, '61 Bis Rue de la Glaciere'); - await user.type($postCode, '75013'); - await user.type($city, 'Paris'); - - const countryMenu: HTMLDivElement = screen.getByRole('listbox', { name: 'Country' }); - await user.click($country); - expectMenuToBeOpen(countryMenu); - await user.click(screen.getByText('France')); - - expect($companyName).toHaveValue('GIP-FUN'); - const visibleValue = $country.querySelector('.c__select__inner__value span'); - expect(visibleValue!.textContent).toBe('France'); - - // Follow-up step - await user.click(screen.getByRole('button', { name: 'Next' })); - const $lastName = await screen.findByRole('textbox', { name: 'Last name' }); - const $firstName = screen.getByRole('textbox', { name: 'First name' }); - const $role = screen.getByRole('textbox', { name: 'Role' }); - const $email = screen.getByRole('textbox', { name: 'Email' }); - const $phone = screen.getByRole('textbox', { name: 'Phone' }); - - await user.type($lastName, 'Doe'); - await user.type($firstName, 'John'); - await user.type($role, 'HR'); - await user.type($email, 'john.doe@fun-mooc.com'); - await user.type($phone, '+338203920103'); - - expect($lastName).toHaveValue('Doe'); - expect($email).toHaveValue('john.doe@fun-mooc.com'); - - // Signatory step - await user.click(screen.getByRole('button', { name: 'Next' })); - const $signatoryLastName = await screen.findByRole('textbox', { name: 'Last name' }); - const $signatoryFirstName = screen.getByRole('textbox', { name: 'First name' }); - const $signatoryRole = screen.getByRole('textbox', { name: 'Role' }); - const $signatoryEmail = screen.getByRole('textbox', { name: 'Email' }); - const $signatoryPhone = screen.getByRole('textbox', { name: 'Phone' }); - - await user.type($signatoryLastName, 'Doe'); - await user.type($signatoryFirstName, 'John'); - await user.type($signatoryRole, 'CEO'); - await user.type($signatoryEmail, 'john.doe@fun-mooc.com'); - await user.type($signatoryPhone, '+338203920103'); - - // Participants step - await user.click(screen.getByRole('button', { name: 'Next' })); - const $nbParticipants = await screen.findByLabelText('How many participants ?'); - await user.type($nbParticipants, '13'); - expect($nbParticipants).toHaveValue(13); - - // Submit the batch order - const batchOrderRead = BatchOrderReadFactory().one(); - fetchMock.post('https://joanie.endpoint/api/v1.0/batch-orders/', batchOrderRead); - const $subscribebutton = screen.getByRole('button', { - name: `Subscribe`, - }) as HTMLButtonElement; - await user.click($subscribebutton); - await screen.findByTestId('generic-sale-tunnel-success-step'); - screen.getByText('Subscription confirmed!'); - screen.getByText('Your order has been successfully registered.'); - const $dashboardLink = screen.getByRole('link', { name: 'Close' }); - expect($dashboardLink).toHaveAttribute( - 'href', - `/en/dashboard/batch-orders/${batchOrderRead.id}`, - ); + // const course = PacedCourseFactory().one(); + // const product = ProductFactory().one(); + // const offering = OfferingFactory({ course, product, is_withdrawable: false }).one(); + // const paymentPlan = PaymentPlanFactory().one(); + // const offeringOrganization = OfferingBatchOrderFactory({ + // product: { id: product.id, title: product.title }, + // }).one(); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/`, + // offering, + // ); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/`, + // paymentPlan, + // ); + // fetchMock.get(`https://joanie.endpoint/api/v1.0/enrollments/`, []); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify({ + // product_id: product.id, + // course_code: course.code, + // state: NOT_CANCELED_ORDER_STATES, + // })}`, + // [], + // ); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/offerings/${offering.id}/get-organizations/`, + // offeringOrganization, + // ); + // render(, { + // queryOptions: { client: createTestQueryClient({ user: richieUser }) }, + // }); + // // Verify product info + // await screen.findByRole('heading', { level: 3, name: product.title }); + // await screen.findByText(formatPrice(product.price_currency, product.price)); + // expect(screen.queryByText('Purchased')).not.toBeInTheDocument(); + // const user = userEvent.setup(); + // const buyButton = screen.getByRole('button', { name: product.call_to_action }); + // expect(screen.queryByTestId('generic-sale-tunnel-payment-step')).not.toBeInTheDocument(); + // await user.click(buyButton); + // await screen.findByTestId('generic-sale-tunnel-payment-step'); + // // Verify learning path + // await screen.findByText('Your learning path'); + // const targetCourses = await screen.findAllByTestId('product-target-course'); + // expect(targetCourses).toHaveLength(product.target_courses.length); + // targetCourses.forEach((targetCourse, index) => { + // const courseItem = product.target_courses[index]; + // const courseDetail = within(targetCourse).getByTestId( + // `target-course-detail-${courseItem.code}`, + // ); + // const summary = courseDetail.querySelector('summary')!; + // expect(summary).toHaveTextContent(courseItem.title); + // const courseRuns = targetCourse.querySelectorAll( + // '.product-detail-row__course-run-dates__item', + // ); + // const openedCourseRuns = courseItem.course_runs.filter( + // (cr: CourseRun) => cr.state.priority <= Priority.FUTURE_NOT_YET_OPEN, + // ); + // expect(courseRuns).toHaveLength(openedCourseRuns.length); + // }); + // // Select group buy form + // await screen.findByText('Purchase type'); + // const formTypeSelect = screen.getByRole('combobox', { name: 'Purchase type' }); + // const menu: HTMLDivElement = screen.getByRole('listbox', { name: 'Purchase type' }); + // expectMenuToBeClosed(menu); + // await user.click(formTypeSelect); + // expectMenuToBeOpen(menu); + // await user.click(screen.getByText('Group purchase (B2B)')); + // // Company step + // const $companyName = await screen.findByRole('textbox', { name: 'Company name' }); + // const $idNumber = screen.getByRole('textbox', { name: /Identification number/ }); + // const $address = screen.getByRole('textbox', { name: 'Address' }); + // const $postCode = screen.getByRole('textbox', { name: 'Post code' }); + // const $city = screen.getByRole('textbox', { name: 'City' }); + // const $country = screen.getByRole('combobox', { name: 'Country' }); + // await user.type($companyName, 'GIP-FUN'); + // await user.type($idNumber, '789 242 229 01694'); + // await user.type($address, '61 Bis Rue de la Glaciere'); + // await user.type($postCode, '75013'); + // await user.type($city, 'Paris'); + // const countryMenu: HTMLDivElement = screen.getByRole('listbox', { name: 'Country' }); + // await user.click($country); + // expectMenuToBeOpen(countryMenu); + // await user.click(screen.getByText('France')); + // expect($companyName).toHaveValue('GIP-FUN'); + // const visibleValue = $country.querySelector('.c__select__inner__value span'); + // expect(visibleValue!.textContent).toBe('France'); + // // Follow-up step + // await user.click(screen.getByRole('button', { name: 'Next' })); + // const $lastName = await screen.findByRole('textbox', { name: 'Last name' }); + // const $firstName = screen.getByRole('textbox', { name: 'First name' }); + // const $role = screen.getByRole('textbox', { name: 'Role' }); + // const $email = screen.getByRole('textbox', { name: 'Email' }); + // const $phone = screen.getByRole('textbox', { name: 'Phone' }); + // await user.type($lastName, 'Doe'); + // await user.type($firstName, 'John'); + // await user.type($role, 'HR'); + // await user.type($email, 'john.doe@fun-mooc.com'); + // await user.type($phone, '+338203920103'); + // expect($lastName).toHaveValue('Doe'); + // expect($email).toHaveValue('john.doe@fun-mooc.com'); + // // Signatory step + // await user.click(screen.getByRole('button', { name: 'Next' })); + // const $signatoryLastName = await screen.findByRole('textbox', { name: 'Last name' }); + // const $signatoryFirstName = screen.getByRole('textbox', { name: 'First name' }); + // const $signatoryRole = screen.getByRole('textbox', { name: 'Role' }); + // const $signatoryEmail = screen.getByRole('textbox', { name: 'Email' }); + // const $signatoryPhone = screen.getByRole('textbox', { name: 'Phone' }); + // await user.type($signatoryLastName, 'Doe'); + // await user.type($signatoryFirstName, 'John'); + // await user.type($signatoryRole, 'CEO'); + // await user.type($signatoryEmail, 'john.doe@fun-mooc.com'); + // await user.type($signatoryPhone, '+338203920103'); + // // Participants step + // await user.click(screen.getByRole('button', { name: 'Next' })); + // const $nbParticipants = await screen.findByLabelText('How many participants ?'); + // await user.type($nbParticipants, '13'); + // expect($nbParticipants).toHaveValue(13); + // // Submit the batch order + // const batchOrderRead = BatchOrderReadFactory().one(); + // fetchMock.post('https://joanie.endpoint/api/v1.0/batch-orders/', batchOrderRead); + // const $subscribebutton = screen.getByRole('button', { + // name: `Subscribe`, + // }) as HTMLButtonElement; + // await user.click($subscribebutton); + // await screen.findByTestId('generic-sale-tunnel-success-step'); + // screen.getByText('Subscription confirmed!'); + // screen.getByText('Your order has been successfully registered.'); + // const $dashboardLink = screen.getByRole('link', { name: 'Close' }); + // expect($dashboardLink).toHaveAttribute( + // 'href', + // `/en/dashboard/batch-orders/${batchOrderRead.id}`, + // ); }, 30000); - it('tests the entire process of subscribing with a voucher from a batch order', async () => { - /** - * Initialization. - */ - const course = PacedCourseFactory().one(); - const product = ProductFactory().one(); - const offering = OfferingFactory({ - course, - product, - is_withdrawable: false, - }).one(); - const paymentPlan = PaymentPlanFactory().one(); - - fetchMock.get( - `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/`, - offering, - ); - fetchMock.get( - `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/`, - paymentPlan, - ); - fetchMock.get(`https://joanie.endpoint/api/v1.0/enrollments/`, []); - const orderQueryParameters = { - product_id: product.id, - course_code: course.code, - state: NOT_CANCELED_ORDER_STATES, - }; - fetchMock.get( - `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`, - [], - ); - - render(, { - queryOptions: { client: createTestQueryClient({ user: richieUser }) }, - }); - - // Wait for product information to be fetched - await screen.findByRole('heading', { level: 3, name: product.title }); - // Price is displayed, meaning the product is not bought yet. - screen.getByText( - // the price formatter generates non-breaking spaces and getByText doesn't seem to handle that well, replace it - // with a regular space. We replace NNBSP (\u202F) and NBSP (\u00a0) with a regular space - formatPrice(product.price_currency, product.price), - ); - expect(screen.queryByText('Purchased')).not.toBeInTheDocument(); - - /** - * Purchase. - */ - const user = userEvent.setup(); - const buyButton = screen.getByRole('button', { name: product.call_to_action }); - - // The SaleTunnel should not be displayed. - expect(screen.queryByTestId('generic-sale-tunnel-payment-step')).not.toBeInTheDocument(); - - await user.click(buyButton); - - // The SaleTunnel should be displayed. - screen.getByTestId('generic-sale-tunnel-payment-step'); - - /** - * Submit voucher and check price - */ - const paymentPlanVoucher = PaymentPlanFactory({ - discounted_price: 0, - discount: '-100%', - payment_schedule: undefined, - from_batch_order: true, - }).one(); - fetchMock.get( - `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/?voucher_code=DISCOUNT100`, - paymentPlanVoucher, - { overwriteRoutes: true }, - ); - await user.type(screen.getByLabelText('Voucher code'), 'DISCOUNT100'); - await user.click(screen.getByRole('button', { name: 'Validate' })); - expect(screen.queryByRole('heading', { name: 'Payment schedule' })).not.toBeInTheDocument(); - await screen.findByTestId('sale-tunnel__total__amount'); - const $totalAmountVoucher = screen.getByTestId('sale-tunnel__total__amount'); - expect($totalAmountVoucher).toHaveTextContent( - 'Total' + - formatPrice(product.price_currency, paymentPlanVoucher.price!) + - formatPrice(product.price_currency, paymentPlanVoucher.discounted_price!), - ); - - /** - * Make sure the checkbox to waive withdrawal right is not displayed - */ - expect(screen.queryByTestId('withdraw-right-checkbox')).not.toBeInTheDocument(); - - /** - * Subscribe - */ - const order = CredentialOrderFactory({ - state: OrderState.COMPLETED, - payment_schedule: undefined, - }).one(); - fetchMock - .post('https://joanie.endpoint/api/v1.0/orders/', order) - .get( - `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`, - [order], - { overwriteRoutes: true }, - ); - - const $button = screen.getByRole('button', { - name: `Subscribe`, - }) as HTMLButtonElement; - await user.click($button); - - /** - * No withdrawal error should be displayed. - */ - expect( - await screen.queryByText('You must waive your withdrawal right.'), - ).not.toBeInTheDocument(); - - // // Make sure the success step is shown. - await screen.findByTestId('generic-sale-tunnel-success-step'); - - screen.getByText('Subscription confirmed!'); - }, 10000); + // it('tests the entire process of subscribing with a voucher from a batch order', async () => { + // /** + // * Initialization. + // */ + // const course = PacedCourseFactory().one(); + // const product = ProductFactory().one(); + // const offering = OfferingFactory({ + // course, + // product, + // is_withdrawable: false, + // }).one(); + // const paymentPlan = PaymentPlanFactory().one(); + + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/`, + // offering, + // ); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/`, + // paymentPlan, + // ); + // fetchMock.get(`https://joanie.endpoint/api/v1.0/enrollments/`, []); + // const orderQueryParameters = { + // product_id: product.id, + // course_code: course.code, + // state: NOT_CANCELED_ORDER_STATES, + // }; + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`, + // [], + // ); + + // render(, { + // queryOptions: { client: createTestQueryClient({ user: richieUser }) }, + // }); + + // // Wait for product information to be fetched + // await screen.findByRole('heading', { level: 3, name: product.title }); + // // Price is displayed, meaning the product is not bought yet. + // screen.getByText( + // // the price formatter generates non-breaking spaces and getByText doesn't seem to handle that well, replace it + // // with a regular space. We replace NNBSP (\u202F) and NBSP (\u00a0) with a regular space + // formatPrice(product.price_currency, product.price), + // ); + // expect(screen.queryByText('Purchased')).not.toBeInTheDocument(); + + // /** + // * Purchase. + // */ + // const user = userEvent.setup(); + // const buyButton = screen.getByRole('button', { name: product.call_to_action }); + + // // The SaleTunnel should not be displayed. + // expect(screen.queryByTestId('generic-sale-tunnel-payment-step')).not.toBeInTheDocument(); + + // await user.click(buyButton); + + // // The SaleTunnel should be displayed. + // screen.getByTestId('generic-sale-tunnel-payment-step'); + + // /** + // * Submit voucher and check price + // */ + // const paymentPlanVoucher = PaymentPlanFactory({ + // discounted_price: 0, + // discount: '-100%', + // payment_schedule: undefined, + // from_batch_order: true, + // }).one(); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/?voucher_code=DISCOUNT100`, + // paymentPlanVoucher, + // { overwriteRoutes: true }, + // ); + // await user.type(screen.getByLabelText('Voucher code'), 'DISCOUNT100'); + // await user.click(screen.getByRole('button', { name: 'Validate' })); + // expect(screen.queryByRole('heading', { name: 'Payment schedule' })).not.toBeInTheDocument(); + // await screen.findByTestId('sale-tunnel__total__amount'); + // const $totalAmountVoucher = screen.getByTestId('sale-tunnel__total__amount'); + // expect($totalAmountVoucher).toHaveTextContent( + // 'Total' + + // formatPrice(product.price_currency, paymentPlanVoucher.price!) + + // formatPrice(product.price_currency, paymentPlanVoucher.discounted_price!), + // ); + + // /** + // * Make sure the checkbox to waive withdrawal right is not displayed + // */ + // expect(screen.queryByTestId('withdraw-right-checkbox')).not.toBeInTheDocument(); + + // /** + // * Subscribe + // */ + // const order = CredentialOrderFactory({ + // state: OrderState.COMPLETED, + // payment_schedule: undefined, + // }).one(); + // fetchMock + // .post('https://joanie.endpoint/api/v1.0/orders/', order) + // .get( + // `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`, + // [order], + // { overwriteRoutes: true }, + // ); + + // const $button = screen.getByRole('button', { + // name: `Subscribe`, + // }) as HTMLButtonElement; + // await user.click($button); + + // /** + // * No withdrawal error should be displayed. + // */ + // expect( + // await screen.queryByText('You must waive your withdrawal right.'), + // ).not.toBeInTheDocument(); + + // // // Make sure the success step is shown. + // await screen.findByTestId('generic-sale-tunnel-success-step'); + + // screen.getByText('Subscription confirmed!'); + // }, 10000); }); diff --git a/src/frontend/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx b/src/frontend/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx index 50847da979..de41437943 100644 --- a/src/frontend/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +++ b/src/frontend/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx @@ -66,10 +66,10 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => { `https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?signature_state=half_signed&page=1`, [], ); - fetchMock.get( - `https://joanie.endpoint/api/v1.0/organizations/${organization.id}/agreements/?signature_state=half_signed&page=1`, - [], - ); + // fetchMock.get( + // `https://joanie.endpoint/api/v1.0/organizations/${organization.id}/agreements/?signature_state=half_signed&page=1`, + // [], + // ); render(, { routerOptions: { @@ -82,7 +82,7 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => { nbApiCalls += 1; // course api call nbApiCalls += 1; // offerings api call nbApiCalls += 1; // contracts api call - nbApiCalls += 1; // agreements api call + // nbApiCalls += 1; // agreements api call const calledUrls = fetchMock.calls().map((call) => call[0]); expect(calledUrls).toHaveLength(nbApiCalls); expect(calledUrls).toContain( diff --git a/src/frontend/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx b/src/frontend/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx index bd2229dce5..32c3c3d410 100644 --- a/src/frontend/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx +++ b/src/frontend/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx @@ -37,7 +37,7 @@ export const LearnerDashboardSidebar = (props: Partial) = LearnerDashboardPaths.CERTIFICATES, LearnerDashboardPaths.CONTRACTS, LearnerDashboardPaths.PREFERENCES, - LearnerDashboardPaths.BATCH_ORDERS, + // LearnerDashboardPaths.BATCH_ORDERS, ].map((path) => ({ to: generatePath(path), label: getRouteLabel(path), diff --git a/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx b/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx index bbddb82e7c..53c0f19407 100644 --- a/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx +++ b/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx @@ -56,11 +56,11 @@ describe('', () => { // It should display menu links const links = screen.getAllByRole('link'); - expect(links).toHaveLength(4); + expect(links).toHaveLength(2); expect(links[0]).toHaveTextContent('Courses'); expect(links[1]).toHaveTextContent('Contracts'); - expect(links[2]).toHaveTextContent('Quotes'); - expect(links[3]).toHaveTextContent('Agreements'); + // expect(links[2]).toHaveTextContent('Quotes'); + // expect(links[3]).toHaveTextContent('Agreements'); // No badge should be displayed next to contract link expect(links[1].nextSibling).toBeNull(); }); diff --git a/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx b/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx index 144ca8cca7..589c80e24b 100644 --- a/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +++ b/src/frontend/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx @@ -60,8 +60,8 @@ export const TeacherDashboardOrganizationSidebar = () => { const links = [ TeacherDashboardPaths.ORGANIZATION_COURSES, TeacherDashboardPaths.ORGANIZATION_CONTRACTS, - TeacherDashboardPaths.ORGANIZATION_QUOTES, - TeacherDashboardPaths.ORGANIZATION_AGREEMENTS, + // TeacherDashboardPaths.ORGANIZATION_QUOTES, + // TeacherDashboardPaths.ORGANIZATION_AGREEMENTS, ].map(getMenuLinkFromPath); if (fetching) {