Skip to content

Commit

Permalink
feat(tests): migrate for monorepo
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Haroenv committed Nov 15, 2022
1 parent 85b0a9e commit 9a40ee9
Show file tree
Hide file tree
Showing 16 changed files with 403 additions and 462 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Test specs
command: yarn test:saucelabs
name: Lint
command: yarn lint

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},
overrides: [
{
files: ['specs/**/*.spec.ts'],
files: ['specs/**/*.spec.ts', 'all-flavors.spec.ts'],
extends: ['plugin:wdio/recommended'],
plugins: ['wdio'],
env: {
Expand Down
16 changes: 16 additions & 0 deletions tests/e2e/all-flavors.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
});
});
3 changes: 3 additions & 0 deletions tests/e2e/flavors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
flavors: ['js'],
};
3 changes: 0 additions & 3 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
"scripts": {
"commit": "git-cz",
"version": "conventional-changelog --preset angular --infile CHANGELOG.md --same-file && git add CHANGELOG.md",
"test": "yarn test:local",
"test:local": "yarn link && cd tests && ./instantsearch.js.sh && ./react-instantsearch.sh && ./vue-instantsearch.sh",
"test:saucelabs": "SAUCELABS=1 yarn test:local",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
"type-check": "tsc",
Expand Down
72 changes: 38 additions & 34 deletions tests/e2e/specs/brand-and-query.spec.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
describe('InstantSearch - Search on specific brand and query filtering', () => {
it('navigates to the e-commerce demo', async () => {
await browser.url('examples/e-commerce/');
});
export function brandAndQuery(flavor: string) {
const root = `examples/${flavor}/e-commerce/`;

it('selects "Apple" brand in list', async () => {
await browser.clickRefinementListItem('Apple');
});
describe('Search on specific brand and query filtering', () => {
it('navigates to the e-commerce demo', async () => {
await browser.url(root);
});

it('fills search input with "macbook"', async () => {
await browser.setSearchBoxValue('macbook');
});
it('selects "Apple" brand in list', async () => {
await browser.clickRefinementListItem('Apple');
});

it('waits for the results list to be updated (wait for the "macbook" word to be highlighted)', async () => {
await browser.waitForElement('mark=MacBook');
});
it('fills search input with "macbook"', async () => {
await browser.setSearchBoxValue('macbook');
});

it('waits for the results list to be updated (wait for the "macbook" word to be highlighted)', async () => {
await browser.waitForElement('mark=MacBook');
});

it('must have the expected results', async () => {
const hitsTitles = await browser.getHitsTitles();
it('must have the expected results', async () => {
const hitsTitles = await browser.getHitsTitles();

expect(hitsTitles).toEqual([
'Apple - MacBook Air® (Latest Model) - 13.3" Display - Intel Core i5 - 8GB Memory - 128GB Flash Storage - Silver',
'Apple - MacBook Air® (Latest Model) - 13.3" Display - Intel Core i5 - 8GB Memory - 256GB Flash Storage - Silver',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Space Gray',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Rose Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Silver',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Space Gray',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Rose Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Silver',
'Apple - MacBook Pro with Retina display - 13.3" Display - 8GB Memory - 128GB Flash Storage - Silver',
'Apple - MacBook Pro® - 13" Display - Intel Core i5 - 8 GB Memory - 256GB Flash Storage (latest model) - Space Gray',
'Apple - MacBook® Pro - 15.4" Display - Intel Core i7 - 16GB Memory - 256GB Flash Storage - Silver',
'Apple - MacBook Pro® - 13" Display - Intel Core i5 - 8 GB Memory - 256GB Flash Storage (latest model) - Silver',
'Apple - MacBook® Pro - Intel Core i5 - 13.3" Display - 4GB Memory - 500GB Hard Drive - Silver',
'Apple - MacBook Pro 13.3" Refurbished Laptop - Intel Core i5 - 4GB Memory - 320GB - Silver',
]);
expect(hitsTitles).toEqual([
'Apple - MacBook Air® (Latest Model) - 13.3" Display - Intel Core i5 - 8GB Memory - 128GB Flash Storage - Silver',
'Apple - MacBook Air® (Latest Model) - 13.3" Display - Intel Core i5 - 8GB Memory - 256GB Flash Storage - Silver',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Space Gray',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Rose Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M3 - 8GB Memory - 256GB Flash Storage - Silver',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Space Gray',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Rose Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Gold',
'Apple - Macbook® (Latest Model) - 12" Display - Intel Core M5 - 8GB Memory - 512GB Flash Storage - Silver',
'Apple - MacBook Pro with Retina display - 13.3" Display - 8GB Memory - 128GB Flash Storage - Silver',
'Apple - MacBook Pro® - 13" Display - Intel Core i5 - 8 GB Memory - 256GB Flash Storage (latest model) - Space Gray',
'Apple - MacBook® Pro - 15.4" Display - Intel Core i7 - 16GB Memory - 256GB Flash Storage - Silver',
'Apple - MacBook Pro® - 13" Display - Intel Core i5 - 8 GB Memory - 256GB Flash Storage (latest model) - Silver',
'Apple - MacBook® Pro - Intel Core i5 - 13.3" Display - 4GB Memory - 500GB Hard Drive - Silver',
'Apple - MacBook Pro 13.3" Refurbished Laptop - Intel Core i5 - 4GB Memory - 320GB - Silver',
]);
});
});
});
}
118 changes: 61 additions & 57 deletions tests/e2e/specs/category.spec.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
describe('InstantSearch - Search on specific category', () => {
it('navigates to the e-commerce demo', async () => {
await browser.url('examples/e-commerce/');
});
export function category(flavor: string) {
const root = `examples/${flavor}/e-commerce/`;

it('selects "Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Appliances');
});
describe('Search on specific category', () => {
it('navigates to the e-commerce demo', async () => {
await browser.url(root);
});

it('selects "Small Kitchen Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Small Kitchen Appliances');
});
it('selects "Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Appliances');
});

it('must have the expected results for "Small Kitchen Appliances"', async () => {
const hitsTitles = await browser.getHitsTitles();

expect(hitsTitles).toEqual([
'Insignia™ - 2.6 Cu. Ft. Compact Refrigerator - Black',
'Keurig - K50 Coffeemaker - Black',
'Keurig - K200 Brewer - Black',
'Frigidaire - 3.3 Cu. Ft. Compact Refrigerator - Stainless Steel',
'Ninja - Mega Kitchen System 72-Oz. Blender - Black',
'Ninja - Nutri Ninja Pro 24-Oz. Blender - Black/Silver',
'Oster - Inspire 2-Slice Wide-Slot Toaster - Black',
'Keurig - The Original Donut Shop K-Cup® Pods (18-Pack)',
'Chefman - Express Air Fryer - Black',
'Oster - 10-Speed Blender - Black',
'Keurig - Swiss Miss Milk Chocolate Hot Cocoa K-Cup® Pods (16-Pack)',
'Keurig - Cinnabon Classic Cinnamon Roll K-Cup® Pods (18-Pack) - Multi',
'Ninja - Nutri Ninja 32 Oz. Auto-iQ Blender - Black',
'Anova - Precision Cooker WiFi',
'Nespresso - VertuoLine Evoluo Espresso Maker/Coffeemaker - Gray',
'Magic Bullet - Blender - Silver/Black',
]);
});
it('selects "Small Kitchen Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Small Kitchen Appliances');
});

