Skip to content

Commit

Permalink
diplay service provider error message
Browse files Browse the repository at this point in the history
Signed-off-by: aporss <art.porss@yahooinc.com>
  • Loading branch information
ArtjomsPorss committed Oct 8, 2024
1 parent 06ccf23 commit a7dbc8c
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ exports[`ProviderTable should render 1`] = `
vertical-align: text-bottom;
}
.emotion-17 {
text-align: left;
padding: 5px 0 5px 15px;
vertical-align: middle;
}
<td
class="emotion-0 emotion-1"
color=""
colspan="7"
colspan="8"
data-testid="provider-table"
>
<table
Expand Down Expand Up @@ -130,6 +136,15 @@ exports[`ProviderTable should render 1`] = `
</svg>
</div>
</td>
<td
class="emotion-17 emotion-18"
>
<div
data-testid="error-message"
name="red600"
style="color: rgb(208, 17, 17); display: inline-block;"
/>
</td>
</tr>
</tbody>
</table>
Expand All @@ -147,7 +162,5 @@ exports[`ProviderTable should render error if allow api throws error 1`] = `
data-testid="error-message"
name="red600"
style="color: rgb(208, 17, 17); display: inline-block;"
>
Failed to fetch template details.
</div>
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ exports[`ServiceList should render add service modal after click 1`] = `
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -264,7 +265,7 @@ exports[`ServiceList should render add service modal after click 1`] = `
class="emotion-29"
data-testid="icon"
height="1.25em"
id=""
id="openhouse-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down Expand Up @@ -451,6 +452,7 @@ exports[`ServiceList should render delete service modal error(other) after click
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -579,7 +581,7 @@ exports[`ServiceList should render delete service modal error(other) after click
class="emotion-29"
data-testid="icon"
height="1.25em"
id=""
id="openhouse-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down Expand Up @@ -756,6 +758,7 @@ exports[`ServiceList should render delete service modal error(refresh) after cli
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -884,7 +887,7 @@ exports[`ServiceList should render delete service modal error(refresh) after cli
class="emotion-29"
data-testid="icon"
height="1.25em"
id=""
id="openhouse-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down Expand Up @@ -1061,6 +1064,7 @@ exports[`ServiceList should render serviceList again after cancel delete 1`] = `
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -1189,7 +1193,7 @@ exports[`ServiceList should render serviceList again after cancel delete 1`] = `
class="emotion-29"
data-testid="icon"
height="1.25em"
id=""
id="openhouse-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down Expand Up @@ -1344,6 +1348,7 @@ exports[`ServiceList should render serviceList again after confirm delete 1`] =
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -1525,6 +1530,7 @@ exports[`ServiceList should render with services 1`] = `
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -1653,7 +1659,7 @@ exports[`ServiceList should render with services 1`] = `
class="emotion-29"
data-testid="icon"
height="1.25em"
id=""
id="openhouse-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down Expand Up @@ -1808,6 +1814,7 @@ exports[`ServiceList should render without services 1`] = `
</div>
<table
class="emotion-5 emotion-6"
id="services-table"
>
<thead>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ exports[`ServiceRow should render row 1`] = `
class="emotion-8"
data-testid="icon"
height="1.25em"
id=""
id="serviceName-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ exports[`ServicePage should render 1`] = `
</div>
<table
class="emotion-103 emotion-104"
id="services-table"
>
<thead>
<tr>
Expand Down Expand Up @@ -1489,7 +1490,7 @@ exports[`ServicePage should render 1`] = `
class="emotion-84"
data-testid="icon"
height="1.25em"
id=""
id="bastion-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down Expand Up @@ -1612,7 +1613,7 @@ exports[`ServicePage should render 1`] = `
class="emotion-84"
data-testid="icon"
height="1.25em"
id=""
id="openhouse-providers"
viewBox="0 0 1024 1024"
width="1.25em"
>
Expand Down
93 changes: 93 additions & 0 deletions ui/src/__tests__/spec/tests/services.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

const serviceNameForProvidersTest = 'providers-error-test-service';

describe('services screen tests', () => {
it('when clicking help tooltip link, it should open a tab with athenz guide', async () => {
// open browser
Expand Down Expand Up @@ -81,4 +83,95 @@ describe('services screen tests', () => {
let modalDeleteButton = await $('button*=Delete');
await modalDeleteButton.click();
});

it('when clicking "Allow" button on a provider without having appropriate authorisation, the error should be displayed to the right of the button', async () => {
// open browser
await browser.newUser();
await browser.url(`/`);
// select domain
let domain = 'athenz.dev.functional-test';
let testDomain = await $(`a*=${domain}`);
await browser.waitUntil(async () => await testDomain.isClickable());
await testDomain.click();

// open Services
let servicesDiv = await $('div*=Services');
await servicesDiv.click();

// use date and time when creating a service because if we recreate service with same name - it will reference
// previous provider allowances
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const dateTimeFormatted = `${year}-${month}-${day}-${hours}-${minutes}-${seconds}`;

// add service
const serviceNameWithDate = `${serviceNameForProvidersTest}-${dateTimeFormatted}`;
let addServiceButton = await $('button*=Add Service');
await addServiceButton.click();
let serviceNameInput = await $('input[id="service-name"]');
await serviceNameInput.addValue(serviceNameWithDate);
let submitButton = await $('button*=Submit');
await submitButton.click();

// click Providers
let providersButton = await $(`.//*[local-name()="svg" and @id="${serviceNameWithDate + '-providers'}"]`);
await providersButton.click();

// click Azure provider
let awsProviderAllowButton = await $(`td[data-testid="provider-table"]`)
.$(`//td[text()="Azure VM launches instances for the service"]/following-sibling::td//button`);
await awsProviderAllowButton.click();

// warning should appear
let warning = await $(`td[data-testid="provider-table"]`)
.$(`//td[text()="Azure VM launches instances for the service"]/following-sibling::td//div[text()="Status: 404. Message: unknown domain - athenz.azure.provider"]`);
await expect(warning).toHaveText('Status: 404. Message: unknown domain - athenz.azure.provider');
});

// after - runs after the last test in order of declaration
after(async() => {
// open browser
await browser.newUser();
await browser.url(`/`);
// select domain
let domain = 'athenz.dev.functional-test';
let testDomain = await $(`a*=${domain}`);
await browser.waitUntil(async () => await testDomain.isClickable());
await testDomain.click();

// open Services
let servicesDiv = await $('div*=Services');
await servicesDiv.click();

// wait until services table is populated with services
await browser.waitUntil(async () => {
const table = await $('//table[@id="services-table"]')
const rows = await table.$$('tr');
return rows.length > 0;
}, {
timeout: 1000,
timeoutMsg: `Services table did not have a service containing ${serviceNameForProvidersTest}.`
});

// get all the services created during the test
let deleteButtons = await $$(`[id*="delete-service-${serviceNameForProvidersTest}"]`);

// iteratively get delete buttons, pick only ones that match our ID and delete these
for (let i = 0; i < await deleteButtons.length; i++) {
const deleteButton = deleteButtons[i];
const id = await deleteButton.getAttribute('id');
await deleteButton.click();
let deleteButtonOnModal = await $('button*=Delete');
await deleteButtonOnModal.click();
// wait until the notification about successful deletion disappears - so that next deletion can be done
let deletedDiv = await $('div*=Successfully deleted service');
await deletedDiv.waitForDisplayed({ reverse: true, timeout: 10000 });
console.log("DELETED SERVICE", id)
}
});
})
Loading

0 comments on commit a7dbc8c

Please sign in to comment.