-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently there's an off-by-one error when displaying a small file with fewer rows than the number used in previews (10). This fixes the off-by-one and introduces a test to ensure we don't re-introduce it.
- Loading branch information
Showing
3 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A,B | ||
1,2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
import * as fixtures from "./helpers/fixtures"; | ||
|
||
import { UploadPage } from './helpers/upload_page'; | ||
import { SheetSelectorPage } from './helpers/sheet_selector_page'; | ||
import { HeaderSelectorPage } from './helpers/header_selector_page'; | ||
import { FooterSelectorPage } from './helpers/footer_selector_page' | ||
import { MappingPage } from './helpers/mapping_page' | ||
|
||
const path = require('node:path'); | ||
|
||
// Take a screenshot to help with debugging | ||
const screenshot = async(page, name) => { | ||
await page.screenshot({ path: name, fullPage: true }); | ||
} | ||
|
||
test('tiny files', async ({ page }) => { | ||
await page.goto('/'); | ||
await page.getByText('Start now').click(); | ||
|
||
// --------------------------------------------------------------------------- | ||
// Upload a file | ||
await expect(page).toHaveURL(/.upload/) | ||
|
||
const uploadPage = new UploadPage(page) | ||
const browseButton = await uploadPage.browseButton() | ||
|
||
await browseButton.click(); | ||
await browseButton.setInputFiles(fixtures.getFixture('small-file.csv')); | ||
await uploadPage.submit(); | ||
|
||
// --------------------------------------------------------------------------- | ||
// Select sheet | ||
await expect(page).toHaveURL(/.select_sheet/) | ||
|
||
const sheets = new SheetSelectorPage(page); | ||
|
||
// There is only a single sheet, it should default be selected and the table | ||
// visible | ||
const radioButton = await sheets.getRadio('Sheet1') | ||
await expect(radioButton).toBeChecked(); | ||
const vis = await sheets.getTableProperty(0, 'visibility') | ||
await expect(vis).toBe('visible') | ||
|
||
// // Check the data is present in the sheet previews | ||
const previewRow = await sheets.getTableRow(0, 0) | ||
const zerozero = await previewRow.locator("td").nth(0).textContent() | ||
const zeroone = await previewRow.locator("td").nth(1).textContent() | ||
await expect(zerozero).toBe("A") | ||
await expect(zeroone).toBe("B") | ||
|
||
await sheets.submit() | ||
|
||
// --------------------------------------------------------------------------- | ||
// Select some cells for a header row | ||
// We will use the entire first row as our selection | ||
await expect(page).toHaveURL(/.select_header_row/) | ||
|
||
const headers = new HeaderSelectorPage(page) | ||
await headers.select([0,0], [0,1]) | ||
await headers.submit() | ||
|
||
// // --------------------------------------------------------------------------- | ||
// // Do not choose a footer row, just click Skip | ||
await expect(page).toHaveURL(/.select_footer_row/) | ||
|
||
const footers = new FooterSelectorPage(page) | ||
await footers.skip() | ||
|
||
// // --------------------------------------------------------------------------- | ||
// // Perform the mapping after checking the previews here are what we expect | ||
await expect(page).toHaveURL(/.mapping/) | ||
|
||
const mapping = new MappingPage(page) | ||
|
||
const expectedColumns = ["A", "B"] | ||
const expectedExamples = [ | ||
"1", | ||
"2", | ||
] | ||
|
||
const colNames = await mapping.getColumnNames() | ||
expect(colNames).toStrictEqual(expectedColumns) | ||
Check failure on line 84 in prototypes/basic/tests/small-file.spec.js GitHub Actions / testsmall-file.spec.js:18:5 › tiny files
|
||
|
||
const examples = await mapping.getExamples() | ||
expect(examples).toStrictEqual(expectedExamples) | ||
|
||
await mapping.setMapping('A', 'Code') | ||
await mapping.setMapping('B', 'Name') | ||
await mapping.submit() | ||
|
||
// // --------------------------------------------------------------------------- | ||
// // Should be on the success page | ||
await expect(page).toHaveURL(/.success/) | ||
}); |