forked from jsnbuchanan/crowd-funder-for-time-pwa
fix error setting the apiServer to "", plus some refactors while fixing test 40
This commit is contained in:
@@ -25,8 +25,9 @@ export default defineConfig({
|
|||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: [
|
reporter: [
|
||||||
['list'],
|
['list'],
|
||||||
['html', { open: 'never' }],
|
['html'],
|
||||||
['json', { outputFile: 'test-results/test-results.json' }]
|
// ['html', { open: 'never' }], // don't automatically open report page after tests complete even with failures
|
||||||
|
['json', { outputFile: 'test-playwright-results/test-results.json' }]
|
||||||
],
|
],
|
||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ db.version(4)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const DEFAULT_SETTINGS = {
|
const DEFAULT_SETTINGS: Settings = {
|
||||||
id: MASTER_SETTINGS_KEY,
|
id: MASTER_SETTINGS_KEY,
|
||||||
activeDid: undefined,
|
activeDid: undefined,
|
||||||
apiServer: DEFAULT_ENDORSER_API_SERVER,
|
apiServer: DEFAULT_ENDORSER_API_SERVER,
|
||||||
@@ -183,15 +183,21 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update settings for the given account, or in MASTER_SETTINGS_KEY if no accountDid is provided.
|
export async function updateDefaultSettings(
|
||||||
// Don't expose this because we should be explicit on whether we're updating the default settings or account settings.
|
settingsChanges: Settings,
|
||||||
async function updateSettings(settingsChanges: Settings): Promise<void> {
|
): Promise<void> {
|
||||||
await db.open();
|
delete settingsChanges.accountDid; // just in case
|
||||||
if (!settingsChanges.accountDid) {
|
|
||||||
// ensure there is no "id" that would override the key
|
// ensure there is no "id" that would override the key
|
||||||
delete settingsChanges.id;
|
delete settingsChanges.id;
|
||||||
await db.settings.update(MASTER_SETTINGS_KEY, settingsChanges);
|
await db.settings.update(MASTER_SETTINGS_KEY, settingsChanges);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
export async function updateAccountSettings(
|
||||||
|
accountDid: string,
|
||||||
|
settingsChanges: Settings,
|
||||||
|
): Promise<void> {
|
||||||
|
settingsChanges.accountDid = accountDid;
|
||||||
|
delete settingsChanges.id; // key off account, not ID
|
||||||
const result = await db.settings
|
const result = await db.settings
|
||||||
.where("accountDid")
|
.where("accountDid")
|
||||||
.equals(settingsChanges.accountDid)
|
.equals(settingsChanges.accountDid)
|
||||||
@@ -206,20 +212,6 @@ async function updateSettings(settingsChanges: Settings): Promise<void> {
|
|||||||
await db.settings.add(settingsChanges);
|
await db.settings.add(settingsChanges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export async function updateDefaultSettings(settings: Settings): Promise<void> {
|
|
||||||
delete settings.accountDid; // just in case
|
|
||||||
await updateSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function updateAccountSettings(
|
|
||||||
accountDid: string,
|
|
||||||
settings: Settings,
|
|
||||||
): Promise<void> {
|
|
||||||
settings.accountDid = accountDid;
|
|
||||||
await updateSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
// similar method is in the sw_scripts/additional-scripts.js file
|
// similar method is in the sw_scripts/additional-scripts.js file
|
||||||
export async function logConsoleAndDb(
|
export async function logConsoleAndDb(
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ export default class Help extends Vue {
|
|||||||
async unsetFinishedOnboarding() {
|
async unsetFinishedOnboarding() {
|
||||||
const settings = await retrieveSettingsForActiveAccount();
|
const settings = await retrieveSettingsForActiveAccount();
|
||||||
if (settings.activeDid) {
|
if (settings.activeDid) {
|
||||||
await updateAccountSettings(settings.activeDid || "", {
|
await updateAccountSettings(settings.activeDid, {
|
||||||
finishedOnboarding: false,
|
finishedOnboarding: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,7 +539,6 @@ export default class HomeView extends Vue {
|
|||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
await updateAccountSettings(this.activeDid, {
|
await updateAccountSettings(this.activeDid, {
|
||||||
isRegistered: true,
|
isRegistered: true,
|
||||||
apiServer: "",
|
|
||||||
});
|
});
|
||||||
this.isRegistered = true;
|
this.isRegistered = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,8 +92,10 @@ test('Add contact, record gift, confirm gift', async ({ page }) => {
|
|||||||
await page.goto('./contacts');
|
await page.goto('./contacts');
|
||||||
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F, ' + userName);
|
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F, ' + userName);
|
||||||
await page.locator('button > svg.fa-plus').click();
|
await page.locator('button > svg.fa-plus').click();
|
||||||
|
// This should not be visible because user #1 is not registered, but firefox is getting the logic wrong somehow.
|
||||||
|
// await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible();
|
||||||
|
// await page.locator('div[role="alert"] button:has-text("No")').click();
|
||||||
await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible();
|
await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible();
|
||||||
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
|
|
||||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
||||||
await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone
|
await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone
|
||||||
|
|
||||||
@@ -187,7 +189,9 @@ test('Add contact, copy details, delete, and import from paste & from file', asy
|
|||||||
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39, User #111');
|
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39, User #111');
|
||||||
await page.locator('button > svg.fa-plus').click();
|
await page.locator('button > svg.fa-plus').click();
|
||||||
await expect(page.locator('div[role="alert"]')).toBeVisible();
|
await expect(page.locator('div[role="alert"]')).toBeVisible();
|
||||||
|
await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible();
|
||||||
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
|
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
|
||||||
|
await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible();
|
||||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
||||||
// wait for the alert to disappear
|
// wait for the alert to disappear
|
||||||
await expect(page.locator('div[role="alert"]')).toBeHidden();
|
await expect(page.locator('div[role="alert"]')).toBeHidden();
|
||||||
@@ -196,7 +200,9 @@ test('Add contact, copy details, delete, and import from paste & from file', asy
|
|||||||
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x222BB77E6Ff3774d34c751f3c1260866357B677b, User #222, asdf1234');
|
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x222BB77E6Ff3774d34c751f3c1260866357B677b, User #222, asdf1234');
|
||||||
await page.locator('button > svg.fa-plus').click();
|
await page.locator('button > svg.fa-plus').click();
|
||||||
await expect(page.locator('div[role="alert"]')).toBeVisible();
|
await expect(page.locator('div[role="alert"]')).toBeVisible();
|
||||||
|
await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible();
|
||||||
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
|
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
|
||||||
|
await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible();
|
||||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
||||||
await expect(page.locator('div[role="alert"]')).toBeHidden();
|
await expect(page.locator('div[role="alert"]')).toBeHidden();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user