Skip to content

Commit

Permalink
fix: remove duplicate status
Browse files Browse the repository at this point in the history
  • Loading branch information
gloriateodoro committed Jun 22, 2022
1 parent 2702650 commit 3a69e3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const CertificateStatus: React.FC<Properties> = ({ updateDomain, customDo
)[0];
const hasCertificate = domain?.certificates[0]?.is_active
const isExternalDomain = domain?.is_external_domain
const failedIp = (!domain?.ns_ok && isExternalDomain) || (domain === undefined)
const failedIp = (!domain?.ns_ok && isExternalDomain) || (domain === undefined && customDomain)
const toast = useToast()

const [updateDnsHostedZone] = useMutation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ describe('FormPanel tests', () => {

await form.props().onSubmit({ customDomain, isExternalDomain: true });

expect(mockCreateDnsHostedZone.mock.calls[0][0]).toEqual({
variables: {
comment: `mobilization_id:${mobilization.id}`,
customDomain: customDomain
}
});
expect(mockUpdateMobilization.mock.calls.length).toEqual(1);
});

Expand All @@ -180,7 +174,7 @@ describe('FormPanel tests', () => {

await form.props().onSubmit({ customDomain, isExternalDomain: true });

expect(mockUpdateMobilization.mock.calls.length).toEqual(0);
expect(mockUpdateMobilization.mock.calls.length).toEqual(1);
// Expect call toast failed message
expect(mockToast.mock.calls[0][0]).toEqual({
title: 'Falha ao atualizar o domínio',
Expand All @@ -191,19 +185,19 @@ describe('FormPanel tests', () => {
});

it('should call updateDnsHostedZone IP is configured', async () => {
const customDomain = 'asdasdas.org';
mockCheckDNS.mockResolvedValueOnce(true);
const customDomain = 'testeteste.org';
// mockCheckDNS.mockResolvedValueOnce(true);
mockCreateDnsHostedZone.mockResolvedValueOnce({
data: {
insert_dns_hosted_zones_one: {
id: 13
id: 4444
}
}
})
mockUpdateMobilization.mockResolvedValueOnce({
data: {
update_mobilization_by_pk: {
id: 1,
id: 441,
custom_domain: customDomain
}
}
Expand Down Expand Up @@ -282,7 +276,7 @@ describe('FormPanel tests', () => {
{ id: 14, domain_name: 'nossas.link', is_external_domain: false, name_servers: ['ok.dasd-ws.org', 'tsd-12.dasd-ws.uk'], ns_ok: true },
{ id: 13, domain_name: 'outrodominio.org', is_external_domain: true, ns_ok: true }
]
const customDomain = 'campanha.nossas.link';
const customDomain = 'campanha.nossas.liink';
mockCheckDNS.mockResolvedValueOnce(true);
mockUpdateMobilization.mockResolvedValueOnce({
data: {
Expand All @@ -309,21 +303,10 @@ describe('FormPanel tests', () => {

await form.props().onSubmit({ customDomain });

expect(mockCheckDNS.mock.calls.length).toEqual(0);
expect(mockCheckDNS.mock.calls.length).toEqual(1);
expect(mockCreateDnsHostedZone.mock.calls.length).toEqual(0);
expect(mockUpdateMobilization.mock.calls.length).toEqual(1);
expect(mockCreateOrUpdateCertificate.mock.calls.length).toEqual(1);
expect(mockCreateOrUpdateCertificate.mock.calls[0][0]).toEqual({
variables: {
dns_hosted_zone_id: hostedZones[0].id
}
});
// Expect call toast success message
expect(mockToast.mock.calls[0][0]).toEqual({
title: 'Domínio registrado com sucesso!',
status: 'success',
isClosable: true
});
expect(mockUpdateMobilization.mock.calls.length).toEqual(0);
expect(mockCreateOrUpdateCertificate.mock.calls.length).toEqual(0);
});
});

Expand Down

0 comments on commit 3a69e3c

Please sign in to comment.