2021-11-09 15:33:08 -05:00
|
|
|
// These tests do not sign in with a user
|
|
|
|
|
|
|
|
const SeleniumHelper = require('./selenium-helpers.js');
|
|
|
|
|
|
|
|
const {
|
|
|
|
buildDriver,
|
|
|
|
clickXpath,
|
|
|
|
findByXpath,
|
2023-09-25 11:34:30 -04:00
|
|
|
getKey,
|
|
|
|
navigate
|
2021-11-09 15:33:08 -05:00
|
|
|
} = new SeleniumHelper();
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
2021-11-09 15:33:08 -05:00
|
|
|
|
2021-12-03 09:14:25 -05:00
|
|
|
jest.setTimeout(60000);
|
2021-11-09 15:33:08 -05:00
|
|
|
|
|
|
|
let driver;
|
|
|
|
|
|
|
|
describe('www-integration search', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
driver = await buildDriver('www-integration search');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(rootUrl);
|
2021-11-09 15:33:08 -05:00
|
|
|
});
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
afterAll(() => driver.quit());
|
2021-11-09 15:33:08 -05:00
|
|
|
|
|
|
|
test('search converts spaces', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const searchBar = await findByXpath('//div[contains(@class, "search-wrapper")]/div/input');
|
|
|
|
await searchBar.sendKeys(`Test search string${getKey('ENTER')}`);
|
2021-11-09 15:33:08 -05:00
|
|
|
|
|
|
|
// check url
|
2023-10-24 14:22:28 -04:00
|
|
|
const url = await driver.getCurrentUrl();
|
|
|
|
expect(url).toMatch(/^.*\?q=Test%20search%20string$/);
|
2021-11-09 15:33:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Search escapes symbols', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const searchBar = await findByXpath('//div[contains(@class, "search-wrapper")]/div/input');
|
|
|
|
await searchBar.sendKeys(`100% pen${getKey('ENTER')}`);
|
2021-11-09 15:33:08 -05:00
|
|
|
|
|
|
|
// check url
|
2023-10-24 14:22:28 -04:00
|
|
|
const url = await driver.getCurrentUrl();
|
|
|
|
expect(url).toMatch(/^.*\?q=100%25%20pen$/);
|
2021-11-09 15:33:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Switching to studios maintains search string', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const searchBar = await findByXpath('//div[contains(@class, "search-wrapper")]/div/input');
|
|
|
|
await searchBar.sendKeys(`100% pen${getKey('ENTER')}`);
|
2021-11-09 15:33:08 -05:00
|
|
|
|
|
|
|
// switch to studios tab
|
2023-10-23 19:13:56 -04:00
|
|
|
await clickXpath('//button//*[contains(text(),"Studios")]');
|
2021-11-09 15:33:08 -05:00
|
|
|
|
|
|
|
// check url
|
2023-10-24 14:22:28 -04:00
|
|
|
const url = await driver.getCurrentUrl();
|
|
|
|
expect(url).toMatch(/^.*\?q=100%25%20pen$/);
|
2021-11-09 15:33:08 -05:00
|
|
|
});
|
|
|
|
});
|