|
| 1 | +const ISSO_ENDPOINT = process.env.ISSO_ENDPOINT ? |
| 2 | + process.env.ISSO_ENDPOINT : 'http://localhost:8080'; |
| 3 | + |
| 4 | +beforeEach(async () => { |
| 5 | + await page.goto( |
| 6 | + ISSO_ENDPOINT + '/demo#isso-1', |
| 7 | + { waitUntil: 'load' } |
| 8 | + ) |
| 9 | + await expect(page.url()).toBe(ISSO_ENDPOINT + '/demo/index.html#isso-1'); |
| 10 | +}) |
| 11 | + |
| 12 | +test('Linked should be highlighted', async () => { |
| 13 | + await expect(page).toFill( |
| 14 | + '.isso-textarea', |
| 15 | + 'A comment with *italics* and [a link](http://link.com)' |
| 16 | + ); |
| 17 | + const [postCreated] = await Promise.all([ |
| 18 | + page.waitForResponse(async (response) => |
| 19 | + response.url().includes('/new') && response.ok(), |
| 20 | + { timout: 500 } |
| 21 | + ), |
| 22 | + expect(page).toClick('.isso-post-action > input[type=submit]'), |
| 23 | + ]); |
| 24 | + |
| 25 | + // Refresh page to arm window.location.hash listeners |
| 26 | + await page.goto( |
| 27 | + ISSO_ENDPOINT + '/demo#isso-1', |
| 28 | + { waitUntil: 'load' } |
| 29 | + ) |
| 30 | + |
| 31 | + let highlightedComment = await expect(page).toMatchElement('#isso-1'); |
| 32 | + let wrapper = await expect(highlightedComment).toMatchElement('.isso-target'); |
| 33 | + |
| 34 | + // Use another (invalid) hash |
| 35 | + await page.goto( |
| 36 | + ISSO_ENDPOINT + '/demo#isso-x', |
| 37 | + { waitUntil: 'load' } |
| 38 | + ) |
| 39 | + await expect(page).not.toMatchElement('.isso-target'); |
| 40 | + |
| 41 | + // Cleanup |
| 42 | + // Need to click once to surface "confirm" and then again to confirm |
| 43 | + await expect(page).toClick('#isso-1 > .isso-text-wrapper > .isso-comment-footer > .isso-delete'); |
| 44 | + await expect(page).toClick('#isso-1 > .isso-text-wrapper > .isso-comment-footer > .isso-delete'); |
| 45 | +}); |
0 commit comments