it('unselects "Small Kitchen Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Small Kitchen Appliances');
});
it('must have the expected results for "Small Kitchen Appliances"', async () => {
const hitsTitles = await browser.getHitsTitles();

expect(hitsTitles).toEqual([
'Insignia™ - 2.6 Cu. Ft. Compact Refrigerator - Black',
'Keurig - K50 Coffeemaker - Black',
'Keurig - K200 Brewer - Black',
'Frigidaire - 3.3 Cu. Ft. Compact Refrigerator - Stainless Steel',
'Ninja - Mega Kitchen System 72-Oz. Blender - Black',
'Ninja - Nutri Ninja Pro 24-Oz. Blender - Black/Silver',
'Oster - Inspire 2-Slice Wide-Slot Toaster - Black',
'Keurig - The Original Donut Shop K-Cup® Pods (18-Pack)',
'Chefman - Express Air Fryer - Black',
'Oster - 10-Speed Blender - Black',
'Keurig - Swiss Miss Milk Chocolate Hot Cocoa K-Cup® Pods (16-Pack)',
'Keurig - Cinnabon Classic Cinnamon Roll K-Cup® Pods (18-Pack) - Multi',
'Ninja - Nutri Ninja 32 Oz. Auto-iQ Blender - Black',
'Anova - Precision Cooker WiFi',
'Nespresso - VertuoLine Evoluo Espresso Maker/Coffeemaker - Gray',
'Magic Bullet - Blender - Silver/Black',
]);
});

