Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

feat(tests): migrate for monorepo #38

Closed
wants to merge 1 commit into from
Closed

feat(tests): migrate for monorepo #38

wants to merge 1 commit into from

Conversation

Haroenv
Copy link

@Haroenv Haroenv commented Nov 15, 2022

  • wrap tests in "flavor" factory
  • remove ci setup (doesn't work with old URL anymore)

BREAKING CHANGE: this requires the url to be /examples/js/e-commerce instead of /examples/e-commerce. This means that until the package is in the monorepo, its tests wouldn't pass. After the main monorepo PR is merged, this repo will move inside and will no longer be published.

- wrap tests in "flavor" factory
- remove ci setup (doesn't work with old URL anymore)

BREAKING CHANGE: this requires the url to be /examples/js/e-commerce instead of /examples/e-commerce. This means that until the package is in the monorepo, its tests wouldn't pass. After the main monorepo PR is merged, this repo will move inside and will no longer be published.
@Haroenv
Copy link
Author

Haroenv commented Nov 21, 2022

This PR is ready for review, but should not be merged as there's no need to have this next version tagged outside of the InstantSearch monorepo

@Haroenv Haroenv requested review from a team, sarahdayan and aymeric-giraudet and removed request for a team November 21, 2022 17:18
it('navigates to the e-commerce demo', async () => {
await browser.url('examples/e-commerce/');
});
export function brandAndQuery(flavor: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function brandAndQuery(flavor: string) {
export function createBrandAndQueryTestSuite(flavor: string) {

it('selects "Apple" brand in list', async () => {
await browser.clickRefinementListItem('Apple');
});
describe('Search on specific brand and query filtering', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('Search on specific brand and query filtering', () => {
describe('search on specific brand and query filtering', () => {

it('navigates to the e-commerce demo', async () => {
await browser.url('examples/e-commerce/');
});
export function category(flavor: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function category(flavor: string) {
export function createCategoryTestSuite(flavor: string) {

it('navigates to the e-commerce demo', async () => {
await browser.url('examples/e-commerce/');
});
export function brandAndQuery(flavor: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type should be typeof flavors[number], same for the other factories.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that first but the flavor file needs to be cjs for it to work in the config, and then I'm either writing the flavours twice without validation, or have it as a string (what I preferred in the end)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah 😞 Can't we use .mjs configs with WebdriverIO?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with newer versions we can do it in typescript I think, I'll look if possible to upgrade once migrated in monorepo

it('selects "Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Appliances');
});
describe('Search on specific category', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('Search on specific category', () => {
describe('search on specific category', () => {

`examples/e-commerce/search/Appliances%2FSmall+Kitchen+Appliances/?${params.toString()}`
);
});
export function initialStateFromRoute(flavor: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function initialStateFromRoute(flavor: string) {
export function createInitialStateFromRouteTestSuite(flavor: string) {

it('navigates to the e-commerce demo', async () => {
await browser.url('examples/e-commerce/');
});
export function pagination(flavor: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function pagination(flavor: string) {
export function createPaginationTestSuite(flavor: string) {

it('navigates to next page', async () => {
await browser.clickNextPage();
});
describe('Page navigation', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('Page navigation', () => {
describe('page navigation', () => {

describe('InstantSearch - Search on specific price range', () => {
let lowerBound: number;
let upperBound: number;
export function priceRange(flavor: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function priceRange(flavor: string) {
export function createPriceRangeTestSuite(flavor: string) {

Comment on lines +1 to +16
import { brandAndQuery } from './specs/brand-and-query.spec';
import { category } from './specs/category.spec';
import { initialStateFromRoute } from './specs/initial-state-from-route.spec';
import { pagination } from './specs/pagination.spec';
import { priceRange } from './specs/price-range.spec';
import { flavors } from './flavors';

flavors.forEach(flavor => {
describe(flavor, () => {
brandAndQuery(flavor);
category(flavor);
initialStateFromRoute(flavor);
pagination(flavor);
priceRange(flavor);
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { brandAndQuery } from './specs/brand-and-query.spec';
import { category } from './specs/category.spec';
import { initialStateFromRoute } from './specs/initial-state-from-route.spec';
import { pagination } from './specs/pagination.spec';
import { priceRange } from './specs/price-range.spec';
import { flavors } from './flavors';
flavors.forEach(flavor => {
describe(flavor, () => {
brandAndQuery(flavor);
category(flavor);
initialStateFromRoute(flavor);
pagination(flavor);
priceRange(flavor);
});
});
import { createBrandAndQueryTestSuite } from './specs/brand-and-query.spec';
import { createCategoryTestSuite } from './specs/category.spec';
import { createInitialStateFromRouteTestSuite } from './specs/initial-state-from-route.spec';
import { createPaginationTestSuite } from './specs/pagination.spec';
import { createPriceRangeTestSuite } from './specs/price-range.spec';
import { flavors } from './flavors';
flavors.forEach(flavor => {
describe(flavor, () => {
createBrandAndQueryTestSuite(flavor);
createCategoryTestSuite(flavor);
createInitialStateFromRouteTestSuite(flavor);
createPaginationTestSuite(flavor);
createPriceRangeTestSuite(flavor);
});
});

@Haroenv
Copy link
Author

Haroenv commented Nov 23, 2022

I've done the rewording suggestions in algolia/instantsearch@854a553

@sarahdayan
Copy link
Member

@Haroenv Will you close this PR then?

@Haroenv Haroenv closed this Nov 24, 2022
@Haroenv Haroenv deleted the feat/monorepo branch November 24, 2022 09:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants