Skip to content

Commit

Permalink
chore(remote-manifest.e2e): add test for bad URL in manifest.json
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHax committed Nov 8, 2023
1 parent 93a927a commit 95488ba
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
:content="messageCount"
:color="messageBadgeColor"
:model-value="messageCount > 0"
id="notifications"
>
<tool-button
size="40"
Expand Down
18 changes: 18 additions & 0 deletions tests/pageobjects/volview.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ class VolViewPage extends Page {
);
}

get notifications() {
return $('#notifications');
}

async waitForNotification() {
const this_ = this;
await browser.waitUntil(
async () => {
const badge = await this_.notifications.$('span[aria-label="Badge"]');
const notificationCount = parseInt(await badge.getHTML(), 10);
return notificationCount >= 1;
},
{
timeoutMsg: `expected notification badge to display`,
}
);
}

get rectangleButton() {
return $('button span i[class~=mdi-vector-square]');
}
Expand Down
24 changes: 24 additions & 0 deletions tests/specs/remote-manifest.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as path from 'path';
import * as fs from 'fs';
import { cleanuptotal } from 'wdio-cleanuptotal-service';
import { TEMP_DIR } from '../../wdio.shared.conf';
import { volViewPage } from '../pageobjects/volview.page';

describe('VolView loading of remoteManifest.json', () => {
it('should show error when there is no name and URL is malformed', async () => {
const manifest = {
resources: [{ url: 'foo' }],
};
// write object as json to file
const fileName = 'remoteFilesBadUrl.json';
const filePath = path.join(TEMP_DIR, fileName);
await fs.promises.writeFile(filePath, JSON.stringify(manifest));
cleanuptotal.addCleanup(async () => {
fs.unlinkSync(filePath);
});

const urlParams = `?urls=[tmp/${fileName}]`;
await volViewPage.open(urlParams);
await volViewPage.waitForNotification();
});
});

0 comments on commit 95488ba

Please sign in to comment.