it('unselects "Small Kitchen Appliances" category in list', async () => {
await browser.clickHierarchicalMenuItem('Small Kitchen Appliances');
});

it('must have the expected results for "Appliances"', async () => {
const hitsTitles = await browser.getHitsTitles();

it('must have the expected results for "Appliances"', async () => {
const hitsTitles = await browser.getHitsTitles();

expect(hitsTitles).toEqual([
'Nest - Learning Thermostat - 3rd Generation - Stainless Steel',
'LG - 1.1 Cu. Ft. Mid-Size Microwave - Stainless-Steel',
'Insignia™ - 2.6 Cu. Ft. Compact Refrigerator - Black',
'Keurig - K50 Coffeemaker - Black',
'iRobot - Roomba 650 Vacuuming Robot - Black',
'Shark - Navigator Lift-Away Deluxe Bagless Upright Vacuum - Blue',
'LG - 1.5 Cu. Ft. Mid-Size Microwave - Stainless Steel',
'Insignia™ - 5.0 Cu. Ft. Chest Freezer - White',
'Samsung - activewash 4.8 Cu. Ft. 11-Cycle High-Efficiency Top-Loading Washer - White',
'Samsung - 4.8 Cu. Ft. 11-Cycle High-Efficiency Top-Loading Washer - White',
'LG - 2.0 Cu. Ft. Full-Size Microwave - Stainless Steel',
'Shark - Rotator Professional Lift-Away HEPA Bagless 2-in-1 Upright Vacuum - Red',
'LG - 4.5 Cu. Ft. 8-Cycle High-Efficiency Top-Loading Washer - White',
'Samsung - 4.2 Cu. Ft. 9-Cycle High-Efficiency Steam Front-Loading Washer - Platinum',
'Panasonic - 1.3 Cu. Ft. Mid-Size Microwave - Stainless steel/black/silver',
'LG - 2.0 Cu. Ft. Mid-Size Microwave - Black Stainless',
]);
expect(hitsTitles).toEqual([
'Nest - Learning Thermostat - 3rd Generation - Stainless Steel',
'LG - 1.1 Cu. Ft. Mid-Size Microwave - Stainless-Steel',
'Insignia™ - 2.6 Cu. Ft. Compact Refrigerator - Black',
'Keurig - K50 Coffeemaker - Black',
'iRobot - Roomba 650 Vacuuming Robot - Black',
'Shark - Navigator Lift-Away Deluxe Bagless Upright Vacuum - Blue',
'LG - 1.5 Cu. Ft. Mid-Size Microwave - Stainless Steel',
'Insignia™ - 5.0 Cu. Ft. Chest Freezer - White',
'Samsung - activewash 4.8 Cu. Ft. 11-Cycle High-Efficiency Top-Loading Washer - White',
'Samsung - 4.8 Cu. Ft. 11-Cycle High-Efficiency Top-Loading Washer - White',
'LG - 2.0 Cu. Ft. Full-Size Microwave - Stainless Steel',
'Shark - Rotator Professional Lift-Away HEPA Bagless 2-in-1 Upright Vacuum - Red',
'LG - 4.5 Cu. Ft. 8-Cycle High-Efficiency Top-Loading Washer - White',
'Samsung - 4.2 Cu. Ft. 9-Cycle High-Efficiency Steam Front-Loading Washer - Platinum',
'Panasonic - 1.3 Cu. Ft. Mid-Size Microwave - Stainless steel/black/silver',
'LG - 2.0 Cu. Ft. Mid-Size Microwave - Black Stainless',
]);
});
});
});
}
Loading

0 comments on commit 9a40ee9

Please sign in to comment.