|
1 | | -describe('Smoke tests', () => { |
2 | | - beforeEach(async () => { |
3 | | - await page.goto(process.env.SOURCEGRAPH_URL || '') |
4 | | - }) |
| 1 | +const searchUrl = process.env.SOURCEGRAPH_URL || '' |
| 2 | +const resultCountSelector = '[data-testid="streaming-progress-skipped"]' |
| 3 | +const searchQuery = 'repo:^github.com/sourcegraph/smoke-tests-test-repository$' |
| 4 | +const expectedResultString = '1 result' |
5 | 5 |
|
| 6 | +describe('Smoke tests', () => { |
6 | 7 | it('successfully loads the application', async () => { |
| 8 | + await page.goto(searchUrl) |
7 | 9 | await expect(page).toMatch('Sourcegraph') |
8 | 10 | }) |
9 | 11 |
|
10 | 12 | it('successful runs a search', async () => { |
11 | | - // Update search input |
12 | | - await page.waitForSelector('.test-query-input textarea') |
13 | | - await expect(page).toFill( |
14 | | - '.test-query-input textarea', |
15 | | - 'repo:^github.com/sourcegraph/smoke-tests-test-repository$' |
16 | | - ) |
17 | | - |
18 | | - // Click search button |
19 | | - await expect(page).toClick('.test-search-button') |
| 13 | + // Perform a search by navigating to a search results page with the q parameter |
| 14 | + await page.goto(searchUrl + `?q=${encodeURIComponent(searchQuery)}`) |
20 | 15 |
|
21 | 16 | // Expect results count is shown correctly |
22 | | - await page.waitForSelector('[data-testid="streaming-progress-count"]') |
23 | | - await expect(page).toMatchElement('[data-testid="streaming-progress-count"]', { |
24 | | - text: '1 result', |
| 17 | + await page.waitForSelector(resultCountSelector) |
| 18 | + await expect(page).toMatchElement(resultCountSelector, { |
| 19 | + text: expectedResultString, |
25 | 20 | }) |
26 | 21 | }) |
27 | 22 | }) |
0 commit comments