Skip to content

Commit

Permalink
test: improve e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cawa-93 committed Dec 17, 2022
1 parent f1e1d9f commit a8d054d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/renderer/src/components/ReactiveHash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const hashedString = computed(() => sha256sum(rawString.value));
<label>
Raw value
<input
id="reactive-hash-raw-value"
v-model="rawString"
type="text"
/>
Expand All @@ -21,6 +22,7 @@ const hashedString = computed(() => sha256sum(rawString.value));
<label>
Hashed by node:crypto
<input
id="reactive-hash-hashed-value"
v-model="hashedString"
readonly
type="text"
Expand Down
15 changes: 12 additions & 3 deletions tests/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ test('Main window web content', async () => {

test('Preload versions', async () => {
const page = await electronApp.firstWindow();
const renderedVersions = await page.locator('#process-versions').innerText();
const versionsElement = page.locator('#process-versions');
expect(await versionsElement.count(), 'expect find one element #process-versions').toStrictEqual(1);

const renderedVersions = await versionsElement.innerText();
const expectedVersions = await electronApp.evaluate(() => process.versions);

for (const expectedVersionsKey in expectedVersions) {
Expand All @@ -62,8 +64,15 @@ test('Preload nodeCrypto', async () => {
// Test hashing a random string
const testString = Math.random().toString(36).slice(2, 7);

await page.fill('input', testString);
const renderedHash = await page.inputValue('input[readonly]');
const rawInput = page.locator('input#reactive-hash-raw-value');
expect(await rawInput.count(), 'expect find one element input#reactive-hash-raw-value').toStrictEqual(1);

const hashedInput = page.locator('input#reactive-hash-hashed-value');
expect(await hashedInput.count(), 'expect find one element input#reactive-hash-hashed-value').toStrictEqual(1);


await rawInput.fill(testString);
const renderedHash = await hashedInput.inputValue();
const expectedHash = createHash('sha256').update(testString).digest('hex');
expect(renderedHash).toEqual(expectedHash);
});

0 comments on commit a8d054d

Please sign in to comment.