-
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.
Merge pull request #8 from conlacda/fix_issue_4_5_7
- Loading branch information
Showing
9 changed files
with
169 additions
and
39 deletions.
There are no files selected for viewing
71 changes: 55 additions & 16 deletions
71
browser-extension/chrome-extension-test/tests/submission_details.spec.ts
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 |
---|---|---|
@@ -1,68 +1,107 @@ | ||
import {test, expect} from '../fixtures'; | ||
import {Page, Locator, Download} from "@playwright/test"; | ||
import { test, expect } from '../fixtures'; | ||
import { Page, Locator, Download } from "@playwright/test"; | ||
import * as fs from 'fs'; | ||
|
||
require('dotenv').config({path: './.env'}); | ||
require('dotenv').config({ path: './.env' }); | ||
|
||
// chromium.launch PersistentContext prevents you from using multiple pages, so do not use parallel mode. | ||
// The parallel mode opens each tab for each test, and the context will be closed after one test. | ||
test.describe.configure({mode: 'serial'}); | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
let page: Page; | ||
const EXTENDED_PROBLEM_SUBMISSION_URL: string = 'https://atcoder.jp/contests/abc298/submissions/60492340'; | ||
const CE_SUBMISSION_URL = 'https://atcoder.jp/contests/abc298/submissions/60492314'; | ||
const MAPPING_PROBLEM_SUBMISSION_URL = 'https://atcoder.jp/contests/abc044/submissions/60493350'; | ||
|
||
test.beforeAll(async ({context}) => { | ||
test.beforeAll(async ({ context }) => { | ||
page = await context.newPage(); | ||
const SUBMISSION_URL: string = 'https://atcoder.jp/contests/abc347/submissions/51807898'; | ||
await page.goto(SUBMISSION_URL); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await page.close(); | ||
}); | ||
|
||
test.describe('Extension functions correctly on the submission details page', () => { | ||
test.describe('Copy button', () => { | ||
test.describe('Copy button - extended problem', () => { | ||
test('Copy input', async () => { | ||
await page.goto(EXTENDED_PROBLEM_SUBMISSION_URL); | ||
const copyButton: Locator = page.locator('#copy-in-0'); | ||
const copiedButton: Locator = page.locator('#copied-in-0'); | ||
await copyButton.dispatchEvent('click'); | ||
await expect(copiedButton).toBeVisible(); | ||
expect(await page.evaluate(() => navigator.clipboard.readText())).toContain("yay"); | ||
const copiedText = await page.evaluate(() => navigator.clipboard.readText()); | ||
const onlyNumberText = copiedText.replace(/\D/g, ''); | ||
expect(onlyNumberText).toBe('5344525153411253'); | ||
}); | ||
test('Copy output', async () => { | ||
test('Copy input - mapping problem', async () => { | ||
await page.goto(MAPPING_PROBLEM_SUBMISSION_URL); | ||
const copyButton: Locator = page.locator('#copy-in-0'); | ||
const copiedButton: Locator = page.locator('#copied-in-0'); | ||
await copyButton.dispatchEvent('click'); | ||
await expect(copiedButton).toBeVisible(); | ||
const copiedText = await page.evaluate(() => navigator.clipboard.readText()); | ||
const onlyNumberText = copiedText.replace(/\D/g, ''); | ||
expect(onlyNumberText).toBe('53100009000'); | ||
}); | ||
test('Copy output - extended problem', async () => { | ||
await page.goto(EXTENDED_PROBLEM_SUBMISSION_URL); | ||
const copyButton: Locator = page.locator('#copy-out-0'); | ||
const copiedButton: Locator = page.locator('#copied-out-0'); | ||
await copyButton.dispatchEvent('click'); | ||
await expect(copiedButton).toBeVisible(); | ||
expect(await page.evaluate(() => navigator.clipboard.readText())).toContain("5"); | ||
const copiedText = await page.evaluate(() => navigator.clipboard.readText()); | ||
const onlyNumberText = copiedText.replace(/\D/g, ''); | ||
expect(onlyNumberText).toContain('463'); | ||
}); | ||
test('Copy output - mapping problem', async () => { | ||
await page.goto(MAPPING_PROBLEM_SUBMISSION_URL); | ||
const copyButton: Locator = page.locator('#copy-out-0'); | ||
const copiedButton: Locator = page.locator('#copied-out-0'); | ||
await copyButton.dispatchEvent('click'); | ||
await expect(copiedButton).toBeVisible(); | ||
const copiedText = await page.evaluate(() => navigator.clipboard.readText()); | ||
const onlyNumberText = copiedText.replace(/\D/g, ''); | ||
expect(onlyNumberText).toContain('48000'); | ||
}); | ||
}); | ||
|
||
test.describe('Download button', () => { | ||
test('Download input', async () => { | ||
await page.goto(EXTENDED_PROBLEM_SUBMISSION_URL); | ||
const downloadButton: Locator = page.locator('#download-in-0'); | ||
const downloadPromise = page.waitForEvent('download'); | ||
await downloadButton.click(); | ||
const download: Download = await downloadPromise; | ||
expect(download.suggestedFilename()).toBe("in-00_sample_01.txt"); | ||
expect(download.suggestedFilename()).toBe("in-sample00.txt"); | ||
await download.saveAs(download.suggestedFilename()); | ||
const contents = await fs.promises.readFile(await download.path(), 'utf-8'); | ||
expect(contents).toContain("yay"); | ||
const onlyNumberText = contents.replace(/\D/g, ''); | ||
expect(onlyNumberText).toContain('5344525153411253'); | ||
}); | ||
test('Download output', async () => { | ||
await page.goto(EXTENDED_PROBLEM_SUBMISSION_URL); | ||
const downloadButton: Locator = page.locator('#download-out-0'); | ||
const downloadPromise = page.waitForEvent('download'); | ||
await downloadButton.click(); | ||
const download: Download = await downloadPromise; | ||
expect(download.suggestedFilename()).toBe("out-00_sample_01.txt"); | ||
expect(download.suggestedFilename()).toBe("out-sample00.txt"); | ||
await download.saveAs(download.suggestedFilename()); | ||
const contents = await fs.promises.readFile(await download.path(), 'utf-8'); | ||
expect(contents).toContain("5"); | ||
const onlyNumberText = contents.replace(/\D/g, ''); | ||
expect(onlyNumberText).toContain('463'); | ||
}); | ||
}) | ||
|
||
test('Debug button', async () => { | ||
await page.goto(EXTENDED_PROBLEM_SUBMISSION_URL); | ||
const debugButton: Locator = page.locator('#debug-0'); | ||
await debugButton.click(); | ||
await page.waitForURL('https://atcoder.jp/contests/abc347/custom_test?submissionId=51807898&testcase=00_sample_01&problem=B'); | ||
await page.waitForURL('https://atcoder.jp/contests/abc298/custom_test?submissionId=60492340&testcase=sample00&problem=Ex'); | ||
}); | ||
|
||
test('Do not show the debug button in a table that is not the result table', async () => { | ||
await page.goto(CE_SUBMISSION_URL); | ||
const debugButton: Locator = page.locator('th:has-text("Debug")'); | ||
await expect(debugButton).toHaveCount(0); | ||
}); | ||
}); |
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
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
52 changes: 52 additions & 0 deletions
52
browser-extension/chrome-extension/scripts/shared/testcase_mapping.js
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,52 @@ | ||
/** | ||
* Source of this mapping is from https://kenkoooo.com/atcoder/resources/problems.json | ||
* Check item['id'] and item['contest_id'] + "_" + item['problem_index'] | ||
* If they are different, we need to map them. | ||
*/ | ||
const mappingForTestCase = { | ||
"abc044": "arc060", | ||
"abc045": "arc061", | ||
"abc046": "arc062", | ||
"abc047": "arc063", | ||
"abc048": "arc064", | ||
"abc049": "arc065", | ||
"abc050": "arc066", | ||
"abc052": "arc067", | ||
"abc053": "arc068", | ||
"abc055": "arc069", | ||
"abc056": "arc070", | ||
"abc058": "arc071", | ||
"abc059": "arc072", | ||
"abc060": "arc073", | ||
"abc062": "arc074", | ||
"abc063": "arc075", | ||
"abc065": "arc076", | ||
"abc066": "arc077", | ||
"abc067": "arc078", | ||
"abc068": "arc079", | ||
"abc069": "arc080", | ||
"abc071": "arc081", | ||
"abc072": "arc082", | ||
"abc074": "arc083", | ||
"abc077": "arc084", | ||
"abc078": "arc085", | ||
"abc081": "arc086", | ||
"abc082": "arc087", | ||
"abc083": "arc088", | ||
"abc086": "arc089", | ||
"abc087": "arc090", | ||
"abc090": "arc091", | ||
"abc091": "arc092", | ||
"abc092": "arc093", | ||
"abc093": "arc094", | ||
"abc094": "arc095", | ||
"abc095": "arc096", | ||
"abc097": "arc097", | ||
"abc098": "arc098", | ||
"abc101": "arc099", | ||
"abc102": "arc100", | ||
"abc107": "arc101", | ||
"abc108": "arc102", | ||
"abc111": "arc103", | ||
} | ||
|
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
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